type bitflag aliases

This commit is contained in:
BlackMATov
2022-02-07 23:51:36 +07:00
parent c80e0c44b6
commit f1d9b11b1b
23 changed files with 99 additions and 67 deletions

View File

@@ -16,6 +16,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(array_flags)
using array_bitflags = bitflags<array_flags>;
}
namespace meta_hpp::detail
@@ -26,8 +27,8 @@ namespace meta_hpp::detail
using data_type = std::remove_extent_t<Array>;
[[nodiscard]] static constexpr bitflags<array_flags> make_flags() noexcept {
bitflags<array_flags> flags;
[[nodiscard]] static constexpr array_bitflags make_flags() noexcept {
array_bitflags flags{};
if constexpr ( std::is_bounded_array_v<Array> ) {
flags.set(array_flags::is_bounded);

View File

@@ -19,6 +19,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(class_flags)
using class_bitflags = bitflags<class_flags>;
}
namespace meta_hpp::detail
@@ -31,7 +32,7 @@ namespace meta_hpp::detail
using argument_types = type_list<>;
[[nodiscard]] static constexpr bitflags<class_flags> make_flags() noexcept {
[[nodiscard]] static constexpr class_bitflags make_flags() noexcept {
return {};
}
};
@@ -42,7 +43,7 @@ namespace meta_hpp::detail
using argument_types = type_list<Args...>;
[[nodiscard]] static constexpr bitflags<class_flags> make_flags() noexcept {
[[nodiscard]] static constexpr class_bitflags make_flags() noexcept {
return class_flags::is_template_instantiation;
}
};
@@ -52,8 +53,8 @@ namespace meta_hpp::detail
struct class_traits : impl::class_traits_base<Class> {
static constexpr std::size_t size{sizeof(Class)};
[[nodiscard]] static constexpr bitflags<class_flags> make_flags() noexcept {
bitflags<class_flags> flags;
[[nodiscard]] static constexpr class_bitflags make_flags() noexcept {
class_bitflags flags{};
if constexpr ( std::is_empty_v<Class> ) {
flags.set(class_flags::is_empty);

View File

@@ -15,6 +15,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(ctor_flags)
using ctor_bitflags = bitflags<ctor_flags>;
}
namespace meta_hpp::detail
@@ -26,8 +27,8 @@ namespace meta_hpp::detail
using class_type = Class;
using argument_types = type_list<Args...>;
[[nodiscard]] static constexpr bitflags<ctor_flags> make_flags() noexcept {
bitflags<ctor_flags> flags;
[[nodiscard]] static constexpr ctor_bitflags make_flags() noexcept {
ctor_bitflags flags{};
if constexpr ( std::is_nothrow_constructible_v<Class, Args...> ) {
flags.set(ctor_flags::is_noexcept);

View File

@@ -15,6 +15,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(dtor_flags)
using dtor_bitflags = bitflags<dtor_flags>;
}
namespace meta_hpp::detail
@@ -23,8 +24,8 @@ namespace meta_hpp::detail
struct dtor_traits {
using class_type = Class;
[[nodiscard]] static constexpr bitflags<dtor_flags> make_flags() noexcept {
bitflags<dtor_flags> flags;
[[nodiscard]] static constexpr dtor_bitflags make_flags() noexcept {
dtor_bitflags flags{};
if constexpr ( std::is_nothrow_destructible_v<Class> ) {
flags.set(dtor_flags::is_noexcept);

View File

@@ -15,6 +15,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(enum_flags)
using enum_bitflags = bitflags<enum_flags>;
}
namespace meta_hpp::detail
@@ -23,8 +24,8 @@ namespace meta_hpp::detail
struct enum_traits {
using underlying_type = std::underlying_type_t<Enum>;
[[nodiscard]] static constexpr bitflags<enum_flags> make_flags() noexcept {
bitflags<enum_flags> flags;
[[nodiscard]] static constexpr enum_bitflags make_flags() noexcept {
enum_bitflags flags{};
if constexpr ( !std::is_convertible_v<Enum, underlying_type> ) {
flags.set(enum_flags::is_scoped);

View File

@@ -15,6 +15,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(function_flags)
using function_bitflags = bitflags<function_flags>;
}
namespace meta_hpp::detail
@@ -29,14 +30,14 @@ namespace meta_hpp::detail
using return_type = R;
using argument_types = type_list<Args...>;
[[nodiscard]] static constexpr bitflags<function_flags> make_flags() noexcept {
[[nodiscard]] static constexpr function_bitflags make_flags() noexcept {
return {};
}
};
template < typename R, typename... Args >
struct function_traits<R(*)(Args...) noexcept> : function_traits<R(*)(Args...)> {
[[nodiscard]] static constexpr bitflags<function_flags> make_flags() noexcept {
[[nodiscard]] static constexpr function_bitflags make_flags() noexcept {
return function_flags::is_noexcept;
}
};

View File

@@ -15,6 +15,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(member_flags)
using member_bitflags = bitflags<member_flags>;
}
namespace meta_hpp::detail
@@ -27,8 +28,8 @@ namespace meta_hpp::detail
using class_type = C;
using value_type = V;
[[nodiscard]] static constexpr bitflags<member_flags> make_flags() noexcept {
bitflags<member_flags> flags;
[[nodiscard]] static constexpr member_bitflags make_flags() noexcept {
member_bitflags flags{};
if constexpr ( std::is_const_v<value_type> ) {
flags.set(member_flags::is_readonly);

View File

@@ -18,6 +18,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(method_flags)
using method_bitflags = bitflags<method_flags>;
}
namespace meta_hpp::detail
@@ -34,7 +35,7 @@ namespace meta_hpp::detail
using qualified_type = C;
using argument_types = type_list<Args...>;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return {};
}
};
@@ -43,7 +44,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) const> : method_traits<R(C::*)(Args...)> {
using qualified_type = const C;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_const;
}
};
@@ -52,7 +53,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) noexcept> : method_traits<R(C::*)(Args...)> {
using qualified_type = C;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_noexcept;
}
};
@@ -61,7 +62,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) const noexcept> : method_traits<R(C::*)(Args...)> {
using qualified_type = const C;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_const | method_flags::is_noexcept;
}
};
@@ -70,7 +71,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) &> : method_traits<R(C::*)(Args...)> {
using qualified_type = C&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_lvalue_qualified;
}
};
@@ -79,7 +80,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) & noexcept> : method_traits<R(C::*)(Args...)> {
using qualified_type = C&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_noexcept | method_flags::is_lvalue_qualified;
}
};
@@ -88,7 +89,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) const &> : method_traits<R(C::*)(Args...)> {
using qualified_type = const C&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_const | method_flags::is_lvalue_qualified;
}
};
@@ -97,7 +98,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) const & noexcept> : method_traits<R(C::*)(Args...)> {
using qualified_type = const C&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_const | method_flags::is_noexcept | method_flags::is_lvalue_qualified;
}
};
@@ -106,7 +107,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) &&> : method_traits<R(C::*)(Args...)> {
using qualified_type = C&&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_rvalue_qualified;
}
};
@@ -115,7 +116,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) && noexcept> : method_traits<R(C::*)(Args...)> {
using qualified_type = C&&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_noexcept | method_flags::is_rvalue_qualified;
}
};
@@ -124,7 +125,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) const &&> : method_traits<R(C::*)(Args...)> {
using qualified_type = const C&&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_const | method_flags::is_rvalue_qualified;
}
};
@@ -133,7 +134,7 @@ namespace meta_hpp::detail
struct method_traits<R(C::*)(Args...) const && noexcept> : method_traits<R(C::*)(Args...)> {
using qualified_type = const C&&;
[[nodiscard]] static constexpr bitflags<method_flags> make_flags() noexcept {
[[nodiscard]] static constexpr method_bitflags make_flags() noexcept {
return method_flags::is_const | method_flags::is_noexcept | method_flags::is_rvalue_qualified;
}
};

View File

@@ -18,6 +18,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(number_flags)
using number_bitflags = bitflags<number_flags>;
}
namespace meta_hpp::detail
@@ -26,8 +27,8 @@ namespace meta_hpp::detail
struct number_traits {
static constexpr std::size_t size{sizeof(Number)};
[[nodiscard]] static constexpr bitflags<number_flags> make_flags() noexcept {
bitflags<number_flags> flags;
[[nodiscard]] static constexpr number_bitflags make_flags() noexcept {
number_bitflags flags{};
if constexpr ( std::is_signed_v<Number> ) {
flags.set(number_flags::is_signed);

View File

@@ -15,6 +15,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(pointer_flags)
using pointer_bitflags = bitflags<pointer_flags>;
}
namespace meta_hpp::detail
@@ -23,8 +24,8 @@ namespace meta_hpp::detail
struct pointer_traits {
using data_type = std::remove_pointer_t<Pointer>;
[[nodiscard]] static constexpr bitflags<pointer_flags> make_flags() noexcept {
bitflags<pointer_flags> flags;
[[nodiscard]] static constexpr pointer_bitflags make_flags() noexcept {
pointer_bitflags flags{};
if constexpr ( std::is_const_v<data_type> ) {
flags.set(pointer_flags::is_readonly);

View File

@@ -17,6 +17,7 @@ namespace meta_hpp::detail
};
ENUM_HPP_OPERATORS_DECL(reference_flags)
using reference_bitflags = bitflags<reference_flags>;
}
namespace meta_hpp::detail
@@ -25,8 +26,8 @@ namespace meta_hpp::detail
struct reference_traits {
using data_type = std::remove_reference_t<Reference>;
[[nodiscard]] static constexpr bitflags<reference_flags> make_flags() noexcept {
bitflags<reference_flags> flags;
[[nodiscard]] static constexpr reference_bitflags make_flags() noexcept {
reference_bitflags flags{};
if constexpr ( std::is_const_v<data_type> ) {
flags.set(reference_flags::is_readonly);

View File

@@ -25,16 +25,37 @@
namespace meta_hpp
{
using array_flags = detail::array_flags;
using array_bitflags = detail::array_bitflags;
using class_flags = detail::class_flags;
using class_bitflags = detail::class_bitflags;
using ctor_flags = detail::ctor_flags;
using ctor_bitflags = detail::ctor_bitflags;
using dtor_flags = detail::dtor_flags;
using dtor_bitflags = detail::dtor_bitflags;
using enum_flags = detail::enum_flags;
using enum_bitflags = detail::enum_bitflags;
using function_flags = detail::function_flags;
using function_bitflags = detail::function_bitflags;
using member_flags = detail::member_flags;
using member_bitflags = detail::member_bitflags;
using method_flags = detail::method_flags;
using method_bitflags = detail::method_bitflags;
using number_flags = detail::number_flags;
using number_bitflags = detail::number_bitflags;
using pointer_flags = detail::pointer_flags;
using pointer_bitflags = detail::pointer_bitflags;
using reference_flags = detail::reference_flags;
using reference_bitflags = detail::reference_bitflags;
}
namespace meta_hpp
@@ -104,7 +125,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<array_flags> get_flags() const noexcept;
[[nodiscard]] array_bitflags get_flags() const noexcept;
[[nodiscard]] std::size_t get_extent() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept;
@@ -122,7 +143,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<class_flags> get_flags() const noexcept;
[[nodiscard]] class_bitflags get_flags() const noexcept;
[[nodiscard]] std::size_t get_size() const noexcept;
@@ -188,7 +209,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<ctor_flags> get_flags() const noexcept;
[[nodiscard]] ctor_bitflags get_flags() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] any_type get_class_type() const noexcept;
@@ -208,7 +229,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<dtor_flags> get_flags() const noexcept;
[[nodiscard]] dtor_bitflags get_flags() const noexcept;
[[nodiscard]] any_type get_class_type() const noexcept;
private:
@@ -225,7 +246,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<enum_flags> get_flags() const noexcept;
[[nodiscard]] enum_bitflags get_flags() const noexcept;
[[nodiscard]] number_type get_underlying_type() const noexcept;
@@ -250,7 +271,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<function_flags> get_flags() const noexcept;
[[nodiscard]] function_bitflags get_flags() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] any_type get_return_type() const noexcept;
@@ -270,7 +291,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<member_flags> get_flags() const noexcept;
[[nodiscard]] member_bitflags get_flags() const noexcept;
[[nodiscard]] class_type get_owner_type() const noexcept;
[[nodiscard]] any_type get_value_type() const noexcept;
@@ -288,7 +309,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<method_flags> get_flags() const noexcept;
[[nodiscard]] method_bitflags get_flags() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] class_type get_owner_type() const noexcept;
@@ -323,7 +344,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<number_flags> get_flags() const noexcept;
[[nodiscard]] number_bitflags get_flags() const noexcept;
[[nodiscard]] std::size_t get_size() const noexcept;
private:
@@ -340,7 +361,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<pointer_flags> get_flags() const noexcept;
[[nodiscard]] pointer_bitflags get_flags() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept;
private:
@@ -357,7 +378,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] bitflags<reference_flags> get_flags() const noexcept;
[[nodiscard]] reference_bitflags get_flags() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept;
private:
@@ -426,7 +447,7 @@ namespace meta_hpp::detail
};
struct array_type_data final : type_data_base {
const bitflags<array_flags> flags;
const array_bitflags flags;
const std::size_t extent;
const any_type data_type;
@@ -435,7 +456,7 @@ namespace meta_hpp::detail
};
struct class_type_data final : type_data_base {
const bitflags<class_flags> flags;
const class_bitflags flags;
const std::size_t size;
const std::vector<any_type> argument_types;
@@ -460,7 +481,7 @@ namespace meta_hpp::detail
};
struct ctor_type_data final : type_data_base {
const bitflags<ctor_flags> flags;
const ctor_bitflags flags;
const any_type class_type;
const std::vector<any_type> argument_types;
@@ -469,7 +490,7 @@ namespace meta_hpp::detail
};
struct dtor_type_data final : type_data_base {
const bitflags<dtor_flags> flags;
const dtor_bitflags flags;
const any_type class_type;
template < class_kind Class >
@@ -477,7 +498,7 @@ namespace meta_hpp::detail
};
struct enum_type_data final : type_data_base {
const bitflags<enum_flags> flags;
const enum_bitflags flags;
const number_type underlying_type;
evalue_map evalues;
@@ -487,7 +508,7 @@ namespace meta_hpp::detail
};
struct function_type_data final : type_data_base {
const bitflags<function_flags> flags;
const function_bitflags flags;
const any_type return_type;
const std::vector<any_type> argument_types;
@@ -496,7 +517,7 @@ namespace meta_hpp::detail
};
struct member_type_data final : type_data_base {
const bitflags<member_flags> flags;
const member_bitflags flags;
const class_type owner_type;
const any_type value_type;
@@ -505,7 +526,7 @@ namespace meta_hpp::detail
};
struct method_type_data final : type_data_base {
const bitflags<method_flags> flags;
const method_bitflags flags;
const class_type owner_type;
const any_type return_type;
const std::vector<any_type> argument_types;
@@ -520,7 +541,7 @@ namespace meta_hpp::detail
};
struct number_type_data final : type_data_base {
const bitflags<number_flags> flags;
const number_bitflags flags;
const std::size_t size;
template < number_kind Number >
@@ -528,7 +549,7 @@ namespace meta_hpp::detail
};
struct pointer_type_data final : type_data_base {
const bitflags<pointer_flags> flags;
const pointer_bitflags flags;
const any_type data_type;
template < pointer_kind Pointer >
@@ -536,7 +557,7 @@ namespace meta_hpp::detail
};
struct reference_type_data final : type_data_base {
const bitflags<reference_flags> flags;
const reference_bitflags flags;
const any_type data_type;
template < reference_kind Reference >

View File

@@ -43,7 +43,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<array_flags> array_type::get_flags() const noexcept {
inline array_bitflags array_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -49,7 +49,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<class_flags> class_type::get_flags() const noexcept {
inline class_bitflags class_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -43,7 +43,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<ctor_flags> ctor_type::get_flags() const noexcept {
inline ctor_bitflags ctor_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -42,7 +42,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<dtor_flags> dtor_type::get_flags() const noexcept {
inline dtor_bitflags dtor_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -45,7 +45,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<enum_flags> enum_type::get_flags() const noexcept {
inline enum_bitflags enum_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -43,7 +43,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<function_flags> function_type::get_flags() const noexcept {
inline function_bitflags function_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -43,7 +43,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<member_flags> member_type::get_flags() const noexcept {
inline member_bitflags member_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -44,7 +44,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<method_flags> method_type::get_flags() const noexcept {
inline method_bitflags method_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -41,7 +41,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<number_flags> number_type::get_flags() const noexcept {
inline number_bitflags number_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -42,7 +42,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<pointer_flags> pointer_type::get_flags() const noexcept {
inline pointer_bitflags pointer_type::get_flags() const noexcept {
return data_->flags;
}

View File

@@ -42,7 +42,7 @@ namespace meta_hpp
return data_->id;
}
inline bitflags<reference_flags> reference_type::get_flags() const noexcept {
inline reference_bitflags reference_type::get_flags() const noexcept {
return data_->flags;
}