ALPSCore reference
element_type.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
7 /* $Id: obsvalue.h 3435 2009-11-28 14:45:38Z troyer $ */
8 
9 #ifndef ALPS_TYPE_TRAITS_ELEMENT_TYPE_H
10 #define ALPS_TYPE_TRAITS_ELEMENT_TYPE_H
11 
13 
14 #include <type_traits>
15 
16  namespace alps {
17 
18 template <class T> struct element_type_recursive;
19 
20 namespace detail {
21 
22 template <class T, class F>
23 struct element_type_helper {};
24 
25  template <class T>
26 struct element_type_helper<T,std::false_type>
27 {
28  typedef T type;
29 };
30 
31 template <class T>
32 struct element_type_helper<T,std::true_type>
33 {
34  typedef typename T::value_type type;
35 };
36 
37 template <class T, class F>
38 struct element_type_recursive_helper {};
39 
40  template <class T>
41 struct element_type_recursive_helper<T,std::false_type>
42 {
43  typedef T type;
44 };
45 
46 template <class T>
47 struct element_type_recursive_helper<T,std::true_type>
48  : element_type_recursive<typename T::value_type>
49 {
50 };
51 
52 
53 }
54 
55 template <class T>
56  struct element_type
57  : public detail::element_type_helper<T,typename has_value_type<T>::type > {};
58 
59  template <class T>
61  : public detail::element_type_recursive_helper<T,typename has_value_type<T>::type > {};
62 
63 }
64 
65 #endif // ALPS_TYPE_TRAITS_ELEMENT_TYPE_H
STL namespace.