list.hpp 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2015. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_CONTAINER_LIST_HPP
  11. #define BOOST_CONTAINER_LIST_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/container/detail/config_begin.hpp>
  19. #include <boost/container/detail/workaround.hpp>
  20. // container
  21. #include <boost/container/container_fwd.hpp>
  22. #include <boost/container/new_allocator.hpp> //new_allocator
  23. #include <boost/container/throw_exception.hpp>
  24. // container/detail
  25. #include <boost/container/detail/algorithm.hpp>
  26. #include <boost/container/detail/compare_functors.hpp>
  27. #include <boost/container/detail/iterator.hpp>
  28. #include <boost/container/detail/iterators.hpp>
  29. #include <boost/container/detail/mpl.hpp>
  30. #include <boost/container/detail/node_alloc_holder.hpp>
  31. #include <boost/container/detail/version_type.hpp>
  32. #include <boost/container/detail/value_functors.hpp>
  33. // move
  34. #include <boost/move/utility_core.hpp>
  35. #include <boost/move/iterator.hpp>
  36. #include <boost/move/traits.hpp>
  37. // move/detail
  38. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  39. # include <boost/move/detail/fwd_macros.hpp>
  40. #endif
  41. #include <boost/move/detail/move_helpers.hpp>
  42. // intrusive
  43. #include <boost/intrusive/pointer_traits.hpp>
  44. #include <boost/intrusive/list.hpp>
  45. // other
  46. #include <boost/assert.hpp>
  47. // std
  48. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  49. #include <initializer_list>
  50. #endif
  51. namespace boost {
  52. namespace container {
  53. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  54. namespace dtl {
  55. template<class VoidPointer>
  56. struct list_hook
  57. {
  58. typedef typename dtl::bi::make_list_base_hook
  59. <dtl::bi::void_pointer<VoidPointer>, dtl::bi::link_mode<dtl::bi::normal_link> >::type type;
  60. };
  61. template <class T, class VoidPointer>
  62. struct list_node
  63. : public list_hook<VoidPointer>::type
  64. {
  65. public:
  66. typedef T value_type;
  67. typedef T internal_type;
  68. typedef typename list_hook<VoidPointer>::type hook_type;
  69. typedef typename dtl::aligned_storage<sizeof(T), dtl::alignment_of<T>::value>::type storage_t;
  70. storage_t m_storage;
  71. #if defined(BOOST_GCC) && (BOOST_GCC >= 40600) && (BOOST_GCC < 80000)
  72. #pragma GCC diagnostic push
  73. #pragma GCC diagnostic ignored "-Wstrict-aliasing"
  74. #define BOOST_CONTAINER_DISABLE_ALIASING_WARNING
  75. # endif
  76. BOOST_CONTAINER_FORCEINLINE T &get_data()
  77. { return *reinterpret_cast<T*>(this->m_storage.data); }
  78. BOOST_CONTAINER_FORCEINLINE const T &get_data() const
  79. { return *reinterpret_cast<const T*>(this->m_storage.data); }
  80. BOOST_CONTAINER_FORCEINLINE T *get_data_ptr()
  81. { return reinterpret_cast<T*>(this->m_storage.data); }
  82. BOOST_CONTAINER_FORCEINLINE const T *get_data_ptr() const
  83. { return reinterpret_cast<T*>(this->m_storage.data); }
  84. BOOST_CONTAINER_FORCEINLINE internal_type &get_real_data()
  85. { return *reinterpret_cast<internal_type*>(this->m_storage.data); }
  86. BOOST_CONTAINER_FORCEINLINE const internal_type &get_real_data() const
  87. { return *reinterpret_cast<const internal_type*>(this->m_storage.data); }
  88. BOOST_CONTAINER_FORCEINLINE internal_type *get_real_data_ptr()
  89. { return reinterpret_cast<internal_type*>(this->m_storage.data); }
  90. BOOST_CONTAINER_FORCEINLINE const internal_type *get_real_data_ptr() const
  91. { return reinterpret_cast<internal_type*>(this->m_storage.data); }
  92. BOOST_CONTAINER_FORCEINLINE ~list_node()
  93. { reinterpret_cast<T*>(this->m_storage.data)->~T(); }
  94. #if defined(BOOST_CONTAINER_DISABLE_ALIASING_WARNING)
  95. #pragma GCC diagnostic pop
  96. #undef BOOST_CONTAINER_DISABLE_ALIASING_WARNING
  97. # endif
  98. BOOST_CONTAINER_FORCEINLINE void destroy_header()
  99. { static_cast<hook_type*>(this)->~hook_type(); }
  100. };
  101. template <class T, class VoidPointer>
  102. struct iiterator_node_value_type< list_node<T,VoidPointer> > {
  103. typedef T type;
  104. };
  105. template<class Allocator>
  106. struct intrusive_list_type
  107. {
  108. typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
  109. typedef typename allocator_traits_type::value_type value_type;
  110. typedef typename boost::intrusive::pointer_traits
  111. <typename allocator_traits_type::pointer>::template
  112. rebind_pointer<void>::type
  113. void_pointer;
  114. typedef typename dtl::list_node
  115. <value_type, void_pointer> node_type;
  116. typedef typename dtl::bi::make_list
  117. < node_type
  118. , dtl::bi::base_hook<typename list_hook<void_pointer>::type>
  119. , dtl::bi::constant_time_size<true>
  120. , dtl::bi::size_type
  121. <typename allocator_traits_type::size_type>
  122. >::type container_type;
  123. typedef container_type type ;
  124. };
  125. } //namespace dtl {
  126. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  127. //! A list is a doubly linked list. That is, it is a Sequence that supports both
  128. //! forward and backward traversal, and (amortized) constant time insertion and
  129. //! removal of elements at the beginning or the end, or in the middle. Lists have
  130. //! the important property that insertion and splicing do not invalidate iterators
  131. //! to list elements, and that even removal invalidates only the iterators that point
  132. //! to the elements that are removed. The ordering of iterators may be changed
  133. //! (that is, list<T>::iterator might have a different predecessor or successor
  134. //! after a list operation than it did before), but the iterators themselves will
  135. //! not be invalidated or made to point to different elements unless that invalidation
  136. //! or mutation is explicit.
  137. //!
  138. //! \tparam T The type of object that is stored in the list
  139. //! \tparam Allocator The allocator used for all internal memory management, use void
  140. //! for the default allocator
  141. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  142. template <class T, class Allocator = void >
  143. #else
  144. template <class T, class Allocator>
  145. #endif
  146. class list
  147. : protected dtl::node_alloc_holder
  148. < typename real_allocator<T, Allocator>::type
  149. , typename dtl::intrusive_list_type<typename real_allocator<T, Allocator>::type>::type>
  150. {
  151. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  152. typedef typename real_allocator<T, Allocator>::type ValueAllocator;
  153. typedef typename
  154. dtl::intrusive_list_type<ValueAllocator>::type Icont;
  155. typedef dtl::node_alloc_holder<ValueAllocator, Icont> AllocHolder;
  156. typedef typename AllocHolder::NodePtr NodePtr;
  157. typedef typename AllocHolder::NodeAlloc NodeAlloc;
  158. typedef typename AllocHolder::ValAlloc ValAlloc;
  159. typedef typename AllocHolder::Node Node;
  160. typedef dtl::allocator_destroyer<NodeAlloc> Destroyer;
  161. typedef typename AllocHolder::alloc_version alloc_version;
  162. typedef boost::container::allocator_traits<ValueAllocator> allocator_traits_type;
  163. typedef boost::container::equal_to_value
  164. <typename allocator_traits_type::value_type> equal_to_value_type;
  165. BOOST_COPYABLE_AND_MOVABLE(list)
  166. typedef dtl::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
  167. typedef dtl::iterator_from_iiterator<typename Icont::iterator, true> const_iterator_impl;
  168. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  169. public:
  170. //////////////////////////////////////////////
  171. //
  172. // types
  173. //
  174. //////////////////////////////////////////////
  175. typedef T value_type;
  176. typedef typename ::boost::container::allocator_traits<ValueAllocator>::pointer pointer;
  177. typedef typename ::boost::container::allocator_traits<ValueAllocator>::const_pointer const_pointer;
  178. typedef typename ::boost::container::allocator_traits<ValueAllocator>::reference reference;
  179. typedef typename ::boost::container::allocator_traits<ValueAllocator>::const_reference const_reference;
  180. typedef typename ::boost::container::allocator_traits<ValueAllocator>::size_type size_type;
  181. typedef typename ::boost::container::allocator_traits<ValueAllocator>::difference_type difference_type;
  182. typedef ValueAllocator allocator_type;
  183. typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
  184. typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
  185. typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
  186. typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<iterator>) reverse_iterator;
  187. typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator;
  188. //////////////////////////////////////////////
  189. //
  190. // construct/copy/destroy
  191. //
  192. //////////////////////////////////////////////
  193. //! <b>Effects</b>: Default constructs a list.
  194. //!
  195. //! <b>Throws</b>: If allocator_type's default constructor throws.
  196. //!
  197. //! <b>Complexity</b>: Constant.
  198. list() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<ValueAllocator>::value)
  199. : AllocHolder()
  200. {}
  201. //! <b>Effects</b>: Constructs a list taking the allocator as parameter.
  202. //!
  203. //! <b>Throws</b>: Nothing
  204. //!
  205. //! <b>Complexity</b>: Constant.
  206. explicit list(const allocator_type &a) BOOST_NOEXCEPT_OR_NOTHROW
  207. : AllocHolder(a)
  208. {}
  209. //! <b>Effects</b>: Constructs a list
  210. //! and inserts n value-initialized value_types.
  211. //!
  212. //! <b>Throws</b>: If allocator_type's default constructor
  213. //! throws or T's default or copy constructor throws.
  214. //!
  215. //! <b>Complexity</b>: Linear to n.
  216. explicit list(size_type n)
  217. : AllocHolder(ValueAllocator())
  218. { this->resize(n); }
  219. //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
  220. //! and inserts n copies of value.
  221. //!
  222. //! <b>Throws</b>: If allocator_type's default constructor
  223. //! throws or T's default or copy constructor throws.
  224. //!
  225. //! <b>Complexity</b>: Linear to n.
  226. list(size_type n, const allocator_type &a)
  227. : AllocHolder(a)
  228. { this->resize(n); }
  229. //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
  230. //! and inserts n copies of value.
  231. //!
  232. //! <b>Throws</b>: If allocator_type's default constructor
  233. //! throws or T's default or copy constructor throws.
  234. //!
  235. //! <b>Complexity</b>: Linear to n.
  236. list(size_type n, const T& value, const ValueAllocator& a = ValueAllocator())
  237. : AllocHolder(a)
  238. { this->insert(this->cbegin(), n, value); }
  239. //! <b>Effects</b>: Copy constructs a list.
  240. //!
  241. //! <b>Postcondition</b>: x == *this.
  242. //!
  243. //! <b>Throws</b>: If allocator_type's default constructor throws.
  244. //!
  245. //! <b>Complexity</b>: Linear to the elements x contains.
  246. list(const list& x)
  247. : AllocHolder(x)
  248. { this->insert(this->cbegin(), x.begin(), x.end()); }
  249. //! <b>Effects</b>: Move constructor. Moves x's resources to *this.
  250. //!
  251. //! <b>Throws</b>: If allocator_type's copy constructor throws.
  252. //!
  253. //! <b>Complexity</b>: Constant.
  254. list(BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
  255. : AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
  256. {}
  257. //! <b>Effects</b>: Copy constructs a list using the specified allocator.
  258. //!
  259. //! <b>Postcondition</b>: x == *this.
  260. //!
  261. //! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
  262. //!
  263. //! <b>Complexity</b>: Linear to the elements x contains.
  264. list(const list& x, const allocator_type &a)
  265. : AllocHolder(a)
  266. { this->insert(this->cbegin(), x.begin(), x.end()); }
  267. //! <b>Effects</b>: Move constructor sing the specified allocator.
  268. //! Moves x's resources to *this.
  269. //!
  270. //! <b>Throws</b>: If allocation or value_type's copy constructor throws.
  271. //!
  272. //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
  273. list(BOOST_RV_REF(list) x, const allocator_type &a)
  274. : AllocHolder(a)
  275. {
  276. if(this->node_alloc() == x.node_alloc()){
  277. this->icont().swap(x.icont());
  278. }
  279. else{
  280. this->insert(this->cbegin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
  281. }
  282. }
  283. //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
  284. //! and inserts a copy of the range [first, last) in the list.
  285. //!
  286. //! <b>Throws</b>: If allocator_type's default constructor
  287. //! throws or T's constructor taking a dereferenced InIt throws.
  288. //!
  289. //! <b>Complexity</b>: Linear to the range [first, last).
  290. template <class InpIt>
  291. list(InpIt first, InpIt last, const ValueAllocator &a = ValueAllocator())
  292. : AllocHolder(a)
  293. { this->insert(this->cbegin(), first, last); }
  294. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  295. //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
  296. //! and inserts a copy of the range [il.begin(), il.end()) in the list.
  297. //!
  298. //! <b>Throws</b>: If allocator_type's default constructor
  299. //! throws or T's constructor taking a dereferenced
  300. //! std::initializer_list iterator throws.
  301. //!
  302. //! <b>Complexity</b>: Linear to the range [il.begin(), il.end()).
  303. list(std::initializer_list<value_type> il, const ValueAllocator &a = ValueAllocator())
  304. : AllocHolder(a)
  305. { this->insert(this->cbegin(), il.begin(), il.end()); }
  306. #endif
  307. //! <b>Effects</b>: Destroys the list. All stored values are destroyed
  308. //! and used memory is deallocated.
  309. //!
  310. //! <b>Throws</b>: Nothing.
  311. //!
  312. //! <b>Complexity</b>: Linear to the number of elements.
  313. BOOST_CONTAINER_FORCEINLINE ~list() BOOST_NOEXCEPT_OR_NOTHROW
  314. {} //AllocHolder clears the list
  315. //! <b>Effects</b>: Makes *this contain the same elements as x.
  316. //!
  317. //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
  318. //! of each of x's elements.
  319. //!
  320. //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
  321. //!
  322. //! <b>Complexity</b>: Linear to the number of elements in x.
  323. list& operator=(BOOST_COPY_ASSIGN_REF(list) x)
  324. {
  325. if (BOOST_LIKELY(this != &x)) {
  326. NodeAlloc &this_alloc = this->node_alloc();
  327. const NodeAlloc &x_alloc = x.node_alloc();
  328. dtl::bool_<allocator_traits_type::
  329. propagate_on_container_copy_assignment::value> flag;
  330. if(flag && this_alloc != x_alloc){
  331. this->clear();
  332. }
  333. this->AllocHolder::copy_assign_alloc(x);
  334. this->assign(x.begin(), x.end());
  335. }
  336. return *this;
  337. }
  338. //! <b>Effects</b>: Move assignment. All x's values are transferred to *this.
  339. //!
  340. //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
  341. //! before the function.
  342. //!
  343. //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
  344. //! is false and (allocation throws or value_type's move constructor throws)
  345. //!
  346. //! <b>Complexity</b>: Constant if allocator_traits_type::
  347. //! propagate_on_container_move_assignment is true or
  348. //! this->get>allocator() == x.get_allocator(). Linear otherwise.
  349. list& operator=(BOOST_RV_REF(list) x)
  350. BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
  351. || allocator_traits_type::is_always_equal::value)
  352. {
  353. if (BOOST_LIKELY(this != &x)) {
  354. NodeAlloc &this_alloc = this->node_alloc();
  355. NodeAlloc &x_alloc = x.node_alloc();
  356. const bool propagate_alloc = allocator_traits_type::
  357. propagate_on_container_move_assignment::value;
  358. const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal;
  359. //Resources can be transferred if both allocators are
  360. //going to be equal after this function (either propagated or already equal)
  361. if(propagate_alloc || allocators_equal){
  362. //Destroy
  363. this->clear();
  364. //Move allocator if needed
  365. this->AllocHolder::move_assign_alloc(x);
  366. //Obtain resources
  367. this->icont() = boost::move(x.icont());
  368. }
  369. //Else do a one by one move
  370. else{
  371. this->assign( boost::make_move_iterator(x.begin())
  372. , boost::make_move_iterator(x.end()));
  373. }
  374. }
  375. return *this;
  376. }
  377. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  378. //! <b>Effects</b>: Makes *this contain the same elements as il.
  379. //!
  380. //! <b>Postcondition</b>: this->size() == il.size(). *this contains a copy
  381. //! of each of x's elements.
  382. //!
  383. //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
  384. //!
  385. //! <b>Complexity</b>: Linear to the number of elements in x.
  386. BOOST_CONTAINER_FORCEINLINE list& operator=(std::initializer_list<value_type> il)
  387. {
  388. this->assign(il.begin(), il.end());
  389. return *this;
  390. }
  391. #endif
  392. //! <b>Effects</b>: Assigns the n copies of val to *this.
  393. //!
  394. //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
  395. //!
  396. //! <b>Complexity</b>: Linear to n.
  397. BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& val)
  398. {
  399. typedef constant_iterator<value_type, difference_type> cvalue_iterator;
  400. return this->assign(cvalue_iterator(val, n), cvalue_iterator());
  401. }
  402. //! <b>Effects</b>: Assigns the range [first, last) to *this.
  403. //!
  404. //! <b>Throws</b>: If memory allocation throws or
  405. //! T's constructor from dereferencing InpIt throws.
  406. //!
  407. //! <b>Complexity</b>: Linear to n.
  408. template <class InpIt>
  409. void assign(InpIt first, InpIt last
  410. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  411. , typename dtl::disable_if_convertible<InpIt, size_type>::type * = 0
  412. #endif
  413. )
  414. {
  415. iterator first1 = this->begin();
  416. const iterator last1 = this->end();
  417. for ( ; first1 != last1 && first != last; ++first1, ++first)
  418. *first1 = *first;
  419. if (first == last)
  420. this->erase(first1, last1);
  421. else{
  422. this->insert(last1, first, last);
  423. }
  424. }
  425. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  426. //! <b>Effects</b>: Assigns the range [il.begin(), il.end()) to *this.
  427. //!
  428. //! <b>Throws</b>: If memory allocation throws or
  429. //! T's constructor from dereferencing std::initializer_list iterator throws.
  430. //!
  431. //! <b>Complexity</b>: Linear to n.
  432. BOOST_CONTAINER_FORCEINLINE void assign(std::initializer_list<value_type> il)
  433. { this->assign(il.begin(), il.end()); }
  434. #endif
  435. //! <b>Effects</b>: Returns a copy of the internal allocator.
  436. //!
  437. //! <b>Throws</b>: If allocator's copy constructor throws.
  438. //!
  439. //! <b>Complexity</b>: Constant.
  440. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  441. allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
  442. { return allocator_type(this->node_alloc()); }
  443. //! <b>Effects</b>: Returns a reference to the internal allocator.
  444. //!
  445. //! <b>Throws</b>: Nothing
  446. //!
  447. //! <b>Complexity</b>: Constant.
  448. //!
  449. //! <b>Note</b>: Non-standard extension.
  450. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  451. stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
  452. { return this->node_alloc(); }
  453. //! <b>Effects</b>: Returns a reference to the internal allocator.
  454. //!
  455. //! <b>Throws</b>: Nothing
  456. //!
  457. //! <b>Complexity</b>: Constant.
  458. //!
  459. //! <b>Note</b>: Non-standard extension.
  460. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  461. const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
  462. { return this->node_alloc(); }
  463. //////////////////////////////////////////////
  464. //
  465. // iterators
  466. //
  467. //////////////////////////////////////////////
  468. //! <b>Effects</b>: Returns an iterator to the first element contained in the list.
  469. //!
  470. //! <b>Throws</b>: Nothing.
  471. //!
  472. //! <b>Complexity</b>: Constant.
  473. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  474. iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
  475. { return iterator(this->icont().begin()); }
  476. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
  477. //!
  478. //! <b>Throws</b>: Nothing.
  479. //!
  480. //! <b>Complexity</b>: Constant.
  481. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  482. const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
  483. { return this->cbegin(); }
  484. //! <b>Effects</b>: Returns an iterator to the end of the list.
  485. //!
  486. //! <b>Throws</b>: Nothing.
  487. //!
  488. //! <b>Complexity</b>: Constant.
  489. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  490. iterator end() BOOST_NOEXCEPT_OR_NOTHROW
  491. { return iterator(this->icont().end()); }
  492. //! <b>Effects</b>: Returns a const_iterator to the end of the list.
  493. //!
  494. //! <b>Throws</b>: Nothing.
  495. //!
  496. //! <b>Complexity</b>: Constant.
  497. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  498. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
  499. { return this->cend(); }
  500. //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
  501. //! of the reversed list.
  502. //!
  503. //! <b>Throws</b>: Nothing.
  504. //!
  505. //! <b>Complexity</b>: Constant.
  506. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  507. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW
  508. { return reverse_iterator(end()); }
  509. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  510. //! of the reversed list.
  511. //!
  512. //! <b>Throws</b>: Nothing.
  513. //!
  514. //! <b>Complexity</b>: Constant.
  515. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  516. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW
  517. { return this->crbegin(); }
  518. //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
  519. //! of the reversed list.
  520. //!
  521. //! <b>Throws</b>: Nothing.
  522. //!
  523. //! <b>Complexity</b>: Constant.
  524. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  525. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW
  526. { return reverse_iterator(begin()); }
  527. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  528. //! of the reversed list.
  529. //!
  530. //! <b>Throws</b>: Nothing.
  531. //!
  532. //! <b>Complexity</b>: Constant.
  533. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  534. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW
  535. { return this->crend(); }
  536. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
  537. //!
  538. //! <b>Throws</b>: Nothing.
  539. //!
  540. //! <b>Complexity</b>: Constant.
  541. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  542. const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
  543. { return const_iterator(this->non_const_icont().begin()); }
  544. //! <b>Effects</b>: Returns a const_iterator to the end of the list.
  545. //!
  546. //! <b>Throws</b>: Nothing.
  547. //!
  548. //! <b>Complexity</b>: Constant.
  549. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  550. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
  551. { return const_iterator(this->non_const_icont().end()); }
  552. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  553. //! of the reversed list.
  554. //!
  555. //! <b>Throws</b>: Nothing.
  556. //!
  557. //! <b>Complexity</b>: Constant.
  558. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  559. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW
  560. { return const_reverse_iterator(this->cend()); }
  561. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  562. //! of the reversed list.
  563. //!
  564. //! <b>Throws</b>: Nothing.
  565. //!
  566. //! <b>Complexity</b>: Constant.
  567. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  568. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW
  569. { return const_reverse_iterator(this->cbegin()); }
  570. //////////////////////////////////////////////
  571. //
  572. // capacity
  573. //
  574. //////////////////////////////////////////////
  575. //! <b>Effects</b>: Returns true if the list contains no elements.
  576. //!
  577. //! <b>Throws</b>: Nothing.
  578. //!
  579. //! <b>Complexity</b>: Constant.
  580. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  581. bool empty() const BOOST_NOEXCEPT_OR_NOTHROW
  582. { return !this->size(); }
  583. //! <b>Effects</b>: Returns the number of the elements contained in the list.
  584. //!
  585. //! <b>Throws</b>: Nothing.
  586. //!
  587. //! <b>Complexity</b>: Constant.
  588. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  589. size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
  590. { return this->icont().size(); }
  591. //! <b>Effects</b>: Returns the largest possible size of the list.
  592. //!
  593. //! <b>Throws</b>: Nothing.
  594. //!
  595. //! <b>Complexity</b>: Constant.
  596. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  597. size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW
  598. { return AllocHolder::max_size(); }
  599. //! <b>Effects</b>: Inserts or erases elements at the end such that
  600. //! the size becomes n. New elements are value initialized.
  601. //!
  602. //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
  603. //!
  604. //! <b>Complexity</b>: Linear to the difference between size() and new_size.
  605. void resize(size_type new_size)
  606. {
  607. if(!priv_try_shrink(new_size)){
  608. typedef value_init_construct_iterator<value_type, difference_type> value_init_iterator;
  609. this->insert(this->cend(), value_init_iterator(new_size - this->size()), value_init_iterator());
  610. }
  611. }
  612. //! <b>Effects</b>: Inserts or erases elements at the end such that
  613. //! the size becomes n. New elements are copy constructed from x.
  614. //!
  615. //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
  616. //!
  617. //! <b>Complexity</b>: Linear to the difference between size() and new_size.
  618. void resize(size_type new_size, const T& x)
  619. {
  620. if(!priv_try_shrink(new_size)){
  621. this->insert(this->cend(), new_size - this->size(), x);
  622. }
  623. }
  624. //////////////////////////////////////////////
  625. //
  626. // element access
  627. //
  628. //////////////////////////////////////////////
  629. //! <b>Requires</b>: !empty()
  630. //!
  631. //! <b>Effects</b>: Returns a reference to the first element
  632. //! from the beginning of the container.
  633. //!
  634. //! <b>Throws</b>: Nothing.
  635. //!
  636. //! <b>Complexity</b>: Constant.
  637. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  638. reference front() BOOST_NOEXCEPT_OR_NOTHROW
  639. {
  640. BOOST_ASSERT(!this->empty());
  641. return *this->begin();
  642. }
  643. //! <b>Requires</b>: !empty()
  644. //!
  645. //! <b>Effects</b>: Returns a const reference to the first element
  646. //! from the beginning of the container.
  647. //!
  648. //! <b>Throws</b>: Nothing.
  649. //!
  650. //! <b>Complexity</b>: Constant.
  651. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  652. const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW
  653. {
  654. BOOST_ASSERT(!this->empty());
  655. return *this->begin();
  656. }
  657. //! <b>Requires</b>: !empty()
  658. //!
  659. //! <b>Effects</b>: Returns a reference to the first element
  660. //! from the beginning of the container.
  661. //!
  662. //! <b>Throws</b>: Nothing.
  663. //!
  664. //! <b>Complexity</b>: Constant.
  665. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  666. reference back() BOOST_NOEXCEPT_OR_NOTHROW
  667. {
  668. BOOST_ASSERT(!this->empty());
  669. return *(--this->end());
  670. }
  671. //! <b>Requires</b>: !empty()
  672. //!
  673. //! <b>Effects</b>: Returns a const reference to the first element
  674. //! from the beginning of the container.
  675. //!
  676. //! <b>Throws</b>: Nothing.
  677. //!
  678. //! <b>Complexity</b>: Constant.
  679. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  680. const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW
  681. {
  682. BOOST_ASSERT(!this->empty());
  683. return *(--this->end());
  684. }
  685. //////////////////////////////////////////////
  686. //
  687. // modifiers
  688. //
  689. //////////////////////////////////////////////
  690. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  691. //! <b>Effects</b>: Inserts an object of type T constructed with
  692. //! std::forward<Args>(args)... in the end of the list.
  693. //!
  694. //! <b>Returns</b>: A reference to the created object.
  695. //!
  696. //! <b>Throws</b>: If memory allocation throws or
  697. //! T's in-place constructor throws.
  698. //!
  699. //! <b>Complexity</b>: Constant
  700. template <class... Args>
  701. reference emplace_back(BOOST_FWD_REF(Args)... args)
  702. { return *this->emplace(this->cend(), boost::forward<Args>(args)...); }
  703. //! <b>Effects</b>: Inserts an object of type T constructed with
  704. //! std::forward<Args>(args)... in the beginning of the list.
  705. //!
  706. //! <b>Returns</b>: A reference to the created object.
  707. //!
  708. //! <b>Throws</b>: If memory allocation throws or
  709. //! T's in-place constructor throws.
  710. //!
  711. //! <b>Complexity</b>: Constant
  712. template <class... Args>
  713. reference emplace_front(BOOST_FWD_REF(Args)... args)
  714. { return *this->emplace(this->cbegin(), boost::forward<Args>(args)...); }
  715. //! <b>Effects</b>: Inserts an object of type T constructed with
  716. //! std::forward<Args>(args)... before p.
  717. //!
  718. //! <b>Throws</b>: If memory allocation throws or
  719. //! T's in-place constructor throws.
  720. //!
  721. //! <b>Complexity</b>: Constant
  722. template <class... Args>
  723. iterator emplace(const_iterator position, BOOST_FWD_REF(Args)... args)
  724. {
  725. BOOST_ASSERT((priv_is_linked)(position));
  726. NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
  727. return iterator(this->icont().insert(position.get(), *pnode));
  728. }
  729. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  730. #define BOOST_CONTAINER_LIST_EMPLACE_CODE(N) \
  731. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  732. reference emplace_back(BOOST_MOVE_UREF##N)\
  733. { return *this->emplace(this->cend() BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  734. \
  735. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  736. reference emplace_front(BOOST_MOVE_UREF##N)\
  737. { return *this->emplace(this->cbegin() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);}\
  738. \
  739. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  740. iterator emplace(const_iterator position BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  741. {\
  742. BOOST_ASSERT(position == this->cend() || (--(++position) == position) );\
  743. NodePtr pnode (AllocHolder::create_node(BOOST_MOVE_FWD##N));\
  744. return iterator(this->icont().insert(position.get(), *pnode));\
  745. }\
  746. //
  747. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_LIST_EMPLACE_CODE)
  748. #undef BOOST_CONTAINER_LIST_EMPLACE_CODE
  749. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  750. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  751. //! <b>Effects</b>: Inserts a copy of x at the beginning of the list.
  752. //!
  753. //! <b>Throws</b>: If memory allocation throws or
  754. //! T's copy constructor throws.
  755. //!
  756. //! <b>Complexity</b>: Amortized constant time.
  757. void push_front(const T &x);
  758. //! <b>Effects</b>: Constructs a new element in the beginning of the list
  759. //! and moves the resources of x to this new element.
  760. //!
  761. //! <b>Throws</b>: If memory allocation throws.
  762. //!
  763. //! <b>Complexity</b>: Amortized constant time.
  764. void push_front(T &&x);
  765. #else
  766. BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
  767. #endif
  768. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  769. //! <b>Effects</b>: Inserts a copy of x at the end of the list.
  770. //!
  771. //! <b>Throws</b>: If memory allocation throws or
  772. //! T's copy constructor throws.
  773. //!
  774. //! <b>Complexity</b>: Amortized constant time.
  775. void push_back(const T &x);
  776. //! <b>Effects</b>: Constructs a new element in the end of the list
  777. //! and moves the resources of x to this new element.
  778. //!
  779. //! <b>Throws</b>: If memory allocation throws.
  780. //!
  781. //! <b>Complexity</b>: Amortized constant time.
  782. void push_back(T &&x);
  783. #else
  784. BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
  785. #endif
  786. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  787. //! <b>Requires</b>: p must be a valid iterator of *this.
  788. //!
  789. //! <b>Effects</b>: Insert a copy of x before p.
  790. //!
  791. //! <b>Returns</b>: an iterator to the inserted element.
  792. //!
  793. //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
  794. //!
  795. //! <b>Complexity</b>: Amortized constant time.
  796. iterator insert(const_iterator p, const T &x);
  797. //! <b>Requires</b>: p must be a valid iterator of *this.
  798. //!
  799. //! <b>Effects</b>: Insert a new element before p with x's resources.
  800. //!
  801. //! <b>Returns</b>: an iterator to the inserted element.
  802. //!
  803. //! <b>Throws</b>: If memory allocation throws.
  804. //!
  805. //! <b>Complexity</b>: Amortized constant time.
  806. iterator insert(const_iterator p, T &&x);
  807. #else
  808. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator)
  809. #endif
  810. //! <b>Requires</b>: p must be a valid iterator of *this.
  811. //!
  812. //! <b>Effects</b>: Inserts n copies of x before p.
  813. //!
  814. //! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
  815. //!
  816. //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
  817. //!
  818. //! <b>Complexity</b>: Linear to n.
  819. iterator insert(const_iterator position, size_type n, const T& x)
  820. {
  821. //range check is done by insert
  822. typedef constant_iterator<value_type, difference_type> cvalue_iterator;
  823. return this->insert(position, cvalue_iterator(x, n), cvalue_iterator());
  824. }
  825. //! <b>Requires</b>: p must be a valid iterator of *this.
  826. //!
  827. //! <b>Effects</b>: Insert a copy of the [first, last) range before p.
  828. //!
  829. //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
  830. //!
  831. //! <b>Throws</b>: If memory allocation throws, T's constructor from a
  832. //! dereferenced InpIt throws.
  833. //!
  834. //! <b>Complexity</b>: Linear to distance [first, last).
  835. template <class InpIt>
  836. iterator insert(const_iterator p, InpIt first, InpIt last
  837. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  838. , typename dtl::enable_if_c
  839. < !dtl::is_convertible<InpIt, size_type>::value
  840. && (dtl::is_input_iterator<InpIt>::value
  841. || dtl::is_same<alloc_version, version_1>::value
  842. )
  843. >::type * = 0
  844. #endif
  845. )
  846. {
  847. BOOST_ASSERT((priv_is_linked)(p));
  848. const typename Icont::iterator ipos(p.get());
  849. iterator ret_it(ipos);
  850. if(first != last){
  851. ret_it = iterator(this->icont().insert(ipos, *this->create_node_from_it(first)));
  852. ++first;
  853. }
  854. for (; first != last; ++first){
  855. this->icont().insert(ipos, *this->create_node_from_it(first));
  856. }
  857. return ret_it;
  858. }
  859. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  860. template <class FwdIt>
  861. iterator insert(const_iterator position, FwdIt first, FwdIt last
  862. , typename dtl::enable_if_c
  863. < !dtl::is_convertible<FwdIt, size_type>::value
  864. && !(dtl::is_input_iterator<FwdIt>::value
  865. || dtl::is_same<alloc_version, version_1>::value
  866. )
  867. >::type * = 0
  868. )
  869. {
  870. BOOST_ASSERT((priv_is_linked)(position));
  871. //Optimized allocation and construction
  872. insertion_functor func(this->icont(), position.get());
  873. iterator before_p(position.get());
  874. --before_p;
  875. this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
  876. return ++before_p;
  877. }
  878. #endif
  879. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  880. //! <b>Requires</b>: p must be a valid iterator of *this.
  881. //!
  882. //! <b>Effects</b>: Insert a copy of the [il.begin(), il.end()) range before p.
  883. //!
  884. //! <b>Returns</b>: an iterator to the first inserted element or p if if.begin() == il.end().
  885. //!
  886. //! <b>Throws</b>: If memory allocation throws, T's constructor from a
  887. //! dereferenced std::initializer_list iterator throws.
  888. //!
  889. //! <b>Complexity</b>: Linear to distance [il.begin(), il.end()).
  890. iterator insert(const_iterator p, std::initializer_list<value_type> il)
  891. {
  892. //position range check is done by insert()
  893. return insert(p, il.begin(), il.end());
  894. }
  895. #endif
  896. //! <b>Effects</b>: Removes the first element from the list.
  897. //!
  898. //! <b>Throws</b>: Nothing.
  899. //!
  900. //! <b>Complexity</b>: Amortized constant time.
  901. void pop_front() BOOST_NOEXCEPT_OR_NOTHROW
  902. {
  903. BOOST_ASSERT(!this->empty());
  904. this->erase(this->cbegin());
  905. }
  906. //! <b>Effects</b>: Removes the last element from the list.
  907. //!
  908. //! <b>Throws</b>: Nothing.
  909. //!
  910. //! <b>Complexity</b>: Amortized constant time.
  911. void pop_back() BOOST_NOEXCEPT_OR_NOTHROW
  912. {
  913. BOOST_ASSERT(!this->empty());
  914. const_iterator tmp = this->cend();
  915. this->erase(--tmp);
  916. }
  917. //! <b>Requires</b>: p must be a valid iterator of *this.
  918. //!
  919. //! <b>Effects</b>: Erases the element at p.
  920. //!
  921. //! <b>Throws</b>: Nothing.
  922. //!
  923. //! <b>Complexity</b>: Amortized constant time.
  924. iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
  925. {
  926. BOOST_ASSERT(p != this->cend() && (priv_is_linked)(p));
  927. return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc())));
  928. }
  929. //! <b>Requires</b>: first and last must be valid iterator to elements in *this.
  930. //!
  931. //! <b>Effects</b>: Erases the elements pointed by [first, last).
  932. //!
  933. //! <b>Throws</b>: Nothing.
  934. //!
  935. //! <b>Complexity</b>: Linear to the distance between first and last.
  936. iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
  937. {
  938. BOOST_ASSERT(first == last || (first != this->cend() && (priv_is_linked)(first)));
  939. BOOST_ASSERT(first == last || (priv_is_linked)(last));
  940. return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version()));
  941. }
  942. //! <b>Effects</b>: Swaps the contents of *this and x.
  943. //!
  944. //! <b>Throws</b>: Nothing.
  945. //!
  946. //! <b>Complexity</b>: Constant.
  947. void swap(list& x)
  948. BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_swap::value
  949. || allocator_traits_type::is_always_equal::value)
  950. {
  951. BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value ||
  952. allocator_traits_type::is_always_equal::value ||
  953. this->get_stored_allocator() == x.get_stored_allocator());
  954. AllocHolder::swap(x);
  955. }
  956. //! <b>Effects</b>: Erases all the elements of the list.
  957. //!
  958. //! <b>Throws</b>: Nothing.
  959. //!
  960. //! <b>Complexity</b>: Linear to the number of elements in the list.
  961. void clear() BOOST_NOEXCEPT_OR_NOTHROW
  962. { AllocHolder::clear(alloc_version()); }
  963. //////////////////////////////////////////////
  964. //
  965. // slist operations
  966. //
  967. //////////////////////////////////////////////
  968. //! <b>Requires</b>: p must point to an element contained
  969. //! by the list. x != *this. this' allocator and x's allocator shall compare equal
  970. //!
  971. //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
  972. //! the element pointed by p. No destructors or copy constructors are called.
  973. //!
  974. //! <b>Throws</b>: Nothing
  975. //!
  976. //! <b>Complexity</b>: Constant.
  977. //!
  978. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
  979. //! this list. Iterators of this list and all the references are not invalidated.
  980. void splice(const_iterator p, list& x) BOOST_NOEXCEPT_OR_NOTHROW
  981. {
  982. BOOST_ASSERT((priv_is_linked)(p));
  983. BOOST_ASSERT(this != &x);
  984. BOOST_ASSERT(this->node_alloc() == x.node_alloc());
  985. this->icont().splice(p.get(), x.icont());
  986. }
  987. //! <b>Requires</b>: p must point to an element contained
  988. //! by the list. x != *this. this' allocator and x's allocator shall compare equal
  989. //!
  990. //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
  991. //! the element pointed by p. No destructors or copy constructors are called.
  992. //!
  993. //! <b>Throws</b>: Nothing
  994. //!
  995. //! <b>Complexity</b>: Constant.
  996. //!
  997. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
  998. //! this list. Iterators of this list and all the references are not invalidated.
  999. void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
  1000. {
  1001. //Checks done in splice
  1002. this->splice(p, static_cast<list&>(x));
  1003. }
  1004. //! <b>Requires</b>: p must point to an element contained
  1005. //! by this list. i must point to an element contained in list x.
  1006. //! this' allocator and x's allocator shall compare equal
  1007. //!
  1008. //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
  1009. //! before the element pointed by p. No destructors or copy constructors are called.
  1010. //! If p == i or p == ++i, this function is a null operation.
  1011. //!
  1012. //! <b>Throws</b>: Nothing
  1013. //!
  1014. //! <b>Complexity</b>: Constant.
  1015. //!
  1016. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
  1017. //! list. Iterators of this list and all the references are not invalidated.
  1018. void splice(const_iterator p, list &x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
  1019. {
  1020. BOOST_ASSERT((priv_is_linked)(p));
  1021. BOOST_ASSERT(this->node_alloc() == x.node_alloc());
  1022. this->icont().splice(p.get(), x.icont(), i.get());
  1023. }
  1024. //! <b>Requires</b>: p must point to an element contained
  1025. //! by this list. i must point to an element contained in list x.
  1026. //! this' allocator and x's allocator shall compare equal.
  1027. //!
  1028. //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
  1029. //! before the element pointed by p. No destructors or copy constructors are called.
  1030. //! If p == i or p == ++i, this function is a null operation.
  1031. //!
  1032. //! <b>Throws</b>: Nothing
  1033. //!
  1034. //! <b>Complexity</b>: Constant.
  1035. //!
  1036. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
  1037. //! list. Iterators of this list and all the references are not invalidated.
  1038. void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
  1039. {
  1040. BOOST_ASSERT(this != &x);
  1041. //Additional checks done in splice()
  1042. this->splice(p, static_cast<list&>(x), i);
  1043. }
  1044. //! <b>Requires</b>: p must point to an element contained
  1045. //! by this list. first and last must point to elements contained in list x.
  1046. //! this' allocator and x's allocator shall compare equal
  1047. //!
  1048. //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
  1049. //! before the element pointed by p. No destructors or copy constructors are called.
  1050. //!
  1051. //! <b>Throws</b>: Nothing
  1052. //!
  1053. //! <b>Complexity</b>: Linear to the number of elements transferred.
  1054. //!
  1055. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
  1056. //! list. Iterators of this list and all the references are not invalidated.
  1057. void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
  1058. {
  1059. BOOST_ASSERT((priv_is_linked)(p));
  1060. BOOST_ASSERT(first == last || (first != x.cend() && x.priv_is_linked(first)));
  1061. BOOST_ASSERT(first == last || x.priv_is_linked(last));
  1062. BOOST_ASSERT(this->node_alloc() == x.node_alloc());
  1063. this->icont().splice(p.get(), x.icont(), first.get(), last.get());
  1064. }
  1065. //! <b>Requires</b>: p must point to an element contained
  1066. //! by this list. first and last must point to elements contained in list x.
  1067. //! this' allocator and x's allocator shall compare equal.
  1068. //!
  1069. //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
  1070. //! before the element pointed by p. No destructors or copy constructors are called.
  1071. //!
  1072. //! <b>Throws</b>: Nothing
  1073. //!
  1074. //! <b>Complexity</b>: Linear to the number of elements transferred.
  1075. //!
  1076. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
  1077. //! list. Iterators of this list and all the references are not invalidated.
  1078. void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
  1079. {
  1080. BOOST_ASSERT(this != &x);
  1081. //Additional checks done in splice()
  1082. this->splice(p, static_cast<list&>(x), first, last);
  1083. }
  1084. //! <b>Requires</b>: p must point to an element contained
  1085. //! by this list. first and last must point to elements contained in list x.
  1086. //! n == distance(first, last). this' allocator and x's allocator shall compare equal
  1087. //!
  1088. //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
  1089. //! before the element pointed by p. No destructors or copy constructors are called.
  1090. //!
  1091. //! <b>Throws</b>: Nothing
  1092. //!
  1093. //! <b>Complexity</b>: Constant.
  1094. //!
  1095. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
  1096. //! list. Iterators of this list and all the references are not invalidated.
  1097. //!
  1098. //! <b>Note</b>: Non-standard extension
  1099. void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
  1100. {
  1101. BOOST_ASSERT(this->node_alloc() == x.node_alloc());
  1102. this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
  1103. }
  1104. //! <b>Requires</b>: p must point to an element contained
  1105. //! by this list. first and last must point to elements contained in list x.
  1106. //! n == distance(first, last). this' allocator and x's allocator shall compare equal
  1107. //!
  1108. //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
  1109. //! before the element pointed by p. No destructors or copy constructors are called.
  1110. //!
  1111. //! <b>Throws</b>: Nothing
  1112. //!
  1113. //! <b>Complexity</b>: Constant.
  1114. //!
  1115. //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
  1116. //! list. Iterators of this list and all the references are not invalidated.
  1117. //!
  1118. //! <b>Note</b>: Non-standard extension
  1119. void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
  1120. { this->splice(p, static_cast<list&>(x), first, last, n); }
  1121. //! <b>Effects</b>: Removes all the elements that compare equal to value.
  1122. //!
  1123. //! <b>Throws</b>: If comparison throws.
  1124. //!
  1125. //! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
  1126. //!
  1127. //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
  1128. //! and iterators to elements that are not removed remain valid.
  1129. void remove(const T& value)
  1130. { this->remove_if(equal_to_value_type(value)); }
  1131. //! <b>Effects</b>: Removes all the elements for which a specified
  1132. //! predicate is satisfied.
  1133. //!
  1134. //! <b>Throws</b>: If pred throws.
  1135. //!
  1136. //! <b>Complexity</b>: Linear time. It performs exactly size() calls to the predicate.
  1137. //!
  1138. //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
  1139. //! and iterators to elements that are not removed remain valid.
  1140. template <class Pred>
  1141. void remove_if(Pred pred)
  1142. {
  1143. typedef value_to_node_compare<Node, Pred> value_to_node_compare_type;
  1144. this->icont().remove_and_dispose_if(value_to_node_compare_type(pred), Destroyer(this->node_alloc()));
  1145. }
  1146. //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
  1147. //! elements that are equal from the list.
  1148. //!
  1149. //! <b>Throws</b>: If comparison throws.
  1150. //!
  1151. //! <b>Complexity</b>: Linear time (size()-1 comparisons equality comparisons).
  1152. //!
  1153. //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
  1154. //! and iterators to elements that are not removed remain valid.
  1155. void unique()
  1156. { this->unique(value_equal_t()); }
  1157. //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
  1158. //! elements that satisfy some binary predicate from the list.
  1159. //!
  1160. //! <b>Throws</b>: If pred throws.
  1161. //!
  1162. //! <b>Complexity</b>: Linear time (size()-1 comparisons calls to pred()).
  1163. //!
  1164. //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
  1165. //! and iterators to elements that are not removed remain valid.
  1166. template <class BinaryPredicate>
  1167. void unique(BinaryPredicate binary_pred)
  1168. {
  1169. typedef value_to_node_compare<Node, BinaryPredicate> value_to_node_compare_type;
  1170. this->icont().unique_and_dispose(value_to_node_compare_type(binary_pred), Destroyer(this->node_alloc()));
  1171. }
  1172. //! <b>Requires</b>: The lists x and *this must be distinct.
  1173. //!
  1174. //! <b>Effects</b>: This function removes all of x's elements and inserts them
  1175. //! in order into *this according to std::less<value_type>. The merge is stable;
  1176. //! that is, if an element from *this is equivalent to one from x, then the element
  1177. //! from *this will precede the one from x.
  1178. //!
  1179. //! <b>Throws</b>: If comparison throws.
  1180. //!
  1181. //! <b>Complexity</b>: This function is linear time: it performs at most
  1182. //! size() + x.size() - 1 comparisons.
  1183. void merge(list &x)
  1184. { this->merge(x, value_less_t()); }
  1185. //! <b>Requires</b>: The lists x and *this must be distinct.
  1186. //!
  1187. //! <b>Effects</b>: This function removes all of x's elements and inserts them
  1188. //! in order into *this according to std::less<value_type>. The merge is stable;
  1189. //! that is, if an element from *this is equivalent to one from x, then the element
  1190. //! from *this will precede the one from x.
  1191. //!
  1192. //! <b>Throws</b>: If comparison throws.
  1193. //!
  1194. //! <b>Complexity</b>: This function is linear time: it performs at most
  1195. //! size() + x.size() - 1 comparisons.
  1196. void merge(BOOST_RV_REF(list) x)
  1197. { this->merge(static_cast<list&>(x)); }
  1198. //! <b>Requires</b>: p must be a comparison function that induces a strict weak
  1199. //! ordering and both *this and x must be sorted according to that ordering
  1200. //! The lists x and *this must be distinct.
  1201. //!
  1202. //! <b>Effects</b>: This function removes all of x's elements and inserts them
  1203. //! in order into *this. The merge is stable; that is, if an element from *this is
  1204. //! equivalent to one from x, then the element from *this will precede the one from x.
  1205. //!
  1206. //! <b>Throws</b>: If comp throws.
  1207. //!
  1208. //! <b>Complexity</b>: This function is linear time: it performs at most
  1209. //! size() + x.size() - 1 comparisons.
  1210. //!
  1211. //! <b>Note</b>: Iterators and references to *this are not invalidated.
  1212. template <class StrictWeakOrdering>
  1213. void merge(list &x, const StrictWeakOrdering &comp)
  1214. {
  1215. BOOST_ASSERT(this->node_alloc() == x.node_alloc());
  1216. typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
  1217. this->icont().merge(x.icont(), value_to_node_compare_type(comp));
  1218. }
  1219. //! <b>Requires</b>: p must be a comparison function that induces a strict weak
  1220. //! ordering and both *this and x must be sorted according to that ordering
  1221. //! The lists x and *this must be distinct.
  1222. //!
  1223. //! <b>Effects</b>: This function removes all of x's elements and inserts them
  1224. //! in order into *this. The merge is stable; that is, if an element from *this is
  1225. //! equivalent to one from x, then the element from *this will precede the one from x.
  1226. //!
  1227. //! <b>Throws</b>: If comp throws.
  1228. //!
  1229. //! <b>Complexity</b>: This function is linear time: it performs at most
  1230. //! size() + x.size() - 1 comparisons.
  1231. //!
  1232. //! <b>Note</b>: Iterators and references to *this are not invalidated.
  1233. template <class StrictWeakOrdering>
  1234. void merge(BOOST_RV_REF(list) x, StrictWeakOrdering comp)
  1235. { this->merge(static_cast<list&>(x), comp); }
  1236. //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
  1237. //! The sort is stable, that is, the relative order of equivalent elements is preserved.
  1238. //!
  1239. //! <b>Throws</b>: If comparison throws.
  1240. //!
  1241. //! <b>Notes</b>: Iterators and references are not invalidated.
  1242. //!
  1243. //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
  1244. //! is the list's size.
  1245. void sort()
  1246. { this->sort(value_less_t()); }
  1247. //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
  1248. //! The sort is stable, that is, the relative order of equivalent elements is preserved.
  1249. //!
  1250. //! <b>Throws</b>: If comp throws.
  1251. //!
  1252. //! <b>Notes</b>: Iterators and references are not invalidated.
  1253. //!
  1254. //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
  1255. //! is the list's size.
  1256. template <class StrictWeakOrdering>
  1257. void sort(StrictWeakOrdering comp)
  1258. {
  1259. // nothing if the list has length 0 or 1.
  1260. if (this->size() < 2)
  1261. return;
  1262. typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
  1263. this->icont().sort(value_to_node_compare_type(comp));
  1264. }
  1265. //! <b>Effects</b>: Reverses the order of elements in the list.
  1266. //!
  1267. //! <b>Throws</b>: Nothing.
  1268. //!
  1269. //! <b>Complexity</b>: This function is linear time.
  1270. //!
  1271. //! <b>Note</b>: Iterators and references are not invalidated
  1272. void reverse() BOOST_NOEXCEPT_OR_NOTHROW
  1273. { this->icont().reverse(); }
  1274. //! <b>Effects</b>: Returns true if x and y are equal
  1275. //!
  1276. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1277. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  1278. friend bool operator==(const list& x, const list& y)
  1279. { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
  1280. //! <b>Effects</b>: Returns true if x and y are unequal
  1281. //!
  1282. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1283. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  1284. friend bool operator!=(const list& x, const list& y)
  1285. { return !(x == y); }
  1286. //! <b>Effects</b>: Returns true if x is less than y
  1287. //!
  1288. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1289. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  1290. friend bool operator<(const list& x, const list& y)
  1291. { return boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
  1292. //! <b>Effects</b>: Returns true if x is greater than y
  1293. //!
  1294. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1295. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  1296. friend bool operator>(const list& x, const list& y)
  1297. { return y < x; }
  1298. //! <b>Effects</b>: Returns true if x is equal or less than y
  1299. //!
  1300. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1301. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  1302. friend bool operator<=(const list& x, const list& y)
  1303. { return !(y < x); }
  1304. //! <b>Effects</b>: Returns true if x is equal or greater than y
  1305. //!
  1306. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1307. BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
  1308. friend bool operator>=(const list& x, const list& y)
  1309. { return !(x < y); }
  1310. //! <b>Effects</b>: x.swap(y)
  1311. //!
  1312. //! <b>Complexity</b>: Constant.
  1313. BOOST_CONTAINER_FORCEINLINE friend void swap(list& x, list& y)
  1314. BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)))
  1315. { x.swap(y); }
  1316. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1317. private:
  1318. static bool priv_is_linked(const_iterator const position)
  1319. {
  1320. const_iterator cur(position);
  1321. //This list is circular including end nodes
  1322. return (--(++cur)) == position && (++(--cur)) == position;
  1323. }
  1324. bool priv_try_shrink(size_type new_size)
  1325. {
  1326. const size_type len = this->size();
  1327. if(len > new_size){
  1328. const const_iterator iend = this->cend();
  1329. size_type to_erase = len - new_size;
  1330. const_iterator ifirst;
  1331. if(to_erase < len/2u){
  1332. ifirst = iend;
  1333. while(to_erase--){
  1334. --ifirst;
  1335. }
  1336. }
  1337. else{
  1338. ifirst = this->cbegin();
  1339. size_type to_skip = len - to_erase;
  1340. while(to_skip--){
  1341. ++ifirst;
  1342. }
  1343. }
  1344. this->erase(ifirst, iend);
  1345. return true;
  1346. }
  1347. else{
  1348. return false;
  1349. }
  1350. }
  1351. iterator priv_insert(const_iterator p, const T &x)
  1352. {
  1353. BOOST_ASSERT((priv_is_linked)(p));
  1354. NodePtr tmp = AllocHolder::create_node(x);
  1355. return iterator(this->icont().insert(p.get(), *tmp));
  1356. }
  1357. iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
  1358. {
  1359. BOOST_ASSERT((priv_is_linked)(p));
  1360. NodePtr tmp = AllocHolder::create_node(boost::move(x));
  1361. return iterator(this->icont().insert(p.get(), *tmp));
  1362. }
  1363. void priv_push_back (const T &x)
  1364. { this->insert(this->cend(), x); }
  1365. void priv_push_back (BOOST_RV_REF(T) x)
  1366. { this->insert(this->cend(), boost::move(x)); }
  1367. void priv_push_front (const T &x)
  1368. { this->insert(this->cbegin(), x); }
  1369. void priv_push_front (BOOST_RV_REF(T) x)
  1370. { this->insert(this->cbegin(), boost::move(x)); }
  1371. class insertion_functor;
  1372. friend class insertion_functor;
  1373. class insertion_functor
  1374. {
  1375. Icont &icont_;
  1376. typedef typename Icont::const_iterator iconst_iterator;
  1377. const iconst_iterator pos_;
  1378. public:
  1379. insertion_functor(Icont &icont, typename Icont::const_iterator pos)
  1380. : icont_(icont), pos_(pos)
  1381. {}
  1382. void operator()(Node &n)
  1383. {
  1384. this->icont_.insert(pos_, n);
  1385. }
  1386. };
  1387. typedef value_less<value_type> value_less_t;
  1388. typedef value_equal<value_type> value_equal_t;
  1389. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1390. };
  1391. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  1392. template <typename InputIterator>
  1393. list(InputIterator, InputIterator) ->
  1394. list<typename iterator_traits<InputIterator>::value_type>;
  1395. template <typename InputIterator, typename ValueAllocator>
  1396. list(InputIterator, InputIterator, ValueAllocator const&) ->
  1397. list<typename iterator_traits<InputIterator>::value_type, ValueAllocator>;
  1398. #endif
  1399. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1400. } //namespace container {
  1401. //!has_trivial_destructor_after_move<> == true_type
  1402. //!specialization for optimizations
  1403. template <class T, class Allocator>
  1404. struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> >
  1405. {
  1406. typedef typename boost::container::list<T, Allocator>::allocator_type allocator_type;
  1407. typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
  1408. static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
  1409. ::boost::has_trivial_destructor_after_move<pointer>::value;
  1410. };
  1411. namespace container {
  1412. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1413. }}
  1414. #include <boost/container/detail/config_end.hpp>
  1415. #endif // BOOST_CONTAINER_LIST_HPP