Restructure into umbrella modules (~55 -> 16 targets)
Headers move, CMake targets merge, C++ namespaces stay unchanged: - Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant - Functional: Pipeline, Either, Result, Retry - Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval - Math: +Matrix, Numeric, Random, Histogram - Text: Str, Format, Tokenizer, Diff, Encoding, Semver - Data: Json, Csv, Ini - Async: Coro, Concurrency, EventBus, Observable - Time: +Bench - Log: Log facade + Logging framework (facade now header-only, breaking the Stacktrace<->Log link cycle the merge would have created) - System: FileSystem + Process - Configuration: +Argparse - Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail Module system fixes: - OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no longer depends on the alphabetical discovery order of src/ subdirs (Testing -> Text would have been silently dropped). - Every header-only module now has a tracked module.cmake; previously the empty src/<Name> marker dirs were untracked, so a fresh clone would have silently skipped those modules. - VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT. Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files prefixed: ResultBasic etc.). Test count verified identical (831) before and after. README/CLAUDE.md module tables updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da2e93c405
commit
28b94883fd
156 files changed
+278
-220
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Void::Pipeline
|
||||
{
|
||||
|
||||
// ── curry ─────────────────────────────────────────────────────────────────────
|
||||
// Transforms a multi-argument callable into a chain of single-argument calls.
|
||||
//
|
||||
// auto add = curry([](int a, int b) { return a + b; });
|
||||
// auto add5 = add(5); // partially applied — returns another callable
|
||||
// int sum = add5(3); // = 8, all args collected → invoked
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
template <typename F, typename... Collected>
|
||||
struct Curried
|
||||
{
|
||||
F fn;
|
||||
std::tuple<Collected...> args;
|
||||
|
||||
template <typename Arg>
|
||||
constexpr auto operator()(Arg&& arg) &&
|
||||
{
|
||||
auto new_args = std::tuple_cat(std::move(args),
|
||||
std::tuple<std::decay_t<Arg>>{std::forward<Arg>(arg)});
|
||||
using NewCurried = Curried<F, Collected..., std::decay_t<Arg>>;
|
||||
if constexpr (std::is_invocable_v<F, Collected..., std::decay_t<Arg>>) {
|
||||
return std::apply(fn, std::move(new_args));
|
||||
} else {
|
||||
return NewCurried{std::move(fn), std::move(new_args)};
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
constexpr auto operator()(Arg&& arg) const &
|
||||
{
|
||||
auto new_args = std::tuple_cat(args,
|
||||
std::tuple<std::decay_t<Arg>>{std::forward<Arg>(arg)});
|
||||
using NewCurried = Curried<F, Collected..., std::decay_t<Arg>>;
|
||||
if constexpr (std::is_invocable_v<F, Collected..., std::decay_t<Arg>>) {
|
||||
return std::apply(fn, std::move(new_args));
|
||||
} else {
|
||||
return NewCurried{std::move(fn), std::move(new_args)};
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace Detail
|
||||
|
||||
template <typename F>
|
||||
[[nodiscard]] constexpr auto curry(F&& fn)
|
||||
{
|
||||
return Detail::Curried<std::decay_t<F>>{std::forward<F>(fn), {}};
|
||||
}
|
||||
|
||||
} // namespace Void::Pipeline
|
||||
Reference in new issue
Block a user