From 3a49cafe9fcd73fd40e65e260592d9f606dc0148 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Tue, 6 Jul 2021 04:14:21 +0700 Subject: [PATCH] more complete function, method, and field traits --- headers/meta.hpp/meta_fwd.hpp | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/headers/meta.hpp/meta_fwd.hpp b/headers/meta.hpp/meta_fwd.hpp index f6497d9..99ffa0c 100644 --- a/headers/meta.hpp/meta_fwd.hpp +++ b/headers/meta.hpp/meta_fwd.hpp @@ -165,3 +165,88 @@ namespace meta_hpp::detail } } } + +namespace meta_hpp::detail +{ + template < typename Field > + struct field_traits; + + template < typename T, typename I > + struct field_traits { + static constexpr bool is_const = false; + using value_type = T; + using instance_type = I; + }; + + template < typename T, typename I > + struct field_traits + : field_traits { + static constexpr bool is_const = true; + }; +} + +namespace meta_hpp::detail +{ + template < typename Function > + struct function_traits; + + template < typename R, typename... Args > + struct function_traits { + static constexpr bool is_noexcept = false; + static constexpr std::size_t arity = sizeof...(Args); + using return_type = R; + using argument_types = std::tuple; + }; + + template < typename R, typename... Args > + struct function_traits + : function_traits {}; + + template < typename R, typename... Args > + struct function_traits + : function_traits {}; + + template < typename R, typename... Args > + struct function_traits + : function_traits { + static constexpr bool is_noexcept = true; + }; + + template < typename R, typename... Args > + struct function_traits + : function_traits { + static constexpr bool is_noexcept = true; + }; +} + +namespace meta_hpp::detail +{ + template < typename Method > + struct method_traits; + + template < typename R, typename I, typename... Args > + struct method_traits + : function_traits { + static constexpr bool is_const = false; + using instance_type = I; + }; + + template < typename R, typename I, typename... Args > + struct method_traits + : method_traits { + static constexpr bool is_const = true; + }; + + template < typename R, typename I, typename... Args > + struct method_traits + : method_traits { + static constexpr bool is_noexcept = true; + }; + + template < typename R, typename I, typename... Args > + struct method_traits + : method_traits { + static constexpr bool is_const = true; + static constexpr bool is_noexcept = true; + }; +}