@@ -379,46 +379,48 @@ struct mcpplibs::primitives::underlying::common_rep_traits<ExplicitCommonRhs,
379379
380380template <> struct mcpplibs ::primitives::underlying::traits<VoidCommonLhs> {
381381 using value_type = VoidCommonLhs;
382- using rep_type = VoidCommonLhs ;
382+ using rep_type = int ;
383383
384384 static constexpr bool enabled = true ;
385385 static constexpr auto kind = category::integer;
386386
387- static constexpr rep_type to_rep (value_type value) noexcept { return value; }
387+ static constexpr rep_type to_rep (value_type value) noexcept {
388+ return value.value ;
389+ }
388390
389391 static constexpr value_type from_rep (rep_type value) noexcept {
390- return value;
392+ return VoidCommonLhs{ value} ;
391393 }
392394
393395 static constexpr bool is_valid_rep (rep_type) noexcept { return true ; }
394396};
395397
396398template <> struct mcpplibs ::primitives::underlying::traits<VoidCommonRhs> {
397399 using value_type = VoidCommonRhs;
398- using rep_type = VoidCommonRhs ;
400+ using rep_type = short ;
399401
400402 static constexpr bool enabled = true ;
401403 static constexpr auto kind = category::integer;
402404
403- static constexpr rep_type to_rep (value_type value) noexcept { return value; }
405+ static constexpr rep_type to_rep (value_type value) noexcept {
406+ return static_cast <rep_type>(value.value );
407+ }
404408
405409 static constexpr value_type from_rep (rep_type value) noexcept {
406- return value;
410+ return VoidCommonRhs{ value} ;
407411 }
408412
409413 static constexpr bool is_valid_rep (rep_type) noexcept { return true ; }
410414};
411415
412416template <>
413- struct mcpplibs ::primitives::underlying::common_rep_traits<VoidCommonLhs,
414- VoidCommonRhs> {
417+ struct mcpplibs ::primitives::underlying::common_rep_traits<int , short > {
415418 using type = void ;
416419 static constexpr bool enabled = true ;
417420};
418421
419422template <>
420- struct mcpplibs ::primitives::underlying::common_rep_traits<VoidCommonRhs,
421- VoidCommonLhs> {
423+ struct mcpplibs ::primitives::underlying::common_rep_traits<short , int > {
422424 using type = void ;
423425 static constexpr bool enabled = true ;
424426};
@@ -460,6 +462,24 @@ TEST(PrimitiveTraitsTest, UnderlyingTraitsDefaultsAndCustomRegistration) {
460462 (mcpplibs::primitives::underlying::traits<NotRegistered>::enabled));
461463}
462464
465+ TEST (PrimitiveTraitsTest, LegacyPrimitiveTraitsNamespaceAliasesRemainAvailable) {
466+ using value_t = mcpplibs::primitives::primitive<
467+ int , mcpplibs::primitives::policy::error::expected>;
468+ using legacy_traits_t =
469+ mcpplibs::primitives::traits::primitive_traits<value_t >;
470+ using meta_traits_t = mcpplibs::primitives::meta::traits<value_t >;
471+
472+ static_assert (std::same_as<typename legacy_traits_t ::value_type,
473+ typename meta_traits_t ::value_type>);
474+ static_assert (std::same_as<typename legacy_traits_t ::policies,
475+ typename meta_traits_t ::policies>);
476+ static_assert (std::same_as<
477+ mcpplibs::primitives::traits::make_primitive_t <
478+ int , typename legacy_traits_t ::policies>,
479+ value_t >);
480+ SUCCEED ();
481+ }
482+
463483TEST (PrimitiveTraitsTest,
464484 UnderlyingTypeRequiresValidRepTypeAndCategoryConsistency) {
465485 EXPECT_TRUE ((mcpplibs::primitives::underlying::traits<BadRep>::enabled));
@@ -558,6 +578,11 @@ TEST(PrimitiveTraitsTest, UnderlyingCommonRepCanBeCustomizedViaTraits) {
558578}
559579
560580TEST (PrimitiveTraitsTest, TypePoliciesRequireNonVoidCommonRep) {
581+ static_assert (std::is_arithmetic_v<
582+ mcpplibs::primitives::underlying::traits<VoidCommonLhs>::rep_type>);
583+ static_assert (std::is_arithmetic_v<
584+ mcpplibs::primitives::underlying::traits<VoidCommonRhs>::rep_type>);
585+
561586 using compatible_handler_t = mcpplibs::primitives::policy::type::handler<
562587 mcpplibs::primitives::policy::type::compatible,
563588 mcpplibs::primitives::operations::Addition, VoidCommonLhs, VoidCommonRhs>;
0 commit comments