@@ -24,47 +24,33 @@ namespace cib {
24
24
template <typename Config>
25
25
struct nexus {
26
26
private:
27
- template <typename T>
28
- using raw_service_t = decltype(initialized<Config, T>::value.template build<initialized<Config, T>>());
29
-
30
- template <typename T>
31
- CIB_CONSTINIT static inline raw_service_t <T> raw_service =
32
- initialized<Config, T>::value.template build<initialized<Config, T>>();
27
+ using this_t = nexus<Config>;
33
28
34
29
template <typename Tag>
35
30
using service_name_to_raw_type_t =
36
31
typename std::remove_const_t <std::remove_reference_t <decltype(cib::detail::find<Tag, cib::ServiceTagMetaFunc>(cib::initialized_builders_v<Config>))>>;
37
32
38
- template <typename T>
39
- using service_t =
40
- decltype (initialized<Config, service_name_to_raw_type_t <T>>::value.template build<initialized<Config, service_name_to_raw_type_t <T>>>());
33
+ // Workaround unfortunate bug in clang where it can't deduce "auto" sometimes
34
+ #define CIB_BUILD_SERVICE initialized<Config, service_name_to_raw_type_t <T>>::value.template build<initialized<Config, service_name_to_raw_type_t <T>>>()
41
35
42
36
public:
43
37
template <typename T>
44
- CIB_CONSTINIT static inline service_t <T> service =
45
- initialized<Config, service_name_to_raw_type_t <T>>::value. template build<initialized<Config, service_name_to_raw_type_t <T>>>();
38
+ constexpr static decltype (CIB_BUILD_SERVICE) service = CIB_BUILD_SERVICE;
39
+ # undef CIB_BUILD_SERVICE
46
40
47
41
static void init () {
48
42
detail::for_each (initialized_builders_v<Config>, [](auto b){
49
- // Tag/CleanTag is the type name of the builder_meta in the ordered_set
50
- using Tag = typename decltype (b)::Service;
51
- using CleanTag = std::remove_cv_t <std::remove_reference_t <Tag>>;
52
-
53
- using CleanTypename = std::remove_cv_t <std::remove_reference_t <decltype (b)>>;
43
+ using service_tag = typename decltype (b)::Service;
44
+ using clean_service_tag = std::remove_cv_t <std::remove_reference_t <service_tag>>;
54
45
55
- // the built implementation is stored in Build<>::value
56
- auto & builtValue = raw_service<CleanTypename>;
57
- using BuiltType = std::remove_reference_t <decltype (builtValue)>;
46
+ auto & service_impl = this_t ::service<clean_service_tag>;
47
+ using service_impl_type = std::remove_reference_t <decltype (service_impl)>;
58
48
59
- // if the built type is a pointer, then it is a function pointer and we should return its value
60
- // directly to the 'built<>' abstract interface variable.
61
- if constexpr (std::is_pointer_v<BuiltType>) {
62
- cib::service<CleanTag> = builtValue;
49
+ if constexpr (std::is_pointer_v<service_impl_type>) {
50
+ cib::service<clean_service_tag> = service_impl;
63
51
64
- // if the built type is not a pointer, then it is a class and the 'built<>' variable is a pointer to
65
- // the base class. we will need to get a pointer to the builtValue in order to initialize 'built<>'.
66
52
} else {
67
- cib::service<CleanTag > = &builtValue ;
53
+ cib::service<clean_service_tag > = &service_impl ;
68
54
}
69
55
});
70
56
}
0 commit comments