diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 724c7b8..9b63338 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -9985,42 +9985,45 @@ namespace meta_hpp::detail typename From, typename ToDT = std::remove_pointer_t, typename FromDT = std::remove_pointer_t > - concept pointer_ucast_kind // + concept ucast_as_pointers // = (std::is_pointer_v && std::is_class_v) // &&(std::is_pointer_v && (std::is_class_v || std::is_void_v)) // - && (!std::is_const_v || std::is_const_v) // - &&(!std::is_volatile_v || std::is_volatile_v); // + && (std::is_const_v >= std::is_const_v) // + &&(std::is_volatile_v >= std::is_volatile_v); // template < typename To, typename From, typename ToDT = std::remove_reference_t, typename FromDT = std::remove_reference_t > - concept lvalue_reference_ucast_kind // + concept ucast_as_references // = (std::is_lvalue_reference_v && std::is_class_v) // &&(std::is_lvalue_reference_v && std::is_class_v) // - &&(!std::is_const_v || std::is_const_v) // - &&(!std::is_volatile_v || std::is_volatile_v); // + &&(std::is_const_v >= std::is_const_v) // + &&(std::is_volatile_v >= std::is_volatile_v); // } namespace meta_hpp { template < typename To, typename From > - requires detail::pointer_ucast_kind + requires detail::ucast_as_pointers To ucast(From from); template < typename To, typename From > - requires detail::lvalue_reference_ucast_kind + requires detail::ucast_as_references To ucast(From&& from); } namespace meta_hpp { template < typename To, typename From > - requires detail::pointer_ucast_kind + requires detail::ucast_as_pointers To ucast(From from) { - using from_data_type = std::remove_pointer_t; - using to_data_type = std::remove_pointer_t; + using from_cv_data_type = std::remove_pointer_t; + using from_data_type = std::remove_cv_t; + + using to_cv_data_type = std::remove_pointer_t; + using to_data_type = std::remove_cv_t; static_assert( detail::poly_info_enabled, @@ -10032,7 +10035,7 @@ namespace meta_hpp return nullptr; } - if constexpr ( std::is_same_v, std::remove_cv_t> ) { + if constexpr ( std::is_same_v ) { return from; } else { detail::type_registry& registry{detail::type_registry::instance()}; @@ -10051,19 +10054,19 @@ namespace meta_hpp } template < typename To, typename From > - requires detail::lvalue_reference_ucast_kind + requires detail::ucast_as_references // NOLINTNEXTLINE(*-missing-std-forward) To ucast(From&& from) { - using from_data_type = std::remove_reference_t; - using to_data_type = std::remove_reference_t; + using from_cv_data_type = std::remove_reference_t; + using to_cv_data_type = std::remove_reference_t; static_assert( - detail::poly_info_enabled, + detail::poly_info_enabled, "The type doesn't support ucasts. " "Use the META_HPP_ENABLE_POLY_INFO macro to fix it." ); - if ( to_data_type* ptr = ucast(std::addressof(from)) ) { + if ( to_cv_data_type* ptr = ucast(std::addressof(from)) ) { return *ptr; } diff --git a/headers/meta.hpp/meta_ucast.hpp b/headers/meta.hpp/meta_ucast.hpp index 38ede41..a862d5b 100644 --- a/headers/meta.hpp/meta_ucast.hpp +++ b/headers/meta.hpp/meta_ucast.hpp @@ -15,31 +15,31 @@ namespace meta_hpp::detail typename From, typename ToDT = std::remove_pointer_t, typename FromDT = std::remove_pointer_t > - concept pointer_ucast_kind // + concept ucast_as_pointers // = (std::is_pointer_v && std::is_class_v) // &&(std::is_pointer_v && (std::is_class_v || std::is_void_v)) // - && (!std::is_const_v || std::is_const_v) // - &&(!std::is_volatile_v || std::is_volatile_v); // + && (std::is_const_v >= std::is_const_v) // + &&(std::is_volatile_v >= std::is_volatile_v); // template < typename To, typename From, typename ToDT = std::remove_reference_t, typename FromDT = std::remove_reference_t > - concept lvalue_reference_ucast_kind // + concept ucast_as_references // = (std::is_lvalue_reference_v && std::is_class_v) // &&(std::is_lvalue_reference_v && std::is_class_v) // - &&(!std::is_const_v || std::is_const_v) // - &&(!std::is_volatile_v || std::is_volatile_v); // + &&(std::is_const_v >= std::is_const_v) // + &&(std::is_volatile_v >= std::is_volatile_v); // } namespace meta_hpp { template < typename To, typename From > - requires detail::pointer_ucast_kind + requires detail::ucast_as_pointers To ucast(From from); template < typename To, typename From > - requires detail::lvalue_reference_ucast_kind + requires detail::ucast_as_references To ucast(From&& from); } diff --git a/headers/meta.hpp/meta_ucast/ucast.hpp b/headers/meta.hpp/meta_ucast/ucast.hpp index 90496d0..7bb06f1 100644 --- a/headers/meta.hpp/meta_ucast/ucast.hpp +++ b/headers/meta.hpp/meta_ucast/ucast.hpp @@ -16,10 +16,13 @@ namespace meta_hpp { template < typename To, typename From > - requires detail::pointer_ucast_kind + requires detail::ucast_as_pointers To ucast(From from) { - using from_data_type = std::remove_pointer_t; - using to_data_type = std::remove_pointer_t; + using from_cv_data_type = std::remove_pointer_t; + using from_data_type = std::remove_cv_t; + + using to_cv_data_type = std::remove_pointer_t; + using to_data_type = std::remove_cv_t; static_assert( detail::poly_info_enabled, @@ -31,7 +34,7 @@ namespace meta_hpp return nullptr; } - if constexpr ( std::is_same_v, std::remove_cv_t> ) { + if constexpr ( std::is_same_v ) { return from; } else { detail::type_registry& registry{detail::type_registry::instance()}; @@ -50,19 +53,19 @@ namespace meta_hpp } template < typename To, typename From > - requires detail::lvalue_reference_ucast_kind + requires detail::ucast_as_references // NOLINTNEXTLINE(*-missing-std-forward) To ucast(From&& from) { - using from_data_type = std::remove_reference_t; - using to_data_type = std::remove_reference_t; + using from_cv_data_type = std::remove_reference_t; + using to_cv_data_type = std::remove_reference_t; static_assert( - detail::poly_info_enabled, + detail::poly_info_enabled, "The type doesn't support ucasts. " "Use the META_HPP_ENABLE_POLY_INFO macro to fix it." ); - if ( to_data_type* ptr = ucast(std::addressof(from)) ) { + if ( to_cv_data_type* ptr = ucast(std::addressof(from)) ) { return *ptr; }