mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 11:40:35 +07:00
extract *_family concepts to the main namespace
This commit is contained in:
@@ -61,18 +61,15 @@ namespace meta_hpp
|
||||
class uinst;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template < typename T >
|
||||
concept uvalue_family //
|
||||
= std::is_same_v<T, uarg_base> //
|
||||
|| std::is_same_v<T, uarg> //
|
||||
|| std::is_same_v<T, uinst_base> //
|
||||
|| std::is_same_v<T, uinst> //
|
||||
|| std::is_same_v<T, uerror> //
|
||||
|| std::is_same_v<T, uresult> //
|
||||
|| std::is_same_v<T, uvalue>; //
|
||||
}
|
||||
template < typename T >
|
||||
concept uvalue_family //
|
||||
= std::is_same_v<T, uerror> //
|
||||
|| std::is_same_v<T, uresult> //
|
||||
|| std::is_same_v<T, uvalue> //
|
||||
|| std::is_same_v<T, detail::uarg_base> //
|
||||
|| std::is_same_v<T, detail::uarg> //
|
||||
|| std::is_same_v<T, detail::uinst_base> //
|
||||
|| std::is_same_v<T, detail::uinst>; //
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
@@ -110,20 +107,17 @@ namespace meta_hpp
|
||||
using variable_state_ptr = intrusive_ptr<variable_state>;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template < typename T >
|
||||
concept state_family //
|
||||
= std::is_same_v<T, argument> //
|
||||
|| std::is_same_v<T, constructor> //
|
||||
|| std::is_same_v<T, destructor> //
|
||||
|| std::is_same_v<T, evalue> //
|
||||
|| std::is_same_v<T, function> //
|
||||
|| std::is_same_v<T, member> //
|
||||
|| std::is_same_v<T, method> //
|
||||
|| std::is_same_v<T, scope> //
|
||||
|| std::is_same_v<T, variable>; //
|
||||
}
|
||||
template < typename T >
|
||||
concept state_family //
|
||||
= std::is_same_v<T, argument> //
|
||||
|| std::is_same_v<T, constructor> //
|
||||
|| std::is_same_v<T, destructor> //
|
||||
|| std::is_same_v<T, evalue> //
|
||||
|| std::is_same_v<T, function> //
|
||||
|| std::is_same_v<T, member> //
|
||||
|| std::is_same_v<T, method> //
|
||||
|| std::is_same_v<T, scope> //
|
||||
|| std::is_same_v<T, variable>; //
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
@@ -161,25 +155,22 @@ namespace meta_hpp
|
||||
struct void_type_data;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template < typename T >
|
||||
concept type_family //
|
||||
= std::is_same_v<T, any_type> //
|
||||
|| std::is_same_v<T, array_type> //
|
||||
|| std::is_same_v<T, class_type> //
|
||||
|| std::is_same_v<T, constructor_type> //
|
||||
|| std::is_same_v<T, destructor_type> //
|
||||
|| std::is_same_v<T, enum_type> //
|
||||
|| std::is_same_v<T, function_type> //
|
||||
|| std::is_same_v<T, member_type> //
|
||||
|| std::is_same_v<T, method_type> //
|
||||
|| std::is_same_v<T, nullptr_type> //
|
||||
|| std::is_same_v<T, number_type> //
|
||||
|| std::is_same_v<T, pointer_type> //
|
||||
|| std::is_same_v<T, reference_type> //
|
||||
|| std::is_same_v<T, void_type>; //
|
||||
}
|
||||
template < typename T >
|
||||
concept type_family //
|
||||
= std::is_same_v<T, any_type> //
|
||||
|| std::is_same_v<T, array_type> //
|
||||
|| std::is_same_v<T, class_type> //
|
||||
|| std::is_same_v<T, constructor_type> //
|
||||
|| std::is_same_v<T, destructor_type> //
|
||||
|| std::is_same_v<T, enum_type> //
|
||||
|| std::is_same_v<T, function_type> //
|
||||
|| std::is_same_v<T, member_type> //
|
||||
|| std::is_same_v<T, method_type> //
|
||||
|| std::is_same_v<T, nullptr_type> //
|
||||
|| std::is_same_v<T, number_type> //
|
||||
|| std::is_same_v<T, pointer_type> //
|
||||
|| std::is_same_v<T, reference_type> //
|
||||
|| std::is_same_v<T, void_type>; //
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
@@ -194,20 +185,17 @@ namespace meta_hpp
|
||||
class scope_index;
|
||||
class variable_index;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template < typename T >
|
||||
concept index_family //
|
||||
= std::is_same_v<T, argument_index> //
|
||||
|| std::is_same_v<T, constructor_index> //
|
||||
|| std::is_same_v<T, destructor_index> //
|
||||
|| std::is_same_v<T, evalue_index> //
|
||||
|| std::is_same_v<T, function_index> //
|
||||
|| std::is_same_v<T, member_index> //
|
||||
|| std::is_same_v<T, method_index> //
|
||||
|| std::is_same_v<T, scope_index> //
|
||||
|| std::is_same_v<T, variable_index>; //
|
||||
}
|
||||
template < typename T >
|
||||
concept index_family //
|
||||
= std::is_same_v<T, argument_index> //
|
||||
|| std::is_same_v<T, constructor_index> //
|
||||
|| std::is_same_v<T, destructor_index> //
|
||||
|| std::is_same_v<T, evalue_index> //
|
||||
|| std::is_same_v<T, function_index> //
|
||||
|| std::is_same_v<T, member_index> //
|
||||
|| std::is_same_v<T, method_index> //
|
||||
|| std::is_same_v<T, scope_index> //
|
||||
|| std::is_same_v<T, variable_index>; //
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "meta_registry.hpp"
|
||||
#include "meta_states.hpp"
|
||||
#include "meta_types.hpp"
|
||||
#include "meta_uvalue.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
@@ -82,7 +81,7 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
class type_bind_base {
|
||||
public:
|
||||
explicit type_bind_base(const Type& type, metadata_map metadata)
|
||||
@@ -107,7 +106,7 @@ namespace meta_hpp
|
||||
detail::type_registry::locker locker_;
|
||||
};
|
||||
|
||||
template < detail::state_family State >
|
||||
template < state_family State >
|
||||
class state_bind_base {
|
||||
public:
|
||||
explicit state_bind_base(const State& state, metadata_map metadata)
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace meta_hpp
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
template < detail::index_family Index >
|
||||
template < index_family Index >
|
||||
void swap(Index& l, Index& r) noexcept {
|
||||
l.swap(r);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ namespace meta_hpp
|
||||
|
||||
namespace std
|
||||
{
|
||||
template < meta_hpp::detail::index_family Index >
|
||||
template < meta_hpp::index_family Index >
|
||||
struct hash<Index> {
|
||||
size_t operator()(const Index& index) const noexcept {
|
||||
return index.get_hash();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::type_family Type = any_type, typename F >
|
||||
template < type_family Type = any_type, typename F >
|
||||
void for_each_type(F&& f) {
|
||||
using namespace detail;
|
||||
type_registry& registry = type_registry::instance();
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::state_family State >
|
||||
template < state_family State >
|
||||
class state_base {
|
||||
using state_ptr = typename detail::state_traits<State>::state_ptr;
|
||||
friend state_ptr detail::state_access<State>(const State&);
|
||||
@@ -430,7 +430,7 @@ namespace meta_hpp
|
||||
|
||||
namespace std
|
||||
{
|
||||
template < meta_hpp::detail::state_family State >
|
||||
template < meta_hpp::state_family State >
|
||||
struct hash<State> {
|
||||
size_t operator()(const State& state) const noexcept {
|
||||
return state.is_valid() ? state.get_index().get_hash() : 0;
|
||||
@@ -440,12 +440,12 @@ namespace std
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::state_family State >
|
||||
template < state_family State >
|
||||
[[nodiscard]] bool operator==(const State& l, const State& r) noexcept {
|
||||
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_index() == r.get_index());
|
||||
}
|
||||
|
||||
template < detail::state_family State >
|
||||
template < state_family State >
|
||||
[[nodiscard]] std::strong_ordering operator<=>(const State& l, const State& r) noexcept {
|
||||
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
|
||||
return cmp;
|
||||
@@ -456,12 +456,12 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::state_family State >
|
||||
template < state_family State >
|
||||
[[nodiscard]] bool operator==(const State& l, const typename State::index_type& r) noexcept {
|
||||
return l.is_valid() && l.get_index() == r;
|
||||
}
|
||||
|
||||
template < detail::state_family State >
|
||||
template < state_family State >
|
||||
[[nodiscard]] std::strong_ordering operator<=>(const State& l, const typename State::index_type& r) noexcept {
|
||||
return l.is_valid() ? l.get_index() <=> r : std::strong_ordering::less;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace meta_hpp
|
||||
[[nodiscard]] std::strong_ordering operator<=>(const type_id& other) const = default;
|
||||
|
||||
private:
|
||||
template < detail::type_family T >
|
||||
template < type_family T >
|
||||
friend class type_base;
|
||||
|
||||
explicit type_id(const detail::type_data_base* data)
|
||||
@@ -95,7 +95,7 @@ namespace std
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
class type_base {
|
||||
using data_ptr = typename detail::type_traits<Type>::data_ptr;
|
||||
friend data_ptr detail::type_access<Type>(const Type&);
|
||||
@@ -147,14 +147,14 @@ namespace meta_hpp
|
||||
public:
|
||||
using type_base<any_type>::type_base;
|
||||
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
any_type(const Type& other) noexcept;
|
||||
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
[[nodiscard]] bool is() const noexcept;
|
||||
[[nodiscard]] bool is(type_kind kind) const noexcept;
|
||||
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
[[nodiscard]] Type as() const noexcept;
|
||||
|
||||
[[nodiscard]] bool is_array() const noexcept;
|
||||
@@ -423,7 +423,7 @@ namespace meta_hpp
|
||||
|
||||
namespace std
|
||||
{
|
||||
template < meta_hpp::detail::type_family Type >
|
||||
template < meta_hpp::type_family Type >
|
||||
struct hash<Type> {
|
||||
size_t operator()(const Type& type) const noexcept {
|
||||
return type.is_valid() ? type.get_id().get_hash() : 0;
|
||||
@@ -433,12 +433,12 @@ namespace std
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::type_family TypeL, detail::type_family TypeR >
|
||||
template < type_family TypeL, type_family TypeR >
|
||||
[[nodiscard]] bool operator==(const TypeL& l, const TypeR& r) noexcept {
|
||||
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_id() == r.get_id());
|
||||
}
|
||||
|
||||
template < detail::type_family TypeL, detail::type_family TypeR >
|
||||
template < type_family TypeL, type_family TypeR >
|
||||
[[nodiscard]] std::strong_ordering operator<=>(const TypeL& l, const TypeR& r) noexcept {
|
||||
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
|
||||
return cmp;
|
||||
@@ -449,12 +449,12 @@ namespace meta_hpp
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
[[nodiscard]] bool operator==(const Type& l, const typename Type::id_type& r) noexcept {
|
||||
return l.is_valid() && l.get_id() == r;
|
||||
}
|
||||
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
[[nodiscard]] std::strong_ordering operator<=>(const Type& l, const typename Type::id_type& r) noexcept {
|
||||
return l.is_valid() ? l.get_id() <=> r : std::strong_ordering::less;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
any_type::any_type(const Type& other) noexcept
|
||||
: any_type{detail::type_access(other)} {}
|
||||
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
bool any_type::is() const noexcept {
|
||||
if constexpr ( std::is_same_v<Type, any_type> ) {
|
||||
return data_ != nullptr;
|
||||
@@ -28,7 +28,7 @@ namespace meta_hpp
|
||||
return data_ != nullptr && data_->kind == kind;
|
||||
}
|
||||
|
||||
template < detail::type_family Type >
|
||||
template < type_family Type >
|
||||
Type any_type::as() const noexcept {
|
||||
if constexpr ( std::is_same_v<Type, any_type> ) {
|
||||
return *this;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace meta_hpp
|
||||
typename T, //
|
||||
typename Tp = std::decay_t<T>, //
|
||||
typename = std::enable_if_t< //
|
||||
!std::is_same_v<Tp, uresult> && //
|
||||
!uvalue_family<Tp> && //
|
||||
!detail::is_in_place_type_v<Tp> && //
|
||||
std::is_copy_constructible_v<Tp>>> //
|
||||
uresult(T&& val);
|
||||
@@ -92,7 +92,7 @@ namespace meta_hpp
|
||||
typename T, //
|
||||
typename Tp = std::decay_t<T>, //
|
||||
typename = std::enable_if_t< //
|
||||
!std::is_same_v<Tp, uresult> && //
|
||||
!uvalue_family<Tp> && //
|
||||
std::is_copy_constructible_v<Tp>>> //
|
||||
uresult& operator=(T&& val);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace meta_hpp
|
||||
typename T, //
|
||||
typename Tp = std::decay_t<T>, //
|
||||
typename = std::enable_if_t< //
|
||||
!std::is_same_v<Tp, uvalue> && //
|
||||
!uvalue_family<Tp> && //
|
||||
!detail::is_in_place_type_v<Tp> && //
|
||||
std::is_copy_constructible_v<Tp>>> //
|
||||
uvalue(T&& val);
|
||||
@@ -34,7 +34,7 @@ namespace meta_hpp
|
||||
typename T, //
|
||||
typename Tp = std::decay_t<T>, //
|
||||
typename = std::enable_if_t< //
|
||||
!std::is_same_v<Tp, uvalue> && //
|
||||
!uvalue_family<Tp> && //
|
||||
std::is_copy_constructible_v<Tp>>> //
|
||||
uvalue& operator=(T&& val);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user