aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/StdVector
diff options
context:
space:
mode:
authorGravatar Hauke Heibel <hauke.heibel@gmail.com>2010-01-27 20:34:05 +0100
committerGravatar Hauke Heibel <hauke.heibel@gmail.com>2010-01-27 20:34:05 +0100
commit5b9cc65418be7539db01f87712ed32d3f22517a5 (patch)
treeccc72d0b9e0b85bb70ea744811c9952222127bc7 /Eigen/StdVector
parent828d058b4b340a467da7f7bea6bb29522a6565f9 (diff)
Added EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION macro including unit tests and documentation.
Diffstat (limited to 'Eigen/StdVector')
-rw-r--r--Eigen/StdVector39
1 files changed, 39 insertions, 0 deletions
diff --git a/Eigen/StdVector b/Eigen/StdVector
index b6dbde8a2..04e356785 100644
--- a/Eigen/StdVector
+++ b/Eigen/StdVector
@@ -29,6 +29,45 @@
#include "Core"
#include <vector>
+// Define the explicit instantiation (e.g. necessary for the Intel compiler)
+#if defined(__INTEL_COMPILER) || defined(__GNUC__)
+ #define EIGEN_EXPLICIT_STL_VECTOR_INSTANTIATION(...) template class std::vector<__VA_ARGS__, Eigen::aligned_allocator<__VA_ARGS__> >;
+#else
+ #define EIGEN_EXPLICIT_STL_VECTOR_INSTANTIATION(...)
+#endif
+
+/**
+ * This section contains a convenience MACRO which allows an easy specialization of
+ * std::vector such that for data types with alignment issues the correct allocator
+ * is used automatically.
+ */
+#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \
+EIGEN_EXPLICIT_STL_VECTOR_INSTANTIATION(__VA_ARGS__) \
+namespace std \
+{ \
+ template<typename _Ay> \
+ class vector<__VA_ARGS__, _Ay> \
+ : public vector<__VA_ARGS__, Eigen::aligned_allocator<__VA_ARGS__> > \
+ { \
+ typedef vector<__VA_ARGS__, Eigen::aligned_allocator<__VA_ARGS__> > vector_base; \
+ public: \
+ typedef __VA_ARGS__ value_type; \
+ typedef typename vector_base::allocator_type allocator_type; \
+ typedef typename vector_base::size_type size_type; \
+ typedef typename vector_base::iterator iterator; \
+ explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
+ template<typename InputIterator> \
+ vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \
+ vector(const vector& c) : vector_base(c) {} \
+ explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
+ vector(iterator start, iterator end) : vector_base(start, end) {} \
+ vector& operator=(const vector& x) { \
+ vector_base::operator=(x); \
+ return *this; \
+ } \
+ }; \
+}
+
namespace Eigen {
// This one is needed to prevent reimplementing the whole std::vector.