-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathExpressionTraits.h
More file actions
107 lines (95 loc) · 3.51 KB
/
Copy pathExpressionTraits.h
File metadata and controls
107 lines (95 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// -*- c++ -*-
/*
* Copyright (c) 2010-2012, Jim Bosch
* All rights reserved.
*
* ndarray is distributed under a simple BSD-like license;
* see the LICENSE file that should be present in the root
* of the source distribution, or alternately available at:
* https://github.com/ndarray/ndarray
*/
#ifndef NDARRAY_ExpressionTraits_h_INCLUDED
#define NDARRAY_ExpressionTraits_h_INCLUDED
/**
* @file ndarray/ExpressionTraits.h
*
* @brief Traits for Expression.
*/
#include "ndarray_fwd.h"
#include <boost/static_assert.hpp>
namespace ndarray {
/**
* @brief Traits for expressions.
*
* @ingroup MainGroup
*/
template <typename Expression_> struct ExpressionTraits {
typedef boost::mpl::true_ IsScalar;
};
#ifndef GCC_45
/**
* @internal @brief ExpressionTraits specialization for UnaryOpExpression.
*
* @ingroup ndarrayInternalGroup
*/
template <typename Operand, typename UnaryFunction, int N>
struct ExpressionTraits< detail::UnaryOpExpression<Operand,UnaryFunction,N> > {
typedef typename UnaryFunction::result_type Element;
typedef typename ExpressionTraits<Operand>::ND ND;
typedef detail::UnaryOpIterator<Operand,UnaryFunction> Iterator;
typedef detail::UnaryOpExpression<
typename ExpressionTraits<Operand>::Reference,UnaryFunction,N-1
> Value;
typedef Value Reference;
typedef boost::mpl::false_ IsScalar;
};
/**
* @internal @brief ExpressionTraits specialization for 1D UnaryOpExpression.
*
* @ingroup ndarrayInternalGroup
*/
template <typename Operand, typename UnaryFunction>
struct ExpressionTraits< detail::UnaryOpExpression<Operand,UnaryFunction,1> > {
typedef typename UnaryFunction::result_type Element;
typedef typename ExpressionTraits<Operand>::ND ND;
typedef detail::UnaryOpIterator<Operand,UnaryFunction> Iterator;
typedef typename boost::remove_const<Element>::type Value;
typedef Value const Reference;
typedef boost::mpl::false_ IsScalar;
};
/**
* @internal @brief ExpressionTraits specialization for BinaryOpExpression.
*
* @ingroup ndarrayInternalGroup
*/
template <typename Operand1, typename Operand2, typename BinaryFunction, int N>
struct ExpressionTraits< detail::BinaryOpExpression<Operand1,Operand2,BinaryFunction,N> > {
typedef typename BinaryFunction::result_type Element;
typedef typename ExpressionTraits<Operand1>::ND ND;
typedef detail::BinaryOpIterator<Operand1,Operand2,BinaryFunction> Iterator;
typedef detail::BinaryOpExpression<
typename ExpressionTraits<Operand1>::Reference,
typename ExpressionTraits<Operand2>::Reference,
BinaryFunction, N-1 > Reference;
typedef Reference Value;
typedef boost::mpl::false_ IsScalar;
BOOST_STATIC_ASSERT((ND::value == ExpressionTraits<Operand2>::ND::value));
};
/**
* @internal @brief ExpressionTraits specialization for 1D BinaryOpExpression.
*
* @ingroup ndarrayInternalGroup
*/
template <typename Operand1, typename Operand2, typename BinaryFunction>
struct ExpressionTraits< detail::BinaryOpExpression<Operand1,Operand2,BinaryFunction,1> > {
typedef typename BinaryFunction::result_type Element;
typedef typename ExpressionTraits<Operand1>::ND ND;
typedef detail::BinaryOpIterator<Operand1,Operand2,BinaryFunction> Iterator;
typedef typename boost::remove_const<Element>::type Value;
typedef Value const Reference;
typedef boost::mpl::false_ IsScalar;
BOOST_STATIC_ASSERT((ND::value == ExpressionTraits<Operand2>::ND::value));
};
#endif // GCC_45
} // namespace ndarray
#endif // !NDARRAY_ExpressionTraits_h_INCLUDED