ndarray
NumPy-friendly multidimensional arrays in C++
Loading...
Searching...
No Matches
ExpressionTraits.h
Go to the documentation of this file.
1// -*- c++ -*-
2/*
3 * Copyright (c) 2010-2012, Jim Bosch
4 * All rights reserved.
5 *
6 * ndarray is distributed under a simple BSD-like license;
7 * see the LICENSE file that should be present in the root
8 * of the source distribution, or alternately available at:
9 * https://github.com/ndarray/ndarray
10 */
11#ifndef NDARRAY_ExpressionTraits_h_INCLUDED
12#define NDARRAY_ExpressionTraits_h_INCLUDED
13
20#include "ndarray_fwd.h"
21#include <boost/static_assert.hpp>
22
23namespace ndarray {
24
30template <typename Expression_> struct ExpressionTraits {
31 typedef boost::mpl::true_ IsScalar;
32};
33
34#ifndef GCC_45
35
41template <typename Operand, typename UnaryFunction, int N>
42struct ExpressionTraits< detail::UnaryOpExpression<Operand,UnaryFunction,N> > {
43 typedef typename UnaryFunction::result_type Element;
44 typedef typename ExpressionTraits<Operand>::ND ND;
47 typename ExpressionTraits<Operand>::Reference,UnaryFunction,N-1
48 > Value;
49 typedef Value Reference;
50 typedef boost::mpl::false_ IsScalar;
51};
52
58template <typename Operand, typename UnaryFunction>
59struct ExpressionTraits< detail::UnaryOpExpression<Operand,UnaryFunction,1> > {
60 typedef typename UnaryFunction::result_type Element;
61 typedef typename ExpressionTraits<Operand>::ND ND;
63 typedef typename boost::remove_const<Element>::type Value;
64 typedef Value const Reference;
65 typedef boost::mpl::false_ IsScalar;
66};
67
73template <typename Operand1, typename Operand2, typename BinaryFunction, int N>
74struct ExpressionTraits< detail::BinaryOpExpression<Operand1,Operand2,BinaryFunction,N> > {
75 typedef typename BinaryFunction::result_type Element;
76 typedef typename ExpressionTraits<Operand1>::ND ND;
81 BinaryFunction, N-1 > Reference;
82 typedef Reference Value;
83 typedef boost::mpl::false_ IsScalar;
84 BOOST_STATIC_ASSERT((ND::value == ExpressionTraits<Operand2>::ND::value));
85};
86
92template <typename Operand1, typename Operand2, typename BinaryFunction>
93struct ExpressionTraits< detail::BinaryOpExpression<Operand1,Operand2,BinaryFunction,1> > {
94 typedef typename BinaryFunction::result_type Element;
95 typedef typename ExpressionTraits<Operand1>::ND ND;
97 typedef typename boost::remove_const<Element>::type Value;
98 typedef Value const Reference;
99 typedef boost::mpl::false_ IsScalar;
100 BOOST_STATIC_ASSERT((ND::value == ExpressionTraits<Operand2>::ND::value));
101};
102
103#endif // GCC_45
104
105} // namespace ndarray
106
107#endif // !NDARRAY_ExpressionTraits_h_INCLUDED
Definition BinaryOp.h:91
Definition BinaryOp.h:48
Definition UnaryOp.h:74
Definition UnaryOp.h:41
Forward declarations and default template parameters for ndarray.
Traits for expressions.
Definition ExpressionTraits.h:30