mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 11:40:35 +07:00
add value ctor copy constraints
This commit is contained in:
@@ -93,7 +93,6 @@ namespace meta_hpp::detail
|
||||
public:
|
||||
noncopyable(noncopyable&&) = delete;
|
||||
noncopyable(const noncopyable&) = delete;
|
||||
|
||||
noncopyable& operator=(noncopyable&&) = delete;
|
||||
noncopyable& operator=(const noncopyable&) = delete;
|
||||
};
|
||||
@@ -115,10 +114,12 @@ namespace meta_hpp
|
||||
|
||||
~value() = default;
|
||||
|
||||
template < detail::decay_non_uvalue_kind T >
|
||||
template < detail::decay_non_uvalue_kind T, typename Tp = std::decay_t<T> >
|
||||
requires detail::stdex::copy_constructible<Tp>
|
||||
explicit value(T&& val);
|
||||
|
||||
template < detail::decay_non_uvalue_kind T >
|
||||
template < detail::decay_non_uvalue_kind T, typename Tp = std::decay_t<T> >
|
||||
requires detail::stdex::copy_constructible<Tp>
|
||||
value& operator=(T&& val);
|
||||
|
||||
void swap(value& other) noexcept;
|
||||
|
||||
@@ -154,12 +154,14 @@ namespace meta_hpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
template < detail::decay_non_uvalue_kind T >
|
||||
template < detail::decay_non_uvalue_kind T, typename Tp >
|
||||
requires detail::stdex::copy_constructible<Tp>
|
||||
value::value(T&& val)
|
||||
: raw_{std::forward<T>(val)}
|
||||
, traits_{traits::get<std::decay_t<T>>()} {}
|
||||
|
||||
template < detail::decay_non_uvalue_kind T >
|
||||
template < detail::decay_non_uvalue_kind T, typename Tp >
|
||||
requires detail::stdex::copy_constructible<Tp>
|
||||
value& value::operator=(T&& val) {
|
||||
value temp{std::forward<T>(val)};
|
||||
swap(temp);
|
||||
@@ -241,14 +243,14 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < typename T >
|
||||
template < detail::has_value_less_traits T >
|
||||
[[nodiscard]] bool operator<(const value& l, const T& r) {
|
||||
const any_type& r_type = resolve_type<T>();
|
||||
return (l.get_type() < r_type)
|
||||
|| (l.get_type() == r_type && std::less<>{}(l.cast<T>(), r));
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
template < detail::has_value_less_traits T >
|
||||
[[nodiscard]] bool operator<(const T& l, const value& r) {
|
||||
const any_type& l_type = resolve_type<T>();
|
||||
return (l_type < r.get_type())
|
||||
@@ -263,13 +265,13 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < typename T >
|
||||
template < detail::has_value_equals_traits T >
|
||||
[[nodiscard]] bool operator==(const value& l, const T& r) {
|
||||
return l.get_type() == resolve_type<T>()
|
||||
&& std::equal_to<>{}(l.cast<T>(), r);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
template < detail::has_value_equals_traits T >
|
||||
[[nodiscard]] bool operator==(const T& l, const value& r) {
|
||||
return resolve_type<T>() == r.get_type()
|
||||
&& std::equal_to<>{}(l, r.cast<T>());
|
||||
|
||||
Reference in New Issue
Block a user