12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511 |
- #ifndef BOOST_CONTAINER_LIST_HPP
- #define BOOST_CONTAINER_LIST_HPP
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #include <boost/container/detail/config_begin.hpp>
- #include <boost/container/detail/workaround.hpp>
- #include <boost/container/container_fwd.hpp>
- #include <boost/container/new_allocator.hpp> //new_allocator
- #include <boost/container/throw_exception.hpp>
- #include <boost/container/detail/algorithm.hpp>
- #include <boost/container/detail/compare_functors.hpp>
- #include <boost/container/detail/iterator.hpp>
- #include <boost/container/detail/iterators.hpp>
- #include <boost/container/detail/mpl.hpp>
- #include <boost/container/detail/node_alloc_holder.hpp>
- #include <boost/container/detail/version_type.hpp>
- #include <boost/container/detail/value_functors.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/move/iterator.hpp>
- #include <boost/move/traits.hpp>
- #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
- # include <boost/move/detail/fwd_macros.hpp>
- #endif
- #include <boost/move/detail/move_helpers.hpp>
- #include <boost/move/detail/force_ptr.hpp>
- #include <boost/intrusive/pointer_traits.hpp>
- #include <boost/intrusive/list.hpp>
- #include <boost/assert.hpp>
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
- #include <initializer_list>
- #endif
- namespace boost {
- namespace container {
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- namespace dtl {
- template<class VoidPointer>
- struct list_hook
- {
- typedef typename dtl::bi::make_list_base_hook
- <dtl::bi::void_pointer<VoidPointer>, dtl::bi::link_mode<dtl::bi::normal_link> >::type type;
- };
- template <class T, class VoidPointer>
- struct iiterator_node_value_type< base_node<T, list_hook<VoidPointer> > >
- {
- typedef T type;
- };
- template<class Allocator>
- struct intrusive_list_type
- {
- typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
- typedef typename allocator_traits_type::value_type value_type;
- typedef typename boost::intrusive::pointer_traits
- <typename allocator_traits_type::pointer>::template
- rebind_pointer<void>::type
- void_pointer;
- typedef base_node<value_type, list_hook<void_pointer> > node_type;
- typedef typename dtl::bi::make_list
- < node_type
- , dtl::bi::base_hook<typename list_hook<void_pointer>::type>
- , dtl::bi::constant_time_size<true>
- , dtl::bi::size_type
- <typename allocator_traits_type::size_type>
- >::type container_type;
- typedef container_type type ;
- };
- }
- #endif
- #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
- template <class T, class Allocator = void >
- #else
- template <class T, class Allocator>
- #endif
- class list
- : protected dtl::node_alloc_holder
- < typename real_allocator<T, Allocator>::type
- , typename dtl::intrusive_list_type<typename real_allocator<T, Allocator>::type>::type>
- {
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- typedef typename real_allocator<T, Allocator>::type ValueAllocator;
- typedef typename
- dtl::intrusive_list_type<ValueAllocator>::type Icont;
- typedef dtl::node_alloc_holder<ValueAllocator, Icont> AllocHolder;
- typedef typename AllocHolder::NodePtr NodePtr;
- typedef typename AllocHolder::NodeAlloc NodeAlloc;
- typedef typename AllocHolder::ValAlloc ValAlloc;
- typedef typename AllocHolder::Node Node;
- typedef dtl::allocator_node_destroyer<NodeAlloc> Destroyer;
- typedef typename AllocHolder::alloc_version alloc_version;
- typedef boost::container::allocator_traits<ValueAllocator> allocator_traits_type;
- typedef boost::container::equal_to_value
- <typename allocator_traits_type::value_type> equal_to_value_type;
- BOOST_COPYABLE_AND_MOVABLE(list)
- typedef dtl::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
- typedef dtl::iterator_from_iiterator<typename Icont::iterator, true> const_iterator_impl;
- #endif
- public:
-
-
-
-
-
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::reference reference;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::difference_type difference_type;
- typedef ValueAllocator allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
- typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
- typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator;
-
-
-
-
-
-
-
-
-
-
- list() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<ValueAllocator>::value)
- : AllocHolder()
- {}
-
-
-
-
-
- explicit list(const allocator_type &a) BOOST_NOEXCEPT_OR_NOTHROW
- : AllocHolder(a)
- {}
-
-
-
-
-
-
-
- explicit list(size_type n)
- : AllocHolder(ValueAllocator())
- { this->resize(n); }
-
-
-
-
-
-
-
- list(size_type n, const allocator_type &a)
- : AllocHolder(a)
- { this->resize(n); }
-
-
-
-
-
-
-
- list(size_type n, const T& value, const ValueAllocator& a = ValueAllocator())
- : AllocHolder(a)
- { this->insert(this->cbegin(), n, value); }
-
-
-
-
-
-
-
- list(const list& x)
- : AllocHolder(x)
- { this->insert(this->cbegin(), x.begin(), x.end()); }
-
-
-
-
-
- list(BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
- : AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
- {}
-
-
-
-
-
-
-
- list(const list& x, const allocator_type &a)
- : AllocHolder(a)
- { this->insert(this->cbegin(), x.begin(), x.end()); }
-
-
-
-
-
-
- list(BOOST_RV_REF(list) x, const allocator_type &a)
- : AllocHolder(a)
- {
- if(this->node_alloc() == x.node_alloc()){
- this->icont().swap(x.icont());
- }
- else{
- this->insert(this->cbegin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
- }
- }
-
-
-
-
-
-
-
- template <class InpIt>
- list(InpIt first, InpIt last, const ValueAllocator &a = ValueAllocator())
- : AllocHolder(a)
- { this->insert(this->cbegin(), first, last); }
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
-
-
- list(std::initializer_list<value_type> il, const ValueAllocator &a = ValueAllocator())
- : AllocHolder(a)
- { this->insert(this->cbegin(), il.begin(), il.end()); }
- #endif
-
-
-
-
-
-
- BOOST_CONTAINER_FORCEINLINE ~list() BOOST_NOEXCEPT_OR_NOTHROW
- {}
-
-
-
-
-
-
-
-
- list& operator=(BOOST_COPY_ASSIGN_REF(list) x)
- {
- if (BOOST_LIKELY(this != &x)) {
- NodeAlloc &this_alloc = this->node_alloc();
- const NodeAlloc &x_alloc = x.node_alloc();
- dtl::bool_<allocator_traits_type::
- propagate_on_container_copy_assignment::value> flag;
- if(flag && this_alloc != x_alloc){
- this->clear();
- }
- this->AllocHolder::copy_assign_alloc(x);
- this->assign(x.begin(), x.end());
- }
- return *this;
- }
-
-
-
-
-
-
-
-
-
-
-
- list& operator=(BOOST_RV_REF(list) x)
- BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
- || allocator_traits_type::is_always_equal::value)
- {
- if (BOOST_LIKELY(this != &x)) {
- NodeAlloc &this_alloc = this->node_alloc();
- NodeAlloc &x_alloc = x.node_alloc();
- const bool propagate_alloc = allocator_traits_type::
- propagate_on_container_move_assignment::value;
- const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal;
-
-
- if(propagate_alloc || allocators_equal){
-
- this->clear();
-
- this->AllocHolder::move_assign_alloc(x);
-
- this->icont() = boost::move(x.icont());
- }
-
- else{
- this->assign( boost::make_move_iterator(x.begin())
- , boost::make_move_iterator(x.end()));
- }
- }
- return *this;
- }
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_FORCEINLINE list& operator=(std::initializer_list<value_type> il)
- {
- this->assign(il.begin(), il.end());
- return *this;
- }
- #endif
-
-
-
-
-
- BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& val)
- {
- typedef constant_iterator<value_type> cvalue_iterator;
- return this->assign(cvalue_iterator(val, n), cvalue_iterator());
- }
-
-
-
-
-
-
- template <class InpIt>
- void assign(InpIt first, InpIt last
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- , typename dtl::disable_if_convertible<InpIt, size_type>::type * = 0
- #endif
- )
- {
- iterator first1 = this->begin();
- const iterator last1 = this->end();
- for ( ; first1 != last1 && first != last; ++first1, ++first)
- *first1 = *first;
- if (first == last)
- this->erase(first1, last1);
- else{
- this->insert(last1, first, last);
- }
- }
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
- BOOST_CONTAINER_FORCEINLINE void assign(std::initializer_list<value_type> il)
- { this->assign(il.begin(), il.end()); }
- #endif
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
- { return allocator_type(this->node_alloc()); }
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
- { return this->node_alloc(); }
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->node_alloc(); }
-
-
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
- { return iterator(this->icont().begin()); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->cbegin(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- iterator end() BOOST_NOEXCEPT_OR_NOTHROW
- { return iterator(this->icont().end()); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->cend(); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW
- { return reverse_iterator(end()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->crbegin(); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW
- { return reverse_iterator(begin()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->crend(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_iterator(this->non_const_icont().begin()); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_iterator(this->non_const_icont().end()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_reverse_iterator(this->cend()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_reverse_iterator(this->cbegin()); }
-
-
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- bool empty() const BOOST_NOEXCEPT_OR_NOTHROW
- { return !this->size(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->icont().size(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW
- { return AllocHolder::max_size(); }
-
-
-
-
-
-
- void resize(size_type new_size)
- {
- if(!priv_try_shrink(new_size)){
- typedef value_init_construct_iterator<value_type> value_init_iterator;
- this->insert(this->cend(), value_init_iterator(new_size - this->size()), value_init_iterator());
- }
- }
-
-
-
-
-
-
- void resize(size_type new_size, const T& x)
- {
- if(!priv_try_shrink(new_size)){
- this->insert(this->cend(), new_size - this->size(), x);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- reference front() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *this->begin();
- }
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *this->begin();
- }
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- reference back() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *(--this->end());
- }
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *(--this->end());
- }
-
-
-
-
-
- #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
-
-
-
- template <class... Args>
- reference emplace_back(BOOST_FWD_REF(Args)... args)
- { return *this->emplace(this->cend(), boost::forward<Args>(args)...); }
-
-
-
-
-
-
-
-
-
- template <class... Args>
- reference emplace_front(BOOST_FWD_REF(Args)... args)
- { return *this->emplace(this->cbegin(), boost::forward<Args>(args)...); }
-
-
-
-
-
-
-
- template <class... Args>
- iterator emplace(const_iterator position, BOOST_FWD_REF(Args)... args)
- {
- BOOST_ASSERT((priv_is_linked)(position));
- NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
- return iterator(this->icont().insert(position.get(), *pnode));
- }
- #else
- #define BOOST_CONTAINER_LIST_EMPLACE_CODE(N) \
- BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- reference emplace_back(BOOST_MOVE_UREF##N)\
- { return *this->emplace(this->cend() BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
- \
- BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- reference emplace_front(BOOST_MOVE_UREF##N)\
- { return *this->emplace(this->cbegin() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);}\
- \
- BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- iterator emplace(const_iterator position BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
- {\
- BOOST_ASSERT(position == this->cend() || (--(++position) == position) );\
- NodePtr pnode (AllocHolder::create_node(BOOST_MOVE_FWD##N));\
- return iterator(this->icont().insert(position.get(), *pnode));\
- }\
-
- BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_LIST_EMPLACE_CODE)
- #undef BOOST_CONTAINER_LIST_EMPLACE_CODE
- #endif
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
- void push_front(const T &x);
-
-
-
-
-
-
- void push_front(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
- #endif
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
- void push_back(const T &x);
-
-
-
-
-
-
- void push_back(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
- #endif
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, const T &x);
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator)
- #endif
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator position, size_type n, const T& x)
- {
-
- typedef constant_iterator<value_type> cvalue_iterator;
- return this->insert(position, cvalue_iterator(x, n), cvalue_iterator());
- }
-
-
-
-
-
-
-
-
-
-
- template <class InpIt>
- iterator insert(const_iterator p, InpIt first, InpIt last
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- , typename dtl::enable_if_c
- < !dtl::is_convertible<InpIt, size_type>::value
- && (dtl::is_input_iterator<InpIt>::value
- || dtl::is_same<alloc_version, version_1>::value
- )
- >::type * = 0
- #endif
- )
- {
- BOOST_ASSERT((priv_is_linked)(p));
- const typename Icont::iterator ipos(p.get());
- iterator ret_it(ipos);
- if(first != last){
- ret_it = iterator(this->icont().insert(ipos, *this->create_node_from_it(first)));
- ++first;
- }
- for (; first != last; ++first){
- this->icont().insert(ipos, *this->create_node_from_it(first));
- }
- return ret_it;
- }
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- template <class FwdIt>
- iterator insert(const_iterator position, FwdIt first, FwdIt last
- , typename dtl::enable_if_c
- < !dtl::is_convertible<FwdIt, size_type>::value
- && !(dtl::is_input_iterator<FwdIt>::value
- || dtl::is_same<alloc_version, version_1>::value
- )
- >::type * = 0
- )
- {
- BOOST_ASSERT((priv_is_linked)(position));
-
- insertion_functor func(this->icont(), position.get());
- iterator before_p(position.get());
- --before_p;
- this->allocate_many_and_construct(first, boost::container::iterator_udistance(first, last), func);
- return ++before_p;
- }
- #endif
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, std::initializer_list<value_type> il)
- {
-
- return insert(p, il.begin(), il.end());
- }
- #endif
-
-
-
-
-
- void pop_front() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- this->erase(this->cbegin());
- }
-
-
-
-
-
- void pop_back() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- const_iterator tmp = this->cend();
- this->erase(--tmp);
- }
-
-
-
-
-
-
-
- iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(p != this->cend() && (priv_is_linked)(p));
- return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc())));
- }
-
-
-
-
-
-
-
- iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(first == last || (first != this->cend() && (priv_is_linked)(first)));
- BOOST_ASSERT(first == last || (priv_is_linked)(last));
- return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version()));
- }
-
-
-
-
-
- void swap(list& x)
- BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_swap::value
- || allocator_traits_type::is_always_equal::value)
- {
- BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value ||
- allocator_traits_type::is_always_equal::value ||
- this->get_stored_allocator() == x.get_stored_allocator());
- AllocHolder::swap(x);
- }
-
-
-
-
-
- void clear() BOOST_NOEXCEPT_OR_NOTHROW
- { AllocHolder::clear(alloc_version()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list& x) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT((priv_is_linked)(p));
- BOOST_ASSERT(this != &x);
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont());
- }
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
- {
-
- this->splice(p, static_cast<list&>(x));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list &x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT((priv_is_linked)(p));
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont(), i.get());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(this != &x);
-
- this->splice(p, static_cast<list&>(x), i);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT((priv_is_linked)(p));
- BOOST_ASSERT(first == last || (first != x.cend() && x.priv_is_linked(first)));
- BOOST_ASSERT(first == last || x.priv_is_linked(last));
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont(), first.get(), last.get());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(this != &x);
-
- this->splice(p, static_cast<list&>(x), first, last);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
- { this->splice(p, static_cast<list&>(x), first, last, n); }
-
-
-
-
-
-
-
-
- void remove(const T& value)
- { this->remove_if(equal_to_value_type(value)); }
-
-
-
-
-
-
-
-
-
- template <class Pred>
- void remove_if(Pred pred)
- {
- typedef value_to_node_compare<Node, Pred> value_to_node_compare_type;
- this->icont().remove_and_dispose_if(value_to_node_compare_type(pred), Destroyer(this->node_alloc()));
- }
-
-
-
-
-
-
-
-
-
- void unique()
- { this->unique(value_equal_t()); }
-
-
-
-
-
-
-
-
-
- template <class BinaryPredicate>
- void unique(BinaryPredicate binary_pred)
- {
- typedef value_to_node_compare<Node, BinaryPredicate> value_to_node_compare_type;
- this->icont().unique_and_dispose(value_to_node_compare_type(binary_pred), Destroyer(this->node_alloc()));
- }
-
-
-
-
-
-
-
-
-
-
-
- void merge(list &x)
- { this->merge(x, value_less_t()); }
-
-
-
-
-
-
-
-
-
-
-
- void merge(BOOST_RV_REF(list) x)
- { this->merge(static_cast<list&>(x)); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class StrictWeakOrdering>
- void merge(list &x, const StrictWeakOrdering &comp)
- {
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
- this->icont().merge(x.icont(), value_to_node_compare_type(comp));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class StrictWeakOrdering>
- void merge(BOOST_RV_REF(list) x, StrictWeakOrdering comp)
- { this->merge(static_cast<list&>(x), comp); }
-
-
-
-
-
-
-
-
-
- void sort()
- { this->sort(value_less_t()); }
-
-
-
-
-
-
-
-
-
- template <class StrictWeakOrdering>
- void sort(StrictWeakOrdering comp)
- {
-
- if (this->size() < 2)
- return;
- typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
- this->icont().sort(value_to_node_compare_type(comp));
- }
-
-
-
-
-
-
-
- void reverse() BOOST_NOEXCEPT_OR_NOTHROW
- { this->icont().reverse(); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- friend bool operator==(const list& x, const list& y)
- { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- friend bool operator!=(const list& x, const list& y)
- { return !(x == y); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- friend bool operator<(const list& x, const list& y)
- { return boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- friend bool operator>(const list& x, const list& y)
- { return y < x; }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- friend bool operator<=(const list& x, const list& y)
- { return !(y < x); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
- friend bool operator>=(const list& x, const list& y)
- { return !(x < y); }
-
-
-
- BOOST_CONTAINER_FORCEINLINE friend void swap(list& x, list& y)
- BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)))
- { x.swap(y); }
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- private:
- static bool priv_is_linked(const_iterator const position)
- {
- const_iterator cur(position);
-
- return (--(++cur)) == position && (++(--cur)) == position;
- }
- bool priv_try_shrink(size_type new_size)
- {
- const size_type len = this->size();
- if(len > new_size){
- const const_iterator iend = this->cend();
- size_type to_erase = len - new_size;
- const_iterator ifirst;
- if(to_erase < len/2u){
- ifirst = iend;
- while(to_erase--){
- --ifirst;
- }
- }
- else{
- ifirst = this->cbegin();
- size_type to_skip = len - to_erase;
- while(to_skip--){
- ++ifirst;
- }
- }
- this->erase(ifirst, iend);
- return true;
- }
- else{
- return false;
- }
- }
- iterator priv_insert(const_iterator p, const T &x)
- {
- BOOST_ASSERT((priv_is_linked)(p));
- NodePtr tmp = AllocHolder::create_node(x);
- return iterator(this->icont().insert(p.get(), *tmp));
- }
- iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
- {
- BOOST_ASSERT((priv_is_linked)(p));
- NodePtr tmp = AllocHolder::create_node(boost::move(x));
- return iterator(this->icont().insert(p.get(), *tmp));
- }
- template<class U>
- void priv_push_back(BOOST_FWD_REF(U) x)
- { this->icont().push_back(*this->create_node(::boost::forward<U>(x))); }
- template<class U>
- void priv_push_front(BOOST_FWD_REF(U) x)
- { this->icont().push_front(*this->create_node(::boost::forward<U>(x))); }
- class insertion_functor;
- friend class insertion_functor;
- class insertion_functor
- {
- Icont &icont_;
- typedef typename Icont::const_iterator iconst_iterator;
- const iconst_iterator pos_;
- public:
- insertion_functor(Icont &icont, typename Icont::const_iterator pos)
- : icont_(icont), pos_(pos)
- {}
- void operator()(Node &n)
- {
- this->icont_.insert(pos_, n);
- }
- };
- typedef value_less<value_type> value_less_t;
- typedef value_equal<value_type> value_equal_t;
- #endif
- };
- #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
- template <typename InputIterator>
- list(InputIterator, InputIterator) ->
- list<typename iterator_traits<InputIterator>::value_type>;
- template <typename InputIterator, typename ValueAllocator>
- list(InputIterator, InputIterator, ValueAllocator const&) ->
- list<typename iterator_traits<InputIterator>::value_type, ValueAllocator>;
- #endif
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- }
- template <class T, class Allocator>
- struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> >
- {
- typedef typename boost::container::list<T, Allocator>::allocator_type allocator_type;
- typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
- static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
- ::boost::has_trivial_destructor_after_move<pointer>::value;
- };
- namespace container {
- #endif
- }}
- #include <boost/container/detail/config_end.hpp>
- #endif
|