File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 9
9
#include < cib/detail/runtime_conditional.hpp>
10
10
11
11
#include < stdx/compiler.hpp>
12
+ #include < stdx/type_traits.hpp>
12
13
13
14
namespace cib {
14
15
/* *
@@ -46,6 +47,12 @@ constexpr static detail::components<Components...> components{};
46
47
template <typename ... Services>
47
48
constexpr static detail::exports<Services...> exports{};
48
49
50
+ namespace detail {
51
+ template <typename T>
52
+ using maybe_funcptr_t =
53
+ stdx::conditional_t <stdx::is_function_v<T>, std::decay_t <T>, T>;
54
+ }
55
+
49
56
/* *
50
57
* Extend a service with new functionality.
51
58
*
@@ -57,7 +64,7 @@ constexpr static detail::exports<Services...> exports{};
57
64
*/
58
65
template <typename Service, typename ... Args>
59
66
[[nodiscard]] CONSTEVAL auto extend (Args const &...args) {
60
- return detail::extend<Service, Args...>{args...};
67
+ return detail::extend<Service, detail:: maybe_funcptr_t < Args> ...>{args...};
61
68
}
62
69
63
70
template <stdx::ct_string Name>
Original file line number Diff line number Diff line change @@ -46,10 +46,14 @@ struct Foo {
46
46
cib::extend<TestCallback<2 >>([]() { is_callback_invoked<2 > = true ; }));
47
47
};
48
48
49
+ namespace {
50
+ auto test_cb_1 () { is_callback_invoked<1 > = true ; }
51
+ } // namespace
52
+
49
53
struct Bar {
50
54
constexpr static auto config = cib::config(
51
55
cib::extend<TestCallback<0 >>([]() { is_callback_invoked<0 > = true ; }),
52
- cib::extend<TestCallback<1 >>([]() { is_callback_invoked< 1 > = true ; } ));
56
+ cib::extend<TestCallback<1 >>(test_cb_1 ));
53
57
};
54
58
55
59
struct Gorp {
You can’t perform that action at this time.
0 commit comments