mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 14:09:02 +07:00
fix all uvalue traits
ref: https://github.com/BlackMATov/meta.hpp/issues/100
This commit is contained in:
@@ -16,15 +16,15 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename T >
|
||||
concept has_copy_traits //
|
||||
= requires(const T& v) { copy_traits<T>{}(v); };
|
||||
= requires(const T& v) { copy_traits<std::remove_cv_t<T>>{}(v); };
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
requires(!std::is_class_v<T> && std::is_copy_constructible_v<T>)
|
||||
requires(!std::is_class_v<T>) && requires(T v) { uvalue{v}; }
|
||||
struct copy_traits<T> {
|
||||
uvalue operator()(const T& v) const {
|
||||
uvalue operator()(T v) const {
|
||||
return uvalue{v};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename T >
|
||||
concept has_deref_traits //
|
||||
= requires(const T& v) { deref_traits<T>{}(v); };
|
||||
= requires(const T& v) { deref_traits<std::remove_cv_t<T>>{}(v); };
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
requires has_copy_traits<T>
|
||||
requires has_copy_traits<T> && (!std::is_function_v<T>)
|
||||
struct deref_traits<T*> {
|
||||
uvalue operator()(T* v) const {
|
||||
return v != nullptr ? uvalue{*v} : uvalue{};
|
||||
|
||||
@@ -16,17 +16,17 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename T >
|
||||
concept has_equals_traits //
|
||||
= requires(const T& v) { equals_traits<T>{}(v, v); };
|
||||
= requires(const T& v) { equals_traits<std::remove_cv_t<T>>{}(v, v); };
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
requires requires(const T& v) {
|
||||
{ v == v } -> std::convertible_to<bool>;
|
||||
} && (!class_kind<T> || type_list_arity_v<typename class_traits<T>::argument_types> == 0)
|
||||
requires(!std::is_class_v<T>) && requires(T v) {
|
||||
{ v == v } -> std::convertible_to<bool>;
|
||||
}
|
||||
struct equals_traits<T> {
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
bool operator()(T l, T r) const {
|
||||
META_HPP_DETAIL_IGNORE_COMPARISON_WARNINGS_PUSH()
|
||||
return l == r;
|
||||
META_HPP_DETAIL_IGNORE_COMPARISON_WARNINGS_POP()
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename T >
|
||||
concept has_index_traits //
|
||||
= requires(const T& v, std::size_t i) { index_traits<T>{}(v, i); };
|
||||
= requires(const T& v, std::size_t i) { index_traits<std::remove_cv_t<T>>{}(v, i); };
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
requires has_copy_traits<T>
|
||||
requires has_copy_traits<T> && (!std::is_function_v<T>)
|
||||
struct index_traits<T*> {
|
||||
uvalue operator()(T* v, std::size_t i) const {
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
|
||||
@@ -16,17 +16,17 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename T >
|
||||
concept has_less_traits //
|
||||
= requires(const T& v) { less_traits<T>{}(v, v); };
|
||||
= requires(const T& v) { less_traits<std::remove_cv_t<T>>{}(v, v); };
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename T >
|
||||
requires requires(const T& v) {
|
||||
{ v < v } -> std::convertible_to<bool>;
|
||||
} && (!class_kind<T> || type_list_arity_v<typename class_traits<T>::argument_types> == 0)
|
||||
requires(!std::is_class_v<T>) && requires(T v) {
|
||||
{ v < v } -> std::convertible_to<bool>;
|
||||
}
|
||||
struct less_traits<T> {
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
bool operator()(T l, T r) const {
|
||||
META_HPP_DETAIL_IGNORE_COMPARISON_WARNINGS_PUSH()
|
||||
return l < r;
|
||||
META_HPP_DETAIL_IGNORE_COMPARISON_WARNINGS_POP()
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename T >
|
||||
concept has_unmap_traits //
|
||||
= requires(const T& v) { unmap_traits<T>{}(v); };
|
||||
= requires(const T& v) { unmap_traits<std::remove_cv_t<T>>{}(v); };
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
|
||||
Reference in New Issue
Block a user