diff options
author | Hauke Heibel <hauke.heibel@gmail.com> | 2009-09-21 19:59:58 +0200 |
---|---|---|
committer | Hauke Heibel <hauke.heibel@gmail.com> | 2009-09-21 19:59:58 +0200 |
commit | c6822d6723ec34c052ca35393aa7e83146bee8c6 (patch) | |
tree | 1339e156b0949a9af6252f50f29281067aca860f /Eigen/src/Core | |
parent | c1c780a94f148c618a74cfcccf40037442ae2d7c (diff) |
Added EIGEN_REF_TO_TEMPORARY define for rvalue support.
Allowed VC10 to make use of static_assert.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/Matrix.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/Swap.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/TriangularMatrix.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/util/Macros.h | 7 | ||||
-rw-r--r-- | Eigen/src/Core/util/StaticAssert.h | 2 |
6 files changed, 14 insertions, 13 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index aea0f15c8..2e2826205 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -538,7 +538,7 @@ class Matrix * data pointers. */ template<typename OtherDerived> - void swap(const MatrixBase<OtherDerived>& other); + void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other); /** \name Map * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects, @@ -756,7 +756,7 @@ struct ei_matrix_swap_impl<MatrixType, OtherDerived, true> template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> template<typename OtherDerived> -inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(const MatrixBase<OtherDerived>& other) +inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other) { enum { SwapPointers = ei_is_same_type<Matrix, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic }; ei_matrix_swap_impl<Matrix, OtherDerived, bool(SwapPointers)>::run(*this, *const_cast<MatrixBase<OtherDerived>*>(&other)); diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index a1659e2a7..5ae2b0002 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -592,7 +592,7 @@ template<typename Derived> class MatrixBase { return typename ei_eval<Derived>::type(derived()); } template<typename OtherDerived> - void swap(const MatrixBase<OtherDerived>& other); + void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other); template<unsigned int Added> const Flagged<Derived, Added, 0> marked() const; diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 44e1f07e0..a7cf219f7 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -128,15 +128,9 @@ template<typename ExpressionType> class SwapWrapper */ template<typename Derived> template<typename OtherDerived> -void MatrixBase<Derived>::swap(const MatrixBase<OtherDerived>& other) +void MatrixBase<Derived>::swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other) { (SwapWrapper<Derived>(derived())).lazyAssign(other); } #endif // EIGEN_SWAP_H - - - - - - diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 17726bca3..e60d57e70 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -300,13 +300,13 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView } template<typename OtherDerived> - void swap(const TriangularBase<OtherDerived>& other) + void swap(TriangularBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other) { TriangularView<SwapWrapper<MatrixType>,Mode>(const_cast<MatrixType&>(m_matrix)).lazyAssign(other.derived()); } template<typename OtherDerived> - void swap(const MatrixBase<OtherDerived>& other) + void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other) { TriangularView<SwapWrapper<MatrixType>,Mode>(const_cast<MatrixType&>(m_matrix)).lazyAssign(other.derived()); } diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 4b62891d9..530306643 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -251,6 +251,13 @@ using Eigen::ei_cos; // needed to define it here as escaping characters in CMake add_definition's argument seems very problematic. #define EIGEN_DOCS_IO_FORMAT IOFormat(3, 0, " ", "\n", "", "") +// C++0x features +#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) + #define EIGEN_REF_TO_TEMPORARY && +#else + #define EIGEN_REF_TO_TEMPORARY const & +#endif + #ifdef _MSC_VER #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ using Base::operator =; \ diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index 73d302fda..7116e4d0f 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -41,7 +41,7 @@ #ifndef EIGEN_NO_STATIC_ASSERT - #ifdef __GXX_EXPERIMENTAL_CXX0X__ + #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) // if native static_assert is enabled, let's use it #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG); |