Debian Codegraph @

packages/stokhos/src/sacado/Sacado_ETPCE_ExpressionTraits.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef SACADO_ETPCE_EXPRESSIONTRAITS_HPP
11 #define SACADO_ETPCE_EXPRESSIONTRAITS_HPP
12
13 #include "Sacado_Traits.hpp"
14
15 // Forward declarations
16 namespace Sacado {
17 namespace ETPCE {
18 template <typename T> class Expr;
19 }
20 }
21
22 namespace Sacado {
23
24 // We don't specialize Promote because otherwise we can get ambiguous
25 // partial specializations with the OrthogPoly classes.
26
27 //! Specialization of %ScalarType to Expr types
28 template <typename T>
29 struct ScalarType< ETPCE::Expr<T> > {
30 typedef typename ScalarType< typename ETPCE::Expr<T>::value_type >::type type;
31 };
32
33 //! Specialization of %ValueType to Expr types
34 template <typename T>
35 struct ValueType< ETPCE::Expr<T> > {
36 typedef typename ETPCE::Expr<T>::value_type type;
37 };
38
39 //! Specialization of %IsADType to Expr types
40 template <typename T>
41 struct IsADType< ETPCE::Expr<T> > {
42 static const bool value = true;
43 };
44
45 //! Specialization of %IsADType to Expr types
46 template <typename T>
47 struct IsScalarType< ETPCE::Expr<T> > {
48 static const bool value = false;
49 };
50
51 //! Specialization of %Value to Expr types
52 template <typename T>
53 struct Value< ETPCE::Expr<T> > {
54 typedef typename ValueType< ETPCE::Expr<T> >::type value_type;
55 static const value_type& eval(const ETPCE::Expr<T>& x) {
56 return x.val(); }
57 };
58
59 //! Specialization of %ScalarValue to Expr types
60 template <typename T>
61 struct ScalarValue< ETPCE::Expr<T> > {
62 typedef typename ValueType< ETPCE::Expr<T> >::type value_type;
63 typedef typename ScalarType< ETPCE::Expr<T> >::type scalar_type;
64 static const scalar_type& eval(const ETPCE::Expr<T>& x) {
65 return ScalarValue<value_type>::eval(x.val()); }
66 };
67
68 } // namespace Sacado
69
70 #endif // SACADO_ETPCE_EXPRESSIONTRAITS_HPP