Added EIGEN_REF_TO_TEMPORARY define for rvalue support.

Allowed VC10 to make use of static_assert.
This commit is contained in:
Hauke Heibel
2009-09-21 19:59:58 +02:00
parent c1c780a94f
commit c6822d6723
9 changed files with 22 additions and 14 deletions

View File

@@ -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));

View File

@@ -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;

View File

@@ -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

View File

@@ -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());
}

View File

@@ -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 =; \

View File

@@ -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);

View File

@@ -515,7 +515,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
{ 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 SparseFlagged<Derived, Added, 0> marked() const;