cheshirekow  v0.1.0
rvalue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of fiber.
5  *
6  * fiber is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * fiber is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with fiber. If not, see <http://www.gnu.org/licenses/>.
18  */
25 #ifndef FIBER_RVALUE_H_
26 #define FIBER_RVALUE_H_
27 
28 
29 namespace fiber {
30 
32 template <typename Scalar, class Exp>
33 class _RValue {
34  public:
35  Size size() const { return static_cast<Exp const&>(*this).size(); }
36  Size rows() const { return static_cast<Exp const&>(*this).rows(); }
37  Size cols() const { return static_cast<Exp const&>(*this).cols(); }
38 
39  Scalar operator[](Size i) const {
40  return static_cast<Exp const&>(*this)[i];
41  }
42 
43  Scalar operator()(Size i, Size j) const {
44  return static_cast<Exp const&>(*this)(i, j);
45  }
46 };
47 
50 template <typename Scalar, class Exp>
52  return exp;
53 }
54 
55 } // namespace fiber
56 
57 
58 #endif // FIBER_RVALUE_H_
const _RValue< Scalar, Exp > & RValue(const _RValue< Scalar, Exp > &exp)
Explicitly expose _RValue of an expressions, can be used to help the compiler disambiguate overloads...
Definition: rvalue.h:51
expression template for rvalues
Definition: rvalue.h:33
Size cols() const
Definition: rvalue.h:37
unsigned int Size
Definition: fiber.h:32
Size rows() const
Definition: rvalue.h:36
Scalar operator[](Size i) const
Definition: rvalue.h:39
Scalar operator()(Size i, Size j) const
Definition: rvalue.h:43
Size size() const
Definition: rvalue.h:35