diff --git a/headers/meta.hpp/meta_all.hpp b/headers/meta.hpp/meta_all.hpp index f2adc16..1d7fa5c 100644 --- a/headers/meta.hpp/meta_all.hpp +++ b/headers/meta.hpp/meta_all.hpp @@ -6,4 +6,19 @@ #pragma once -#include "meta_fwd.hpp" +#include "meta_base.hpp" + +#include "meta_kinds.hpp" + +#include "meta_traits.hpp" +#include "meta_traits/array_traits.hpp" +#include "meta_traits/class_traits.hpp" +#include "meta_traits/ctor_traits.hpp" +#include "meta_traits/enum_traits.hpp" +#include "meta_traits/function_traits.hpp" +#include "meta_traits/member_traits.hpp" +#include "meta_traits/method_traits.hpp" +#include "meta_traits/number_traits.hpp" +#include "meta_traits/pointer_traits.hpp" +#include "meta_traits/reference_traits.hpp" +#include "meta_traits/void_traits.hpp" diff --git a/headers/meta.hpp/meta_base.hpp b/headers/meta.hpp/meta_base.hpp new file mode 100644 index 0000000..fbff63e --- /dev/null +++ b/headers/meta.hpp/meta_base.hpp @@ -0,0 +1,182 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace meta_hpp +{ + template < typename Enum > + using bitflags = enum_hpp::bitflags::bitflags; +} + +namespace meta_hpp +{ + template < typename... Types > + struct type_list {}; + + template < std::size_t Index, typename TypeList > + struct type_list_at; + + template < std::size_t Index, typename... Types > + struct type_list_at> { + using type = std::tuple_element_t>; + }; + + template < std::size_t Index, typename TypeList > + using type_list_at_t = typename type_list_at::type; +} + +namespace meta_hpp +{ + template < typename Signature > + constexpr auto select(Signature* func) noexcept -> Signature* { + return func; + } + + template < typename Signature, typename Class > + constexpr auto select(Signature Class::*func) -> decltype(func) { + return func; + } +} + +namespace meta_hpp +{ + class value; + + namespace detail + { + class arg_base; + class arg; + + class inst_base; + class inst; + } +} + +namespace meta_hpp +{ + class ctor; + class evalue; + class function; + class member; + class method; + class scope; + class variable; + + namespace detail + { + struct ctor_state; + struct evalue_state; + struct function_state; + struct member_state; + struct method_state; + struct scope_state; + struct variable_state; + + using ctor_state_ptr = std::shared_ptr; + using evalue_state_ptr = std::shared_ptr; + using function_state_ptr = std::shared_ptr; + using member_state_ptr = std::shared_ptr; + using method_state_ptr = std::shared_ptr; + using scope_state_ptr = std::shared_ptr; + using variable_state_ptr = std::shared_ptr; + } +} + +namespace meta_hpp +{ + class any_type; + class array_type; + class class_type; + class ctor_type; + class enum_type; + class function_type; + class member_type; + class method_type; + class number_type; + class pointer_type; + class reference_type; + class void_type; + + namespace detail + { + struct type_data_base; + struct array_type_data; + struct class_type_data; + struct ctor_type_data; + struct enum_type_data; + struct function_type_data; + struct member_type_data; + struct method_type_data; + struct number_type_data; + struct pointer_type_data; + struct reference_type_data; + struct void_type_data; + + using type_data_base_ptr = std::shared_ptr; + using array_type_data_ptr = std::shared_ptr; + using class_type_data_ptr = std::shared_ptr; + using ctor_type_data_ptr = std::shared_ptr; + using enum_type_data_ptr = std::shared_ptr; + using function_type_data_ptr = std::shared_ptr; + using member_type_data_ptr = std::shared_ptr; + using method_type_data_ptr = std::shared_ptr; + using number_type_data_ptr = std::shared_ptr; + using pointer_type_data_ptr = std::shared_ptr; + using reference_type_data_ptr = std::shared_ptr; + using void_type_data_ptr = std::shared_ptr; + } +} + +namespace meta_hpp +{ + struct ctor_index; + struct evalue_index; + struct function_index; + struct member_index; + struct method_index; + struct variable_index; + + using class_set = std::set>; + using class_map = std::map>; + + using enum_set = std::set>; + using enum_map = std::map>; + + using ctor_map = std::map>; + using evalue_map = std::map>; + using function_map = std::map>; + using member_map = std::map>; + using method_map = std::map>; + using variable_map = std::map>; +} diff --git a/headers/meta.hpp/meta_kinds.hpp b/headers/meta.hpp/meta_kinds.hpp new file mode 100644 index 0000000..3aa55fb --- /dev/null +++ b/headers/meta.hpp/meta_kinds.hpp @@ -0,0 +1,154 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "meta_base.hpp" + +namespace meta_hpp +{ + template < typename T > + concept array_kind = std::is_array_v; + + template < typename T > + concept class_kind = std::is_class_v; + + template < typename T > + concept enum_kind = std::is_enum_v; + + template < typename T > + concept function_kind = std::is_pointer_v && std::is_function_v>; + + template < typename T > + concept member_kind = std::is_member_object_pointer_v; + + template < typename T > + concept method_kind = std::is_member_function_pointer_v; + + template < typename T > + concept number_kind = std::is_arithmetic_v; + + template < typename T > + concept pointer_kind = std::is_pointer_v && !std::is_function_v>; + + template < typename T > + concept reference_kind = std::is_reference_v; + + template < typename T > + concept void_kind = std::is_void_v; +} + +namespace meta_hpp +{ + enum class type_kind : std::uint32_t { + array_, + class_, + ctor_, + enum_, + function_, + member_, + method_, + number_, + pointer_, + reference_, + void_, + }; + + template < typename T > + constexpr type_kind make_type_kind() noexcept { + if constexpr ( array_kind ) { return type_kind::array_; } + if constexpr ( class_kind ) { return type_kind::class_; } + if constexpr ( enum_kind ) { return type_kind::enum_; } + if constexpr ( function_kind ) { return type_kind::function_; } + if constexpr ( member_kind ) { return type_kind::member_; } + if constexpr ( method_kind ) { return type_kind::method_; } + if constexpr ( number_kind ) { return type_kind::number_; } + if constexpr ( pointer_kind ) { return type_kind::pointer_; } + if constexpr ( reference_kind ) { return type_kind::reference_; } + if constexpr ( void_kind ) { return type_kind::void_; } + } +} + +namespace meta_hpp::detail +{ + template < type_kind Kind > + struct type_kind_traits; + + template <> + struct type_kind_traits { + using kind_type = array_type; + using kind_type_data = array_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = class_type; + using kind_type_data = class_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = ctor_type; + using kind_type_data = ctor_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = enum_type; + using kind_type_data = enum_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = function_type; + using kind_type_data = function_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = member_type; + using kind_type_data = member_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = method_type; + using kind_type_data = method_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = number_type; + using kind_type_data = number_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = pointer_type; + using kind_type_data = pointer_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = reference_type; + using kind_type_data = reference_type_data; + }; + + template <> + struct type_kind_traits { + using kind_type = void_type; + using kind_type_data = void_type_data; + }; + + template < typename T > + using kind_type = typename type_kind_traits()>::kind_type; + + template < typename T > + using kind_type_data = typename type_kind_traits()>::kind_type_data; + + template < typename T > + using kind_type_data_ptr = std::shared_ptr>; +} diff --git a/headers/meta.hpp/meta_traits.hpp b/headers/meta.hpp/meta_traits.hpp new file mode 100644 index 0000000..37af24b --- /dev/null +++ b/headers/meta.hpp/meta_traits.hpp @@ -0,0 +1,116 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "meta_base.hpp" +#include "meta_kinds.hpp" + +namespace meta_hpp::detail +{ + template < array_kind Array > + struct array_traits; + + template < class_kind T > + struct class_traits; + + template < class_kind Class, typename... Args > + struct ctor_traits; + + template < enum_kind Enum > + struct enum_traits; + + template < function_kind Function > + struct function_traits; + + template < member_kind Member > + struct member_traits; + + template < method_kind Method > + struct method_traits; + + template < number_kind Number > + struct number_traits; + + template < pointer_kind Pointer > + struct pointer_traits; + + template < reference_kind Reference > + struct reference_traits; + + template < void_kind Void > + struct void_traits; +} + +namespace meta_hpp +{ + enum class array_flags : std::uint32_t { + is_bounded = 1 << 0, + is_unbounded = 1 << 1, + }; + + enum class class_flags : std::uint32_t { + is_empty = 1 << 1, + is_final = 1 << 2, + is_abstract = 1 << 3, + is_polymorphic = 1 << 4, + is_template_instantiation = 1 << 5, + }; + + enum class ctor_flags : std::uint32_t { + is_noexcept = 1 << 0, + }; + + enum class enum_flags : std::uint32_t { + }; + + enum class function_flags : std::uint32_t { + is_noexcept = 1 << 0, + }; + + enum class member_flags : std::uint32_t { + }; + + enum class method_flags : std::uint32_t { + is_const = 1 << 0, + is_noexcept = 1 << 1, + is_volatile = 1 << 2, + is_lvalue_qualified = 1 << 3, + is_rvalue_qualified = 1 << 4, + }; + + enum class number_flags : std::uint32_t { + is_signed = 1 << 1, + is_unsigned = 1 << 2, + is_integral = 1 << 3, + is_floating_point = 1 << 4, + }; + + enum class pointer_flags : std::uint32_t { + is_readonly = 1 << 0, + }; + + enum class reference_flags : std::uint32_t { + is_readonly = 1 << 0, + is_lvalue = 1 << 1, + is_rvalue = 1 << 2, + }; + + enum class void_flags : std::uint32_t { + }; + + ENUM_HPP_OPERATORS_DECL(array_flags) + ENUM_HPP_OPERATORS_DECL(class_flags) + ENUM_HPP_OPERATORS_DECL(ctor_flags) + ENUM_HPP_OPERATORS_DECL(enum_flags) + ENUM_HPP_OPERATORS_DECL(function_flags) + ENUM_HPP_OPERATORS_DECL(member_flags) + ENUM_HPP_OPERATORS_DECL(method_flags) + ENUM_HPP_OPERATORS_DECL(number_flags) + ENUM_HPP_OPERATORS_DECL(pointer_flags) + ENUM_HPP_OPERATORS_DECL(reference_flags) + ENUM_HPP_OPERATORS_DECL(void_flags) +} diff --git a/headers/meta.hpp/meta_traits/array_traits.hpp b/headers/meta.hpp/meta_traits/array_traits.hpp new file mode 100644 index 0000000..e979661 --- /dev/null +++ b/headers/meta.hpp/meta_traits/array_traits.hpp @@ -0,0 +1,27 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < array_kind Array > + struct array_traits { + static constexpr std::size_t extent{std::extent_v}; + + using data_type = std::remove_extent_t; + + static bitflags make_flags() noexcept { + bitflags flags; + if ( std::is_bounded_array_v ) flags.set(array_flags::is_bounded); + if ( std::is_unbounded_array_v ) flags.set(array_flags::is_unbounded); + return flags; + } + }; +} diff --git a/headers/meta.hpp/meta_traits/class_traits.hpp b/headers/meta.hpp/meta_traits/class_traits.hpp new file mode 100644 index 0000000..9b06334 --- /dev/null +++ b/headers/meta.hpp/meta_traits/class_traits.hpp @@ -0,0 +1,60 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + namespace impl + { + template < class_kind T > + struct class_traits_base { + static constexpr std::size_t arity{0}; + + using argument_types = type_list<>; + + static bitflags make_flags() noexcept { + return {}; + } + + static std::vector make_argument_types() { + return {}; + } + }; + + template < template < typename... > typename T, typename... Args > + struct class_traits_base> { + static constexpr std::size_t arity{sizeof...(Args)}; + + using argument_types = type_list; + + static bitflags make_flags() noexcept { + return class_flags::is_template_instantiation; + } + + static std::vector make_argument_types() { + return { resolve_type()... }; + } + }; + } + + template < class_kind T > + struct class_traits : impl::class_traits_base { + static constexpr std::size_t size{sizeof(T)}; + + static bitflags make_flags() noexcept { + bitflags flags; + if constexpr ( std::is_empty_v ) flags.set(class_flags::is_empty); + if constexpr ( std::is_final_v ) flags.set(class_flags::is_final); + if constexpr ( std::is_abstract_v ) flags.set(class_flags::is_abstract); + if constexpr ( std::is_polymorphic_v ) flags.set(class_flags::is_polymorphic); + return flags | impl::class_traits_base::make_flags(); + } + }; +} diff --git a/headers/meta.hpp/meta_traits/ctor_traits.hpp b/headers/meta.hpp/meta_traits/ctor_traits.hpp new file mode 100644 index 0000000..745f1e0 --- /dev/null +++ b/headers/meta.hpp/meta_traits/ctor_traits.hpp @@ -0,0 +1,31 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < class_kind Class, typename... Args > + struct ctor_traits { + static constexpr std::size_t arity{sizeof...(Args)}; + + using class_type = Class; + using argument_types = type_list; + + static bitflags make_flags() noexcept { + bitflags flags; + if constexpr ( std::is_nothrow_constructible_v ) flags.set(ctor_flags::is_noexcept); + return flags; + } + + static std::vector make_argument_types() { + return { resolve_type()... }; + } + }; +} diff --git a/untests/meta_tests.cpp b/headers/meta.hpp/meta_traits/enum_traits.hpp similarity index 54% rename from untests/meta_tests.cpp rename to headers/meta.hpp/meta_traits/enum_traits.hpp index cbb5826..ba77ce3 100644 --- a/untests/meta_tests.cpp +++ b/headers/meta.hpp/meta_traits/enum_traits.hpp @@ -4,11 +4,19 @@ * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#include "meta_tests.hpp" +#pragma once -namespace +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail { -} + template < enum_kind Enum > + struct enum_traits { + using underlying_type = std::underlying_type_t; -TEST_CASE("meta") { + static bitflags make_flags() noexcept { + return {}; + } + }; } diff --git a/headers/meta.hpp/meta_traits/function_traits.hpp b/headers/meta.hpp/meta_traits/function_traits.hpp new file mode 100644 index 0000000..709e6a7 --- /dev/null +++ b/headers/meta.hpp/meta_traits/function_traits.hpp @@ -0,0 +1,39 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < function_kind Function > + struct function_traits; + + template < typename R, typename... Args > + struct function_traits { + static constexpr std::size_t arity{sizeof...(Args)}; + + using return_type = R; + using argument_types = type_list; + + static bitflags make_flags() noexcept { + return {}; + } + + static std::vector make_argument_types() { + return { resolve_type()... }; + } + }; + + template < typename R, typename... Args > + struct function_traits : function_traits { + static bitflags make_flags() noexcept { + return function_flags::is_noexcept; + } + }; +} diff --git a/headers/meta.hpp/meta_traits/member_traits.hpp b/headers/meta.hpp/meta_traits/member_traits.hpp new file mode 100644 index 0000000..0500082 --- /dev/null +++ b/headers/meta.hpp/meta_traits/member_traits.hpp @@ -0,0 +1,26 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < member_kind Member > + struct member_traits; + + template < typename V, typename C > + struct member_traits { + using class_type = C; + using value_type = V; + + static bitflags make_flags() noexcept { + return {}; + } + }; +} diff --git a/headers/meta.hpp/meta_traits/method_traits.hpp b/headers/meta.hpp/meta_traits/method_traits.hpp new file mode 100644 index 0000000..fef9086 --- /dev/null +++ b/headers/meta.hpp/meta_traits/method_traits.hpp @@ -0,0 +1,220 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < method_kind Method > + struct method_traits; + + template < typename R, typename C, typename... Args > + struct method_traits { + static constexpr std::size_t arity{sizeof...(Args)}; + + using class_type = C; + using return_type = R; + using qualified_type = C; + using argument_types = type_list; + + static bitflags make_flags() noexcept { + return {}; + } + + static std::vector make_argument_types() { + return { resolve_type()... }; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C; + static bitflags make_flags() noexcept { + return method_flags::is_const; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C; + static bitflags make_flags() noexcept { + return method_flags::is_noexcept; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C; + static bitflags make_flags() noexcept { + return method_flags::is_const | method_flags::is_noexcept; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&; + static bitflags make_flags() noexcept { + return method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&; + static bitflags make_flags() noexcept { + return method_flags::is_noexcept | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&; + static bitflags make_flags() noexcept { + return method_flags::is_const | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&; + static bitflags make_flags() noexcept { + return method_flags::is_const | method_flags::is_noexcept | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&&; + static bitflags make_flags() noexcept { + return method_flags::is_rvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&&; + static bitflags make_flags() noexcept { + return method_flags::is_noexcept | method_flags::is_rvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&&; + static bitflags make_flags() noexcept { + return method_flags::is_const | method_flags::is_rvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&&; + static bitflags make_flags() noexcept { + return method_flags::is_const | method_flags::is_noexcept | method_flags::is_rvalue_qualified; + } + }; + + // + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C; + static bitflags make_flags() noexcept { + return method_flags::is_volatile; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_const; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_noexcept; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_const | method_flags::is_noexcept; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_noexcept | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_const | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_const | method_flags::is_noexcept | method_flags::is_lvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_rvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = C&&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_noexcept | method_flags::is_rvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_const | method_flags::is_rvalue_qualified; + } + }; + + template < typename R, typename C, typename... Args > + struct method_traits : method_traits { + using qualified_type = const C&&; + static bitflags make_flags() noexcept { + return method_flags::is_volatile | method_flags::is_const | method_flags::is_noexcept | method_flags::is_rvalue_qualified; + } + }; +} diff --git a/headers/meta.hpp/meta_traits/number_traits.hpp b/headers/meta.hpp/meta_traits/number_traits.hpp new file mode 100644 index 0000000..eb69abc --- /dev/null +++ b/headers/meta.hpp/meta_traits/number_traits.hpp @@ -0,0 +1,27 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < number_kind Number > + struct number_traits { + static constexpr std::size_t size{sizeof(Number)}; + + static bitflags make_flags() noexcept { + bitflags flags; + if ( std::is_signed_v ) flags.set(number_flags::is_signed); + if ( std::is_unsigned_v ) flags.set(number_flags::is_unsigned); + if ( std::is_integral_v ) flags.set(number_flags::is_integral); + if ( std::is_floating_point_v ) flags.set(number_flags::is_floating_point); + return flags; + } + }; +} diff --git a/headers/meta.hpp/meta_traits/pointer_traits.hpp b/headers/meta.hpp/meta_traits/pointer_traits.hpp new file mode 100644 index 0000000..5b66ea3 --- /dev/null +++ b/headers/meta.hpp/meta_traits/pointer_traits.hpp @@ -0,0 +1,24 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < pointer_kind Pointer > + struct pointer_traits { + using data_type = std::remove_pointer_t; + + static bitflags make_flags() noexcept { + bitflags flags; + if constexpr ( std::is_const_v ) flags.set(pointer_flags::is_readonly); + return flags; + } + }; +} diff --git a/headers/meta.hpp/meta_traits/reference_traits.hpp b/headers/meta.hpp/meta_traits/reference_traits.hpp new file mode 100644 index 0000000..4eef018 --- /dev/null +++ b/headers/meta.hpp/meta_traits/reference_traits.hpp @@ -0,0 +1,26 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail +{ + template < reference_kind Reference > + struct reference_traits { + using data_type = std::remove_reference_t; + + static bitflags make_flags() noexcept { + bitflags flags; + if constexpr ( std::is_const_v ) flags.set(reference_flags::is_readonly); + if constexpr ( std::is_lvalue_reference_v ) flags.set(reference_flags::is_lvalue); + if constexpr ( std::is_rvalue_reference_v ) flags.set(reference_flags::is_rvalue); + return flags; + } + }; +} diff --git a/headers/meta.hpp/meta_fwd.hpp b/headers/meta.hpp/meta_traits/void_traits.hpp similarity index 61% rename from headers/meta.hpp/meta_fwd.hpp rename to headers/meta.hpp/meta_traits/void_traits.hpp index bae8590..f3ced24 100644 --- a/headers/meta.hpp/meta_fwd.hpp +++ b/headers/meta.hpp/meta_traits/void_traits.hpp @@ -6,6 +6,15 @@ #pragma once -namespace meta_hpp +#include "../meta_base.hpp" +#include "../meta_traits.hpp" + +namespace meta_hpp::detail { + template < void_kind Void > + struct void_traits { + static bitflags make_flags() noexcept { + return {}; + } + }; }