#pragma once #include "tuple.hpp" namespace sol { namespace meta { namespace meta_detail { template struct check_deducible_signature { struct nat {}; template static auto test(int) -> decltype(&G::operator(), void()); template static auto test(...) -> nat; using type = std::is_void(0))>; }; } // meta_detail template struct has_deducible_signature : meta_detail::check_deducible_signature::type { }; namespace meta_detail { template struct void_tuple_element : meta::tuple_element {}; template struct void_tuple_element> { typedef void type; }; template using void_tuple_element_t = typename void_tuple_element::type; template struct basic_traits { private: typedef std::conditional_t::value, int, T>& first_type; public: static const bool is_member_function = std::is_void::value; static const bool has_c_var_arg = has_c_variadic; static const std::size_t arity = sizeof...(Args); static const std::size_t free_arity = sizeof...(Args) + static_cast(!std::is_void::value); typedef types args_list; typedef std::tuple args_tuple; typedef T object_type; typedef R return_type; typedef tuple_types returns_list; typedef R(function_type)(Args...); typedef std::conditional_t::value, args_list, types> free_args_list; typedef std::conditional_t::value, R(Args...), R(first_type, Args...)> free_function_type; typedef std::conditional_t::value, R(*)(Args...), R(*)(first_type, Args...)> free_function_pointer_type; typedef std::remove_pointer_t signature_type; template using arg_at = void_tuple_element_t; }; template::value> struct fx_traits : basic_traits {}; // Free Functions template struct fx_traits : basic_traits { typedef R(*function_pointer_type)(Args...); }; template struct fx_traits : basic_traits { typedef R(*function_pointer_type)(Args...); }; template struct fx_traits : basic_traits { typedef R(*function_pointer_type)(Args..., ...); }; template struct fx_traits : basic_traits { typedef R(*function_pointer_type)(Args..., ...); }; // Member Functions /* C-Style Variadics */ template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...); }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...); }; /* Const Volatile */ template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) const; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) const; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) const volatile; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) const volatile; }; /* Member Function Qualifiers */ template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) &; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) &; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) const &; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) const &; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) const volatile &; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) const volatile &; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) &&; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) &&; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) const &&; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) const &&; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args...) const volatile &&; }; template struct fx_traits : basic_traits { typedef R(T::* function_pointer_type)(Args..., ...) const volatile &&; }; template struct fx_traits : fx_traits::function_type, false> {}; template::value> struct callable_traits : fx_traits> { }; template struct callable_traits { typedef R Arg; typedef T object_type; using signature_type = R(T::*); static const bool is_member_function = false; static const std::size_t arity = 1; static const std::size_t free_arity = 2; typedef std::tuple args_tuple; typedef R return_type; typedef types args_list; typedef meta::tuple_types returns_list; typedef R(function_type)(T&, R); typedef R(*function_pointer_type)(T&, R); typedef R(*free_function_pointer_type)(T&, R); template using arg_at = void_tuple_element_t; }; } // meta_detail template struct bind_traits : meta_detail::callable_traits {}; template using function_args_t = typename bind_traits::args_list; template using function_signature_t = typename bind_traits::signature_type; template using function_return_t = typename bind_traits::return_type; } // meta } // sol