Dune Core Modules (2.3.1)

promotiontraits.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_PROMOTIONTRAITS_HH
4#define DUNE_PROMOTIONTRAITS_HH
5
6#include <complex>
7
8namespace Dune {
26 template <typename T1, typename T2>
27 struct PromotionTraits { };
28
29#ifndef DOXYGEN
30 // class for type promotion; // the same types are the same:
31 template <typename T1>
32 struct PromotionTraits<T1,T1> { typedef T1 PromotedType; };
33
34 // promote to complex type
35 template <typename T1>
36 struct PromotionTraits<std::complex<T1>,T1> { typedef std::complex<T1> PromotedType; };
37
38 // \private promote to complex type
39 template <typename T1>
40 struct PromotionTraits<T1,std::complex<T1> > { typedef std::complex<T1> PromotedType; };
41
42 // a few specializations for some common cases
43 template<> struct PromotionTraits<std::complex<double>,std::complex<double> > { typedef std::complex<double> PromotedType; };
44 template<> struct PromotionTraits<std::complex<double>,double> { typedef std::complex<double> PromotedType; };
45 template<> struct PromotionTraits<double,std::complex<double> > { typedef std::complex<double> PromotedType; };
46 template<> struct PromotionTraits<double,double> { typedef double PromotedType; };
47
48 template<> struct PromotionTraits<std::complex<float>,float> { typedef std::complex<float> PromotedType; };
49 template<> struct PromotionTraits<float,std::complex<float> > { typedef std::complex<float> PromotedType; };
50 template<> struct PromotionTraits<std::complex<float>,std::complex<float> > { typedef std::complex<float> PromotedType; };
51 template<> struct PromotionTraits<float,float> { typedef float PromotedType; };
52
53 template<> struct PromotionTraits<std::complex<int>,int> { typedef std::complex<int> PromotedType; };
54 template<> struct PromotionTraits<int,std::complex<int> > { typedef std::complex<int> PromotedType; };
55 template<> struct PromotionTraits<std::complex<int>,std::complex<int> > { typedef std::complex<int> PromotedType; };
56 template<> struct PromotionTraits<int,int> { typedef int PromotedType; };
57#endif // DOXYGEN
58
60} // end namespace
61
62
63#endif // DUNE_PROMOTIONTRAITS_HH
Dune namespace.
Definition: alignment.hh:14
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)