|
- #pragma once
-
- #include <cppmp/core/checker.h>
- #include <cppmp/core/conditionals.h>
-
- #include "lambda_traits.h"
-
- namespace cppmp
- {
-
- namespace __impl
- {
-
- /* lambda_traits_impl */
-
- template<bool B_is_mutable, typename T_object, typename T_return, typename... T_args>
- struct lambda_traits_impl
- {
- using object_type = T_object;
- using return_type = T_return;
- using arguments_type = std::tuple<T_args...>;
-
- using is_mutable = bool_t<B_is_mutable>;
- using is_static = is_same<object_type, void>;
- using argument_count = size_t<sizeof...(T_args)>;
-
- static constexpr decltype(auto) is_mutable_v = is_mutable::value;
- static constexpr decltype(auto) is_static_v = is_static::value;
- static constexpr decltype(auto) argument_count_v = argument_count::value;
-
- template<std::size_t I>
- struct argument
- : public std::tuple_element<I, arguments_type>
- { };
-
- template<std::size_t I>
- using argument_t = typename argument<I>::type;
- };
-
- }
-
- /* lambda_traits */
-
- template<typename T_lambda>
- struct lambda_traits<
- T_lambda,
- enable_if_t<
- is_valid<decltype(&T_lambda::operator())>::value
- >>
- : public lambda_traits<decltype(&T_lambda::operator())>
- { };
-
- template<typename T_return, typename... T_args>
- struct lambda_traits<T_return (*)(T_args...), void>
- : public __impl::lambda_traits_impl<false, void, T_return, T_args...>
- { };
-
- template<typename T_object, typename T_return, typename... T_args>
- struct lambda_traits<T_return (T_object::*)(T_args...), void>
- : public __impl::lambda_traits_impl<true, T_object, T_return, T_args...>
- { };
-
- template<typename T_object, typename T_return, typename... T_args>
- struct lambda_traits<T_return (T_object::*)(T_args...) const, void>
- : public __impl::lambda_traits_impl<false, const T_object, T_return, T_args...>
- { };
-
- }
|