VCCC  2024.05
VisualCamp Common C++ library
arity.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/12/08.
3 # */
4 #
5 # ifndef VCCC_TYPE_TRAITS_ARITY_HPP
6 # define VCCC_TYPE_TRAITS_ARITY_HPP
7 #
8 # include <type_traits>
9 
10 namespace vccc {
11 
38 template <typename T>
39 struct arity : arity<decltype(&T::operator())> {};
40 
41 
43 template <typename R, typename... Args>
44 struct arity<R(*)(Args...)> : std::integral_constant<unsigned, sizeof...(Args)> {};
45 
46 // Possibly add specialization for variadic functions
47 // Member functions:
48 template <typename R, typename C, typename... Args>
49 struct arity<R(C::*)(Args...)> :
50  std::integral_constant<unsigned, sizeof...(Args)> {};
51 
52 template <typename R, typename C, typename... Args>
53 struct arity<R(C::*)(Args...) const> :
54  std::integral_constant<unsigned, sizeof...(Args)> {};
56 
57 template<typename T>
58 using arity_t = typename arity<T>::type;
59 
61 
62 } // namespace vccc
63 
64 #endif // VCCC_TYPE_TRAITS_ARITY_HPP
typename arity< T >::type arity_t
Definition: arity.hpp:58
Definition: directory.h:12
get parameter count of a given function
Definition: arity.hpp:39