@@ -5,65 +5,61 @@ module;
55export module mcpplibs.primitives.primitive.traits;
66
77// Import the policy taxonomy so we can inspect policy::traits<>.
8- export import mcpplibs.primitive .traits.policy;
8+ export import mcpplibs.primitives .traits.policy;
99
1010// Public default policy aliases — these must be visible to internal details.
1111export namespace mcpplibs ::primitives {
12- using default_value_policy = ::mcpplibs::primitive:: policy::unchecked_value;
13- using default_type_policy = ::mcpplibs::primitive:: policy::transparent_type;
14- using default_error_policy = ::mcpplibs::primitive:: policy::throw_error;
15- using default_concurrency_policy = ::mcpplibs::primitive:: policy::single_thread;
12+ using default_value_policy = policy::unchecked_value;
13+ using default_type_policy = policy::transparent_type;
14+ using default_error_policy = policy::throw_error;
15+ using default_concurrency_policy = policy::single_thread;
1616}
1717
1818// Internal implementation details — not exported.
1919namespace mcpplibs ::primitives::traits::details {
20- using policy_category = ::mcpplibs::primitive:: policy::category;
20+ using policy_category = policy::category;
2121
22- template <policy_category C,
23- ::mcpplibs::primitive::policy::policy_type... Policies>
22+ template <policy_category C, policy::policy_type... Policies>
2423struct count_matching_impl ;
2524
2625template <policy_category C> struct count_matching_impl <C> {
2726 static constexpr std::size_t value = 0 ;
2827};
2928
30- template <policy_category C, ::mcpplibs::primitive:: policy::policy_type First,
31- ::mcpplibs::primitive:: policy::policy_type... Rest>
29+ template <policy_category C, policy::policy_type First,
30+ policy::policy_type... Rest>
3231struct count_matching_impl <C, First, Rest...> {
3332 static constexpr std::size_t rest = count_matching_impl<C, Rest...>::value;
3433 static constexpr bool is_match =
35- ::mcpplibs::primitive::policy::traits<First>::enabled &&
36- (::mcpplibs::primitive::policy::traits<First>::kind == C);
34+ policy::traits<First>::enabled && policy::traits<First>::kind == C;
3735 static constexpr std::size_t value = rest + (is_match ? 1u : 0u );
3836};
3937
40- template <policy_category C,
41- ::mcpplibs::primitive::policy::policy_type... Policies>
38+ template <policy_category C, policy::policy_type... Policies>
4239constexpr std::size_t count_matching_v =
4340 count_matching_impl<C, Policies...>::value;
4441
45- template <policy_category C,
46- ::mcpplibs::primitive::policy::policy_type... Policies>
42+ template <policy_category C, policy::policy_type... Policies>
4743struct find_first_impl ;
4844
4945template <policy_category C> struct find_first_impl <C> {
5046 using type = void ;
5147};
5248
53- template <policy_category C, ::mcpplibs::primitive:: policy::policy_type First,
54- ::mcpplibs::primitive:: policy::policy_type... Rest>
49+ template <policy_category C, policy::policy_type First,
50+ policy::policy_type... Rest>
5551struct find_first_impl <C, First, Rest...> {
5652 static constexpr bool is_match =
57- ::mcpplibs::primitive:: policy::traits<First>::enabled &&
58- (::mcpplibs::primitive:: policy::traits<First>::kind == C) ;
53+ policy::traits<First>::enabled &&
54+ policy::traits<First>::kind == C;
5955 using type = std::conditional_t <is_match, First,
6056 typename find_first_impl<C, Rest...>::type>;
6157};
6258
63- template <policy_category C, primitive:: policy::policy_type... Policies>
59+ template <policy_category C, policy::policy_type... Policies>
6460using find_first_t = find_first_impl<C, Policies...>::type;
6561
66- template <policy_category C, primitive:: policy::policy_type... Policies>
62+ template <policy_category C, policy::policy_type... Policies>
6763struct resolve_policy_impl {
6864 static_assert (count_matching_v<C, Policies...> <= 1 ,
6965 " Multiple policies provided for the same category" );
@@ -72,37 +68,35 @@ struct resolve_policy_impl {
7268 using type = std::conditional_t <
7369 std::is_same_v<found, void >,
7470 std::conditional_t <
75- C == policy_category::value, primitives:: default_value_policy,
71+ C == policy_category::value, default_value_policy,
7672 std::conditional_t <
77- C == policy_category::type, primitives:: default_type_policy,
73+ C == policy_category::type, default_type_policy,
7874 std::conditional_t <C == policy_category::error,
79- primitives:: default_error_policy,
80- primitives:: default_concurrency_policy>>>,
75+ default_error_policy,
76+ default_concurrency_policy>>>,
8177 found>;
8278};
8379
8480template <policy_category C,
85- ::mcpplibs::primitive:: policy::policy_type... Policies>
86- using resolve_policy_t = typename resolve_policy_impl<C, Policies...>::type;
81+ policy::policy_type... Policies>
82+ using resolve_policy_t = resolve_policy_impl<C, Policies...>::type;
8783
8884} // namespace mcpplibs::primitives::traits::details
8985
9086// Public API exported from this module.
9187export namespace mcpplibs ::primitives::traits {
92- using policy_category = ::mcpplibs::primitive:: policy::category;
88+ using policy_category = policy::category;
9389
94- template <policy_category C,
95- ::mcpplibs::primitive::policy::policy_type... Policies>
96- using resolve_policy_t =
97- ::mcpplibs::primitives::traits::details::resolve_policy_t <C, Policies...>;
90+ template <policy_category C, policy::policy_type... Policies>
91+ using resolve_policy_t = details::resolve_policy_t <C, Policies...>;
9892
9993 template <typename P> struct primitive_traits ; // customization point for users
10094
10195 // Forward-declare exported `primitive` (defined in impl module).
102- template <typename T, ::mcpplibs::primitive:: policy::policy_type... Policies>
96+ template <typename T, policy::policy_type... Policies>
10397 struct primitive ;
10498
105- template <typename T, ::mcpplibs::primitive:: policy::policy_type... Policies>
99+ template <typename T, policy::policy_type... Policies>
106100 struct primitive_traits <primitive<T, Policies...>> {
107101 using value_type = T;
108102 using policies = std::tuple<Policies...>;
0 commit comments