CASM  1.1.0
A Clusters Approach to Statistical Mechanics
type_traits.hh
Go to the documentation of this file.
1 #ifndef CASM_type_traits
2 #define CASM_type_traits
3 
4 #include <type_traits>
5 #include <utility>
6 
7 namespace notstd {
9 template <typename... Ts>
10 struct make_void {
11  typedef void type;
12 };
13 
15 template <typename... Ts>
16 using void_t = typename make_void<Ts...>::type;
17 
20 template <typename T>
21 struct function_traits : public function_traits<decltype(&T::operator())> {};
22 
23 template <typename ClassType, typename ReturnType, typename... Args>
24 struct function_traits<ReturnType (ClassType::*)(Args...) const> {
25  enum { arity = sizeof...(Args) };
26 
27  typedef ReturnType result_type;
28 
29  template <std::size_t i>
30  struct arg {
31  typedef typename std::tuple_element<i, std::tuple<Args...>>::type type;
32  };
33 };
34 
35 template <typename F>
36 /* using first_argument_type = std::decay_t<typename
37  function_traits<F>::template arg<0>::type>; */
38 using first_argument_type = typename std::decay<
39  typename function_traits<F>::template arg<0>::type>::type;
40 template <typename F>
41 /* using second_argument_type = std::decay_t<typename
42  function_traits<F>::template arg<1>::type>; */
43 using second_argument_type = typename std::decay<
44  typename function_traits<F>::template arg<1>::type>::type;
45 template <typename F>
46 /* using return_type = std::decay_t<typename function_traits<F>::result_type>;
47  */
48 using return_type =
49  typename std::decay<typename function_traits<F>::result_type>::type;
50 
51 } // namespace notstd
52 
53 #endif
Non-std smart pointer classes and functions.
typename std::decay< typename function_traits< F >::template arg< 1 >::type >::type second_argument_type
Definition: type_traits.hh:44
typename make_void< Ts... >::type void_t
Alias for void, to help SFINAE work.
Definition: type_traits.hh:16
typename std::decay< typename function_traits< F >::template arg< 0 >::type >::type first_argument_type
Definition: type_traits.hh:39
typename std::decay< typename function_traits< F >::result_type >::type return_type
Definition: type_traits.hh:49
std::tuple_element< i, std::tuple< Args... > >::type type
Definition: type_traits.hh:31
Deduces return type and argument types for non-generic labmdas and functors.
Definition: type_traits.hh:21
Alias for void, to help SFINAE work.
Definition: type_traits.hh:10