ALPSCore reference
average_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_AVERGAE_TYPE_H
10 #define ALPS_TYPE_TRAITS_AVERGAE_TYPE_H
11 
12 #include <type_traits>
13 #include <valarray>
14 #include <vector>
15 
16 // maybe we can automate this by checking for the existence of a value_type member
17 
18 namespace alps {
19 
20 template <class T>
22  : public std::conditional<std::is_integral<T>::value,double,T> {};
23 
24 template <class T>
25 struct average_type<std::valarray<T> > {
26  typedef std::valarray<typename average_type<T>::type> type;
27 };
28 
29 template <class T, class A>
30 struct average_type<std::vector<T,A> > {
31  typedef std::vector<typename average_type<T>::type,A> type;
32 };
33 
34 } // end namespace alps
35 
36 #endif // ALPS_TYPE_TRAITS_AVERGAE_TYPE_H
std::vector< typename average_type< T >::type, A > type
STL namespace.
std::valarray< typename average_type< T >::type > type