diff --git a/CMakeLists.txt b/CMakeLists.txt index c229a2858..166dbe621 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,10 @@ if(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION) message("Disabling vectorization in tests/examples") endif(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION) +option(EIGEN_TEST_C++0x "Enables all C++0x features." OFF) + +option(EIGEN_TEST_RVALUE_REF_SUPPORT "Enable rvalue references for unit tests." OFF) + include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set(INCLUDE_INSTALL_DIR 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 - void swap(const MatrixBase& other); + void swap(MatrixBase 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 template template -inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(const MatrixBase& other) +inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(MatrixBase EIGEN_REF_TO_TEMPORARY other) { enum { SwapPointers = ei_is_same_type::ret && Base::SizeAtCompileTime==Dynamic }; ei_matrix_swap_impl::run(*this, *const_cast*>(&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 class MatrixBase { return typename ei_eval::type(derived()); } template - void swap(const MatrixBase& other); + void swap(MatrixBase EIGEN_REF_TO_TEMPORARY other); template const Flagged 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 class SwapWrapper */ template template -void MatrixBase::swap(const MatrixBase& other) +void MatrixBase::swap(MatrixBase EIGEN_REF_TO_TEMPORARY other) { (SwapWrapper(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 class TriangularView } template - void swap(const TriangularBase& other) + void swap(TriangularBase EIGEN_REF_TO_TEMPORARY other) { TriangularView,Mode>(const_cast(m_matrix)).lazyAssign(other.derived()); } template - void swap(const MatrixBase& other) + void swap(MatrixBase EIGEN_REF_TO_TEMPORARY other) { TriangularView,Mode>(const_cast(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); diff --git a/Eigen/src/Sparse/SparseMatrixBase.h b/Eigen/src/Sparse/SparseMatrixBase.h index b2b010565..61e8adea3 100644 --- a/Eigen/src/Sparse/SparseMatrixBase.h +++ b/Eigen/src/Sparse/SparseMatrixBase.h @@ -515,7 +515,7 @@ template class SparseMatrixBase : public AnyMatrixBase::type(derived()); } // template -// void swap(const MatrixBase& other); +// void swap(MatrixBase EIGEN_REF_TO_TEMPORARY other); template const SparseFlagged marked() const; diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index faa75c6f4..b252e90e2 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -159,6 +159,9 @@ if(CMAKE_COMPILER_IS_GNUCXX) else(EIGEN_COVERAGE_TESTING) set(COVERAGE_FLAGS "") endif(EIGEN_COVERAGE_TESTING) + if((EIGEN_TEST_RVALUE_REF_SUPPORT OR EIGEN_TEST_C++0x) AND NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + endif((EIGEN_TEST_RVALUE_REF_SUPPORT OR EIGEN_TEST_C++0x) AND NOT MSVC) if(CMAKE_SYSTEM_NAME MATCHES Linux) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS} -g2") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COVERAGE_FLAGS} -O2 -g2")