From 2db538748847b230ff33cfa7f77426400b9b4811 Mon Sep 17 00:00:00 2001 From: Hauke Heibel Date: Wed, 21 Apr 2010 18:21:46 +0200 Subject: [PATCH] Fixed two bad errors on std::vector. First, MSVC 2010 does not ship a 'fixed'/'adapted' STL. Second, only under very rare cases we do not even need the aligned_allocator. --- Eigen/StdList | 4 +--- Eigen/StdVector | 4 +--- Eigen/src/StlSupport/StdList.h | 7 ++++++- Eigen/src/StlSupport/StdVector.h | 18 +++++++++++------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Eigen/StdList b/Eigen/StdList index a6737593e..d914ded4f 100644 --- a/Eigen/StdList +++ b/Eigen/StdList @@ -28,9 +28,7 @@ #include "Core" #include -#if (defined(_MSC_VER) && defined(_WIN64)) || /* MSVC auto aligns in 64 bit builds */ \ - (defined(_MSC_VER) && _MSC_VER >= 1600) || /* MSVC 2010 ships alignment compatible STL libs */ \ - (defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&). */ +#if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) diff --git a/Eigen/StdVector b/Eigen/StdVector index e102b5fc1..f780a1633 100644 --- a/Eigen/StdVector +++ b/Eigen/StdVector @@ -29,9 +29,7 @@ #include "Core" #include -#if (defined(_MSC_VER) && defined(_WIN64)) || /* MSVC auto aligns in 64 bit builds */ \ - (defined(_MSC_VER) && _MSC_VER >= 1600) || /* MSVC 2010 ships alignment compatible STL libs */ \ - (defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&). */ +#if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) diff --git a/Eigen/src/StlSupport/StdList.h b/Eigen/src/StlSupport/StdList.h index 43af4f0f8..55b90066e 100644 --- a/Eigen/src/StlSupport/StdList.h +++ b/Eigen/src/StlSupport/StdList.h @@ -66,6 +66,9 @@ namespace std \ }; \ } +// check whether we really need the std::vector specialization +#if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */ + namespace std { @@ -91,7 +94,7 @@ namespace std template class list > : public list > + Eigen::aligned_allocator_indirection > { typedef list > list_base; @@ -121,4 +124,6 @@ namespace std }; } +#endif // check whether specialization is actually required + #endif // EIGEN_STDLIST_H diff --git a/Eigen/src/StlSupport/StdVector.h b/Eigen/src/StlSupport/StdVector.h index f3d268c9b..8526d29e0 100644 --- a/Eigen/src/StlSupport/StdVector.h +++ b/Eigen/src/StlSupport/StdVector.h @@ -67,6 +67,9 @@ namespace std \ }; \ } +// check whether we really need the std::vector specialization +#if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&). */ + namespace std { #define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \ @@ -88,10 +91,10 @@ namespace std { return *this; \ } -template -class vector > - : public vector > + template + class vector > + : public vector > { typedef vector > vector_base; @@ -101,6 +104,7 @@ class vector > { resize(new_size, T()); } #if defined(_VECTOR_) + #pragma message("old method") // workaround MSVC std::vector implementation void resize(size_type new_size, const value_type& x) { @@ -136,9 +140,9 @@ class vector > vector_base::insert(vector_base::end(), new_size - vector_base::size(), x); } #endif - -}; - + }; } +#endif // check whether specialization is actually required + #endif // EIGEN_STDVECTOR_H