StdDeque.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_STDDEQUE_H
12 #define EIGEN_STDDEQUE_H
13 
14 #include "details.h"
15 
21 #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) \
22 namespace std \
23 { \
24  template<> \
25  class deque<__VA_ARGS__, std::allocator<__VA_ARGS__> > \
26  : public deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
27  { \
28  typedef deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > deque_base; \
29  public: \
30  typedef __VA_ARGS__ value_type; \
31  typedef deque_base::allocator_type allocator_type; \
32  typedef deque_base::size_type size_type; \
33  typedef deque_base::iterator iterator; \
34  explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {} \
35  template<typename InputIterator> \
36  deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : deque_base(first, last, a) {} \
37  deque(const deque& c) : deque_base(c) {} \
38  explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \
39  deque(iterator start_, iterator end_) : deque_base(start_, end_) {} \
40  deque& operator=(const deque& x) { \
41  deque_base::operator=(x); \
42  return *this; \
43  } \
44  }; \
45 }
46 
47 // check whether we really need the std::deque specialization
48 #if !EIGEN_HAS_CXX11_CONTAINERS && !(defined(_GLIBCXX_DEQUE) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::deque::resize(size_type,const T&). */
49 
50 namespace std {
51 
52 #define EIGEN_STD_DEQUE_SPECIALIZATION_BODY \
53  public: \
54  typedef T value_type; \
55  typedef typename deque_base::allocator_type allocator_type; \
56  typedef typename deque_base::size_type size_type; \
57  typedef typename deque_base::iterator iterator; \
58  typedef typename deque_base::const_iterator const_iterator; \
59  explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {} \
60  template<typename InputIterator> \
61  deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
62  : deque_base(first, last, a) {} \
63  deque(const deque& c) : deque_base(c) {} \
64  explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \
65  deque(iterator start_, iterator end_) : deque_base(start_, end_) {} \
66  deque& operator=(const deque& x) { \
67  deque_base::operator=(x); \
68  return *this; \
69  }
70 
71  template<typename T>
72  class deque<T,EIGEN_ALIGNED_ALLOCATOR<T> >
73  : public deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
74  Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
75 {
76  typedef deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
79 
80  void resize(size_type new_size)
81  { resize(new_size, T()); }
82 
83 #if defined(_DEQUE_)
84  // workaround MSVC std::deque implementation
85  void resize(size_type new_size, const value_type& x)
86  {
87  if (deque_base::size() < new_size)
88  deque_base::_Insert_n(deque_base::end(), new_size - deque_base::size(), x);
89  else if (new_size < deque_base::size())
90  deque_base::erase(deque_base::begin() + new_size, deque_base::end());
91  }
92  void push_back(const value_type& x)
93  { deque_base::push_back(x); }
94  void push_front(const value_type& x)
95  { deque_base::push_front(x); }
96  using deque_base::insert;
97  iterator insert(const_iterator position, const value_type& x)
98  { return deque_base::insert(position,x); }
99  void insert(const_iterator position, size_type new_size, const value_type& x)
100  { deque_base::insert(position, new_size, x); }
101 #else
102  // default implementation which should always work.
103  void resize(size_type new_size, const value_type& x)
104  {
105  if (new_size < deque_base::size())
106  deque_base::erase(deque_base::begin() + new_size, deque_base::end());
107  else if (new_size > deque_base::size())
109  }
110 #endif
111  };
112 }
113 
114 #endif // check whether specialization is actually required
115 
116 #endif // EIGEN_STDDEQUE_H
EIGEN_ALIGNED_ALLOCATOR
#define EIGEN_ALIGNED_ALLOCATOR
Definition: details.h:15
resize
v resize(3)
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
std::deque< T, EIGEN_ALIGNED_ALLOCATOR< T > >::resize
EIGEN_STD_DEQUE_SPECIALIZATION_BODY void resize(size_type new_size)
Definition: StdDeque.h:80
T
Eigen::Triplet< double > T
Definition: Tutorial_sparse_example.cpp:6
iterator
Definition: pytypes.h:1460
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
EIGEN_WORKAROUND_MSVC_STL_SUPPORT
#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)
Definition: details.h:78
std::deque< T, EIGEN_ALIGNED_ALLOCATOR< T > >::deque_base
deque< EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T), Eigen::aligned_allocator_indirection< EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > deque_base
Definition: StdDeque.h:77
EIGEN_STD_DEQUE_SPECIALIZATION_BODY
#define EIGEN_STD_DEQUE_SPECIALIZATION_BODY
Definition: StdDeque.h:52
Eigen::Triplet< double >
Eigen::aligned_allocator_indirection
Definition: details.h:22
std
Definition: BFloat16.h:88
gtsam::internal::position
Point3 position(const NavState &X, OptionalJacobian< 3, 9 > H)
Definition: navigation/expressions.h:25
details.h
Eigen::placeholders::end
static const EIGEN_DEPRECATED end_t end
Definition: IndexedViewHelper.h:181
insert
A insert(1, 2)=0
std::deque< T, EIGEN_ALIGNED_ALLOCATOR< T > >::resize
void resize(size_type new_size, const value_type &x)
Definition: StdDeque.h:103


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:36:24