diff --git a/include/cib/config.hpp b/include/cib/config.hpp index 92775aab..d08bb896 100644 --- a/include/cib/config.hpp +++ b/include/cib/config.hpp @@ -11,13 +11,6 @@ #include namespace cib { -/** - * List of arguments to configure compile-time initialization of components. - * - * @see cib::conditional - */ -template constexpr static detail::args args{}; - /** * Container for project and component configuration declarations. * @@ -32,13 +25,7 @@ template constexpr static detail::args args{}; */ template [[nodiscard]] CONSTEVAL auto config(Configs const &...configs) { - return detail::config{args<>, configs...}; -} - -template -[[nodiscard]] CONSTEVAL auto config(detail::args config_args, - Configs const &...configs) { - return detail::config{config_args, configs...}; + return detail::config{configs...}; } /** @@ -64,10 +51,6 @@ constexpr static detail::exports exports{}; * @tparam Service * Type name of the service to extend. * - * @tparam ServiceTemplateArgs - * Template arguments to be passed to the service's - * builder add function. - * * @param args * Value arguments to be passed to the service's builder add function. */ diff --git a/include/cib/detail/components.hpp b/include/cib/detail/components.hpp index 0fcd28a2..eafeacb8 100644 --- a/include/cib/detail/components.hpp +++ b/include/cib/detail/components.hpp @@ -7,14 +7,12 @@ namespace cib::detail { template struct components : public detail::config_item { - template - [[nodiscard]] constexpr auto extends_tuple(Args const &...args) const { - return stdx::tuple_cat(Components::config.extends_tuple(args...)...); + [[nodiscard]] constexpr auto extends_tuple() const { + return stdx::tuple_cat(Components::config.extends_tuple()...); } - template - [[nodiscard]] constexpr auto exports_tuple(Args const &...args) const { - return stdx::tuple_cat(Components::config.exports_tuple(args...)...); + [[nodiscard]] constexpr auto exports_tuple() const { + return stdx::tuple_cat(Components::config.exports_tuple()...); } }; } // namespace cib::detail diff --git a/include/cib/detail/conditional.hpp b/include/cib/detail/conditional.hpp index b2eed003..0dfa14d6 100644 --- a/include/cib/detail/conditional.hpp +++ b/include/cib/detail/conditional.hpp @@ -10,24 +10,22 @@ namespace cib::detail { template requires std::is_default_constructible_v struct conditional : config_item { - detail::config, Configs...> body; + detail::config body; CONSTEVAL explicit conditional(Configs const &...configs) - : body{{}, configs...} {} + : body{configs...} {} - template - [[nodiscard]] constexpr auto extends_tuple(Args const &...) const { - if constexpr (Pred{}(Args{}...)) { - return body.extends_tuple(Args{}...); + [[nodiscard]] constexpr auto extends_tuple() const { + if constexpr (Pred{}()) { + return body.extends_tuple(); } else { return stdx::tuple<>{}; } } - template - [[nodiscard]] constexpr auto exports_tuple(Args const &...) const { - if constexpr (Pred{}(Args{}...)) { - return body.exports_tuple(Args{}...); + [[nodiscard]] constexpr auto exports_tuple() const { + if constexpr (Pred{}()) { + return body.exports_tuple(); } else { return stdx::tuple<>{}; } diff --git a/include/cib/detail/config_details.hpp b/include/cib/detail/config_details.hpp index 9d14473c..962014d8 100644 --- a/include/cib/detail/config_details.hpp +++ b/include/cib/detail/config_details.hpp @@ -13,30 +13,21 @@ template constexpr static auto as_constant_v = std::integral_constant, Value>{}; -template struct args {}; - -template struct config; - -template -struct config, ConfigTs...> : public detail::config_item { +template struct config : public detail::config_item { stdx::tuple configs_tuple; - CONSTEVAL explicit config(args, ConfigTs const &...configs) + CONSTEVAL explicit config(ConfigTs const &...configs) : configs_tuple{configs...} {} - template - [[nodiscard]] constexpr auto extends_tuple(Args const &...args) const { + [[nodiscard]] constexpr auto extends_tuple() const { return configs_tuple.apply([&](auto const &...configs_pack) { - return stdx::tuple_cat(configs_pack.extends_tuple( - args..., as_constant_v...)...); + return stdx::tuple_cat(configs_pack.extends_tuple()...); }); } - template - [[nodiscard]] constexpr auto exports_tuple(Args const &...args) const { + [[nodiscard]] constexpr auto exports_tuple() const { return configs_tuple.apply([&](auto const &...configs_pack) { - return stdx::tuple_cat(configs_pack.exports_tuple( - args..., as_constant_v...)...); + return stdx::tuple_cat(configs_pack.exports_tuple()...); }); } }; diff --git a/include/cib/detail/config_item.hpp b/include/cib/detail/config_item.hpp index ecb6a514..a31b130f 100644 --- a/include/cib/detail/config_item.hpp +++ b/include/cib/detail/config_item.hpp @@ -4,15 +4,11 @@ namespace cib::detail { struct config_item { - template - [[nodiscard]] constexpr auto - extends_tuple(Args const &...) const -> stdx::tuple<> { + [[nodiscard]] constexpr auto extends_tuple() const -> stdx::tuple<> { return {}; } - template - [[nodiscard]] constexpr auto - exports_tuple(InitArgs const &...) const -> stdx::tuple<> { + [[nodiscard]] constexpr auto exports_tuple() const -> stdx::tuple<> { return {}; } }; diff --git a/include/cib/detail/exports.hpp b/include/cib/detail/exports.hpp index d4cc3e7a..25969c7b 100644 --- a/include/cib/detail/exports.hpp +++ b/include/cib/detail/exports.hpp @@ -12,15 +12,13 @@ template struct service_entry { }; template struct exports : public detail::config_item { - template - [[nodiscard]] constexpr auto extends_tuple(InitArgs const &...) const - -> stdx::tuple...> { + [[nodiscard]] constexpr auto + extends_tuple() const -> stdx::tuple...> { return {extend{}...}; } - template [[nodiscard]] constexpr auto - exports_tuple(InitArgs const &...) const -> stdx::tuple { + exports_tuple() const -> stdx::tuple { return {}; } }; diff --git a/include/cib/detail/extend.hpp b/include/cib/detail/extend.hpp index ab21de0f..8210cc3a 100644 --- a/include/cib/detail/extend.hpp +++ b/include/cib/detail/extend.hpp @@ -15,9 +15,7 @@ struct extend : public config_item { CONSTEVAL explicit extend(Args const &...args) : args_tuple{args...} {} - template - [[nodiscard]] constexpr auto - extends_tuple(InitArgs const &...) const -> stdx::tuple { + [[nodiscard]] constexpr auto extends_tuple() const -> stdx::tuple { return {*this}; } }; diff --git a/test/cib/nexus.cpp b/test/cib/nexus.cpp index cc5e58e3..3ef9a4ab 100644 --- a/test/cib/nexus.cpp +++ b/test/cib/nexus.cpp @@ -99,16 +99,17 @@ TEST_CASE("configuration with multiple components, services, and features") { } } -struct SimpleConditionalComponent { +template struct SimpleConditionalComponent { + constexpr static auto config = cib::config(cib::conditional( - [](Arg) { return Arg::value == 42; }, + []() { return V == 42; }, cib::extend>([]() { is_callback_invoked<0> = true; }))); }; template struct ConditionalTestProject { - constexpr static auto config = - cib::config(cib::args, cib::exports>, - cib::components); + constexpr static auto config = cib::config( + cib::exports>, + cib::components>); }; TEST_CASE("configuration with one conditional component") { @@ -131,21 +132,20 @@ TEST_CASE("configuration with one conditional component") { } } -template struct ConditionalComponent { - constexpr static auto config = cib::config( - cib::conditional([](Arg) { return Arg::value == Id; }, - cib::extend>( - []() { is_callback_invoked = true; }))); +template struct ConditionalComponent { + constexpr static auto config = cib::config(cib::conditional( + []() { return EnId == Id; }, cib::extend>([]() { + is_callback_invoked = true; + }))); }; template struct ConditionalConfig { constexpr static auto config = cib::config( - cib::args, - cib::exports, TestCallback<1>, TestCallback<2>>, - cib::components, ConditionalComponent<1>, - ConditionalComponent<2>>); + cib::components, + ConditionalComponent, + ConditionalComponent>); }; TEST_CASE("configuration with conditional features") {