11#ifndef INCLUDED_BSLSTL_LIST_CPP03
12#define INCLUDED_BSLSTL_LIST_CPP03
63#ifdef COMPILING_BSLSTL_LIST_H
87 template <
class LIST_VALUE,
class LIST_ALLOCATOR>
90 template <
class ITER_VALUE>
96 List_Node(
const List_Node&);
98 List_Node& operator=(
const List_Node&);
109#if defined(BSLS_LIBRARYFEATURES_STDCPP_LIBCSTD)
113template <
class VALUE>
115 public std::iterator<std::bidirectional_iterator_tag, VALUE> {
117template <
class VALUE>
124 typedef List_Iterator<NcType> NcIter;
125 typedef List_Node<NcType> Node;
131 template <
class LIST_VALUE,
class LIST_ALLOCATOR>
134 template <
class ITER_VALUE>
137 template <
class T1,
class T2>
138 friend bool operator==(List_Iterator<T1>, List_Iterator<T2>);
145 NcIter unconst()
const;
184#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
186 ~List_Iterator() =
default;
246template <
class T1,
class T2>
247bool operator==(List_Iterator<T1> lhs, List_Iterator<T2> rhs);
249#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
250template <
class T1,
class T2>
251bool operator!=(List_Iterator<T1> lhs, List_Iterator<T2> rhs);
271template <
class VALUE>
272struct List_DefaultLessThan {
278 bool operator()(
const VALUE& lhs,
const VALUE& rhs)
const;
292template <
class VALUE,
class ALLOCATOR>
293class List_AllocAndSizeWrapper :
public allocator_traits<ALLOCATOR>::
294 template rebind_traits<List_Node<VALUE> >::allocator_type {
297 typedef List_Node<VALUE> Node;
301 typedef typename allocator_traits<ALLOCATOR>::template rebind_traits<Node>
304 typedef typename AllocTraits::allocator_type NodeAlloc;
306 typedef typename AllocTraits::size_type size_type;
314 List_AllocAndSizeWrapper(
const List_AllocAndSizeWrapper&);
315 List_AllocAndSizeWrapper& operator=(
const List_AllocAndSizeWrapper&);
322 List_AllocAndSizeWrapper(
const NodeAlloc& basicAllocator,
337 const size_type&
size()
const;
341template <
class VALUE,
class ALLOCATOR>
352template <
class VALUE,
class ALLOCATOR>
353class List_NodeProctor {
356 typedef List_Node<VALUE> Node;
360 typedef typename allocator_traits<ALLOCATOR>::template rebind_traits<Node>
369 typedef typename AllocTraits::pointer NodePtr;
373 list<VALUE, ALLOCATOR> *d_list_p;
378 List_NodeProctor(
const List_NodeProctor&);
379 List_NodeProctor &operator=(
const List_NodeProctor&);
388 List_NodeProctor(list<VALUE, ALLOCATOR> *listPtr, NodePtr nodePtr);
411template <
class VALUE,
class ALLOCATOR = bsl::allocator<VALUE> >
417 typedef List_DefaultLessThan<VALUE> DefaultLessThan;
420 typedef List_Node<VALUE> Node;
423 typedef List_NodeProctor<VALUE, ALLOCATOR> NodeProctor;
426 typedef typename allocator_traits<ALLOCATOR>::template rebind_traits<Node>
430 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
434 typedef List_AllocAndSizeWrapper<VALUE, ALLOCATOR>
438 typedef typename AllocTraits::allocator_type NodeAlloc;
443 typedef typename AllocTraits::pointer NodePtr;
448 typedef const VALUE& const_reference;
449 typedef List_Iterator<VALUE> iterator;
450 typedef List_Iterator<const VALUE> const_iterator;
451 typedef typename allocator_traits<ALLOCATOR>::pointer
pointer;
452 typedef typename allocator_traits<ALLOCATOR>::const_pointer
455 typedef typename allocator_traits<ALLOCATOR>::size_type size_type;
456 typedef typename allocator_traits<ALLOCATOR>::difference_type
459 typedef ALLOCATOR allocator_type;
460 typedef bsl::reverse_iterator<iterator> reverse_iterator;
461 typedef bsl::reverse_iterator<const_iterator> const_reverse_iterator;
466 AllocAndSizeWrapper d_alloc_and_size;
469 friend class List_NodeProctor<VALUE, ALLOCATOR>;
475 NodeAlloc& allocatorImp();
480 NodePtr allocateNode();
486 void createSentinel();
492 void deleteNode(NodePtr node);
503 void freeNode(NodePtr node);
509 iterator insertNode(const_iterator position, NodePtr node);
515 void linkNodes(NodePtr prev, NodePtr next);
529 template <
class COMPARE>
530 NodePtr mergeImp(NodePtr node1,
539 void quickSwap(
list *other);
554 template <class COMPARE>
555 NodePtr sortImp(NodePtr *nodePtrPtr,
557 const COMPARE& comparator);
563 const NodeAlloc& allocatorImp() const;
567 NodePtr headNode() const;
571 const typename AllocTraits::size_type& sizeRef() const
585 explicit
list(const ALLOCATOR& basicAllocator);
595 explicit
list(size_type numElements);
605 list(size_type numElements,
606 const ALLOCATOR& basicAllocator);
620 list(size_type numElements,
622 const ALLOCATOR& basicAllocator = ALLOCATOR());
645 template <class INPUT_ITERATOR>
646 list(INPUT_ITERATOR first,
648 const ALLOCATOR& basicAllocator = ALLOCATOR(),
650 !is_arithmetic<INPUT_ITERATOR>::value &&
651 !is_enum<INPUT_ITERATOR>::value
653 : d_alloc_and_size(basicAllocator, size_type(-1))
664 list tmp(this->allocatorImp());
665 tmp.insert(tmp.cbegin(), first, last);
693 list(BloombergLP::bslmf::MovableRef<list> original);
705 list(BloombergLP::bslmf::MovableRef<list> original,
708#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
709 list(std::initializer_list<value_type> values,
710 const ALLOCATOR& basicAllocator = ALLOCATOR());
745 list& operator=(BloombergLP::bslmf::MovableRef<list> rhs)
747 AllocTraits::is_always_equal::value);
762#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
771 list& operator=(std::initializer_list<value_type> rhs);
788 template <
class INPUT_ITERATOR>
789 void assign(INPUT_ITERATOR first,
799 iterator dstIt = this->
begin();
800 const iterator dstEnd = this->
end();
802 for (; first != last && dstEnd != dstIt; ++first, ++dstIt) {
806 erase(dstIt, dstEnd);
808 for (; first != last; ++first) {
809 emplace(dstEnd, *first);
819#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
827 void assign(std::initializer_list<value_type> values);
854 void resize(size_type newSize);
863 void resize(size_type newSize, const
value_type& value);
895 iterator
erase(const_iterator position);
905 iterator
erase(const_iterator dstBegin, const_iterator dstEnd);
909#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
912#ifndef BSLSTL_LIST_VARIADIC_LIMIT
913#define BSLSTL_LIST_VARIADIC_LIMIT 10
915#ifndef BSLSTL_LIST_VARIADIC_LIMIT_A
916#define BSLSTL_LIST_VARIADIC_LIMIT_A BSLSTL_LIST_VARIADIC_LIMIT
918#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 0
923#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 1
924 template <
class ARGS_01>
929#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 2
930 template <
class ARGS_01,
937#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 3
938 template <
class ARGS_01,
947#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 4
948 template <
class ARGS_01,
959#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 5
960 template <
class ARGS_01,
973#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 6
974 template <
class ARGS_01,
989#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 7
990 template <
class ARGS_01,
1007#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 8
1008 template <
class ARGS_01,
1027#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 9
1028 template <
class ARGS_01,
1049#if BSLSTL_LIST_VARIADIC_LIMIT_A >= 10
1050 template <
class ARGS_01,
1076 template <
class... ARGS>
1082#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1085#ifndef BSLSTL_LIST_VARIADIC_LIMIT
1086#define BSLSTL_LIST_VARIADIC_LIMIT 10
1088#ifndef BSLSTL_LIST_VARIADIC_LIMIT_B
1089#define BSLSTL_LIST_VARIADIC_LIMIT_B BSLSTL_LIST_VARIADIC_LIMIT
1091#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 0
1096#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 1
1097 template <
class ARGS_01>
1102#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 2
1103 template <
class ARGS_01,
1110#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 3
1111 template <
class ARGS_01,
1120#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 4
1121 template <
class ARGS_01,
1132#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 5
1133 template <
class ARGS_01,
1146#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 6
1147 template <
class ARGS_01,
1162#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 7
1163 template <
class ARGS_01,
1180#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 8
1181 template <
class ARGS_01,
1200#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 9
1201 template <
class ARGS_01,
1222#if BSLSTL_LIST_VARIADIC_LIMIT_B >= 10
1223 template <
class ARGS_01,
1249 template <
class... ARGS>
1267 void push_back(BloombergLP::bslmf::MovableRef<value_type> value);
1281 void push_front(BloombergLP::bslmf::MovableRef<value_type> value);
1285#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1288#ifndef BSLSTL_LIST_VARIADIC_LIMIT
1289#define BSLSTL_LIST_VARIADIC_LIMIT 10
1291#ifndef BSLSTL_LIST_VARIADIC_LIMIT_C
1292#define BSLSTL_LIST_VARIADIC_LIMIT_C BSLSTL_LIST_VARIADIC_LIMIT
1294#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 0
1295 iterator emplace(const_iterator position);
1298#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 1
1299 template <
class ARGS_01>
1300 iterator emplace(const_iterator position,
1304#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 2
1305 template <
class ARGS_01,
1307 iterator emplace(const_iterator position,
1312#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 3
1313 template <
class ARGS_01,
1316 iterator emplace(const_iterator position,
1322#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 4
1323 template <
class ARGS_01,
1327 iterator emplace(const_iterator position,
1334#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 5
1335 template <
class ARGS_01,
1340 iterator emplace(const_iterator position,
1348#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 6
1349 template <
class ARGS_01,
1355 iterator emplace(const_iterator position,
1364#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 7
1365 template <
class ARGS_01,
1372 iterator emplace(const_iterator position,
1382#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 8
1383 template <
class ARGS_01,
1391 iterator emplace(const_iterator position,
1402#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 9
1403 template <
class ARGS_01,
1412 iterator emplace(const_iterator position,
1424#if BSLSTL_LIST_VARIADIC_LIMIT_C >= 10
1425 template <
class ARGS_01,
1435 iterator emplace(const_iterator position,
1451 template <
class... ARGS>
1452 iterator emplace(const_iterator position,
1466 iterator insert(const_iterator dstPosition,
const value_type& value);
1478 iterator insert(const_iterator dstPosition,
1479 BloombergLP::bslmf::MovableRef<value_type> value);
1489 iterator insert(const_iterator dstPosition,
1490 size_type numElements,
1508 template <
class INPUT_ITERATOR>
1509 iterator insert(const_iterator dstPosition,
1510 INPUT_ITERATOR first,
1511 INPUT_ITERATOR last,
1520 if (first == last) {
1521 return dstPosition.unconst();
1527 iterator ret = insert(dstPosition, *first);
1528 for (++first; first != last; ++first) {
1529 insert(dstPosition, *first);
1535#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1544 iterator insert(const_iterator dstPosition,
1545 std::initializer_list<value_type> values);
1550 void merge(
list& other);
1558 void merge(BloombergLP::bslmf::MovableRef<list> other);
1567 template <
class COMPARE>
1568 void merge(
list& other, COMPARE comparator);
1569 template <
class COMPARE>
1570 void merge(BloombergLP::bslmf::MovableRef<list> other, COMPARE comparator);
1578 template <
class PREDICATE>
1579 size_type remove_if(PREDICATE predicate);
1598 template <class COMPARE>
1599 void sort(COMPARE comparator);
1601 void splice(const_iterator dstPosition,
1608 void splice(const_iterator dstPosition,
1609 BloombergLP::
bslmf::MovableRef<
list> src);
1611 void splice(const_iterator dstPosition,
1613 const_iterator srcNode);
1622 void splice(const_iterator dstPosition,
1623 BloombergLP::
bslmf::MovableRef<
list> src,
1624 const_iterator srcNode);
1626 void splice(const_iterator dstPosition,
1628 const_iterator first,
1629 const_iterator last);
1640 void splice(const_iterator dstPosition,
1641 BloombergLP::
bslmf::MovableRef<
list> src,
1642 const_iterator first,
1643 const_iterator last);
1652 template <class EQ_PREDICATE>
1653 void unique(EQ_PREDICATE binaryPredicate);
1658 AllocTraits::is_always_equal::value);
1725 const_reference back() const;
1730 const_reference front() const;
1739#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1751 class = bsl::enable_if_t<
1752 bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>,
1753 class = bsl::enable_if_t<
1754 bsl::is_convertible_v<
1758list(SIZE_TYPE, VALUE, ALLOC *) -> list<VALUE>;
1763 class INPUT_ITERATOR,
1764 class VALUE =
typename
1765 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
1767list(INPUT_ITERATOR, INPUT_ITERATOR) -> list<VALUE>;
1775 class INPUT_ITERATOR,
1777 class VALUE =
typename
1778 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1779 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>>
1780list(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR) -> list<VALUE, ALLOCATOR>;
1787 class INPUT_ITERATOR,
1789 class VALUE =
typename
1790 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1792 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1794list(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1805 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1807list(std::initializer_list<VALUE>, ALLOC *)
1820template <
class VALUE,
class ALLOCATOR>
1821bool operator==(
const list<VALUE, ALLOCATOR>& lhs,
1822 const list<VALUE, ALLOCATOR>& rhs);
1824#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1826template <
class VALUE,
class ALLOCATOR>
1827bool operator!=(
const list<VALUE, ALLOCATOR>& lhs,
1828 const list<VALUE, ALLOCATOR>& rhs);
1840#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1845template <
class VALUE,
class ALLOCATOR>
1846BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE> operator<=>(
1847 const list<VALUE, ALLOCATOR>& lhs,
1848 const list<VALUE, ALLOCATOR>& rhs);
1852template <
class VALUE,
class ALLOCATOR>
1853bool operator< (
const list<VALUE, ALLOCATOR>& lhs,
1854 const list<VALUE, ALLOCATOR>& rhs);
1867template <
class VALUE,
class ALLOCATOR>
1868bool operator> (
const list<VALUE, ALLOCATOR>& lhs,
1869 const list<VALUE, ALLOCATOR>& rhs);
1878template <
class VALUE,
class ALLOCATOR>
1879bool operator<=(
const list<VALUE, ALLOCATOR>& lhs,
1880 const list<VALUE, ALLOCATOR>& rhs);
1889template <
class VALUE,
class ALLOCATOR>
1890bool operator>=(
const list<VALUE, ALLOCATOR>& lhs,
1891 const list<VALUE, ALLOCATOR>& rhs);
1906template <
class VALUE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
1907typename list<VALUE, ALLOCATOR>::size_type
1908erase(list<VALUE, ALLOCATOR>& l,
const BDE_OTHER_TYPE& value);
1912template <
class VALUE,
class ALLOCATOR,
class PREDICATE>
1913typename list<VALUE, ALLOCATOR>::size_type
1914erase_if(list<VALUE, ALLOCATOR>& l, PREDICATE predicate);
1916template <
class VALUE,
class ALLOCATOR>
1917void swap(list<VALUE, ALLOCATOR>& a, list<VALUE, ALLOCATOR>& b)
1943template <
class VALUE>
1945typename List_Iterator<VALUE>::NcIter List_Iterator<VALUE>::unconst()
const
1947 return NcIter(d_node_p);
1951template <
class VALUE>
1958template <
class VALUE>
1960List_Iterator<VALUE>::List_Iterator(Node *nodePtr)
1965template <
class VALUE>
1967List_Iterator<VALUE>::List_Iterator(
const NcIter& other)
1968: d_node_p(other.d_node_p)
1973template <
class VALUE>
1975List_Iterator<VALUE>& List_Iterator<VALUE>::operator++()
1977 this->d_node_p = this->d_node_p->d_next_p;
1981template <
class VALUE>
1983List_Iterator<VALUE>& List_Iterator<VALUE>::operator--()
1985 this->d_node_p = this->d_node_p->d_prev_p;
1989template <
class VALUE>
1991List_Iterator<VALUE> List_Iterator<VALUE>::operator++(
int)
1993 List_Iterator temp = *
this;
1998template <
class VALUE>
2000List_Iterator<VALUE> List_Iterator<VALUE>::operator--(
int)
2002 List_Iterator temp = *
this;
2008template <
class VALUE>
2011 List_Iterator<VALUE>::operator*()
const
2013 return this->d_node_p->d_value;
2016template <
class VALUE>
2019 List_Iterator<VALUE>::operator->()
const
2021 return BloombergLP::bsls::Util::addressOf(this->d_node_p->d_value);
2025template <
class T1,
class T2>
2035 return lhs.d_node_p == rhs.d_node_p;
2038#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2039template <
class T1,
class T2>
2049 return ! (lhs == rhs);
2058template <
class VALUE,
class ALLOCATOR>
2060List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::List_AllocAndSizeWrapper(
2061 const NodeAlloc& basicAllocator,
2063: NodeAlloc(basicAllocator)
2069template <
class VALUE,
class ALLOCATOR>
2071typename List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size_type&
2072List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size()
2078template <
class VALUE,
class ALLOCATOR>
2080const typename List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size_type&
2081List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size()
const
2091template <
class VALUE,
class ALLOCATOR>
2093List_NodeProctor<VALUE, ALLOCATOR>::List_NodeProctor(
2094 list<VALUE, ALLOCATOR> *listPtr,
2103template <
class VALUE,
class ALLOCATOR>
2105List_NodeProctor<VALUE, ALLOCATOR>::~List_NodeProctor()
2108 d_list_p->freeNode(d_node_p);
2113template <
class VALUE,
class ALLOCATOR>
2115void List_NodeProctor<VALUE, ALLOCATOR>::release()
2125template <
class VALUE>
2127bool List_DefaultLessThan<VALUE>::operator()(
2128 const VALUE& lhs,
const VALUE& rhs)
const
2138template <
class VALUE,
class ALLOCATOR>
2140typename list<VALUE, ALLOCATOR>::NodeAlloc&
2141 list<VALUE, ALLOCATOR>::allocatorImp()
2143 return d_alloc_and_size;
2146template <
class VALUE,
class ALLOCATOR>
2148typename list<VALUE, ALLOCATOR>::NodePtr list<VALUE, ALLOCATOR>::allocateNode()
2150 NodePtr ret = AllocTraits::allocate(allocatorImp(), 1);
2156template <
class VALUE,
class ALLOCATOR>
2158void list<VALUE, ALLOCATOR>::createSentinel()
2162 d_sentinel = allocateNode();
2163 linkNodes(d_sentinel, d_sentinel);
2167template <
class VALUE,
class ALLOCATOR>
2169void list<VALUE, ALLOCATOR>::deleteNode(NodePtr node)
2173 AllocTraits::destroy(allocatorImp(),
2174 BloombergLP::bsls::Util::addressOf(node->d_value));
2175 AllocTraits::deallocate(allocatorImp(), node, 1);
2178template <
class VALUE,
class ALLOCATOR>
2180void list<VALUE, ALLOCATOR>::destroyAll()
2183 freeNode(d_sentinel);
2184 sizeRef() = size_type(-1);
2187template <
class VALUE,
class ALLOCATOR>
2189void list<VALUE, ALLOCATOR>::freeNode(NodePtr node)
2191 AllocTraits::deallocate(allocatorImp(), node, 1);
2194template <
class VALUE,
class ALLOCATOR>
2196typename list<VALUE, ALLOCATOR>::iterator
2197list<VALUE, ALLOCATOR>::insertNode(const_iterator position, NodePtr node)
2199 NodePtr next = position.d_node_p;
2200 NodePtr prev = next->d_prev_p;
2201 linkNodes(prev, node);
2202 linkNodes(node, next);
2204 return iterator(node);
2207template <
class VALUE,
class ALLOCATOR>
2209void list<VALUE, ALLOCATOR>::linkNodes(NodePtr prev, NodePtr next)
2211 prev->d_next_p = next;
2212 next->d_prev_p = prev;
2215template <
class VALUE,
class ALLOCATOR>
2216template <
class COMPARE>
2217typename list<VALUE, ALLOCATOR>::NodePtr
2218list<VALUE, ALLOCATOR>::mergeImp(NodePtr node1,
2223 NodePtr pre = node1->d_prev_p;
2237 while (node1 != node2 && node2 != finish) {
2243 if (comparator(node2->d_value, node1->d_value)) {
2249 NodePtr lastMove = node2;
2250 NodePtr next2 = node2->d_next_p;
2251 while (next2 != finish && comparator(next2->d_value,
2254 next2 = lastMove->d_next_p;
2257 linkNodes(node2->d_prev_p, next2);
2258 linkNodes(node1->d_prev_p, node2);
2259 linkNodes(lastMove, node1);
2268 node1 = node1->d_next_p;
2272 return pre->d_next_p;
2275template <
class VALUE,
class ALLOCATOR>
2277void list<VALUE, ALLOCATOR>::quickSwap(list *other)
2283 swap(d_sentinel, other->d_sentinel);
2284 swap(sizeRef(), other->sizeRef());
2287template <
class VALUE,
class ALLOCATOR>
2289typename list<VALUE, ALLOCATOR>::AllocTraits::size_type&
2292 return d_alloc_and_size.size();
2295template <
class VALUE,
class ALLOCATOR>
2296template <
class COMPARE>
2297typename list<VALUE, ALLOCATOR>::NodePtr
2298list<VALUE, ALLOCATOR>::sortImp(NodePtr *nodePtrPtr,
2300 const COMPARE& comparator)
2304 NodePtr node1 = *nodePtrPtr;
2306 return node1->d_next_p;
2309 size_type half =
size / 2;
2311 NodePtr node2 = sortImp(&node1, half, comparator);
2312 NodePtr next = sortImp(&node2, size - half, comparator);
2314 *nodePtrPtr = mergeImp(node1, node2, next, comparator);
2319template <
class VALUE,
class ALLOCATOR>
2321const typename list<VALUE, ALLOCATOR>::NodeAlloc&
2322 list<VALUE, ALLOCATOR>::allocatorImp()
const
2324 return d_alloc_and_size;
2327template <
class VALUE,
class ALLOCATOR>
2329typename list<VALUE, ALLOCATOR>::NodePtr list<VALUE, ALLOCATOR>::headNode()
2332 return d_sentinel->d_next_p;
2335template <
class VALUE,
class ALLOCATOR>
2337const typename list<VALUE, ALLOCATOR>::AllocTraits::size_type&
2340 return d_alloc_and_size.size();
2344template <
class VALUE,
class ALLOCATOR>
2345list<VALUE, ALLOCATOR>::list()
2347, d_alloc_and_size(ALLOCATOR(), 0)
2350 typename AllocTraits::size_type>::value));
2352 typename AllocTraits::difference_type>::value));
2356template <
class VALUE,
class ALLOCATOR>
2357list<VALUE, ALLOCATOR>::list(
const ALLOCATOR& basicAllocator)
2359, d_alloc_and_size(basicAllocator, 0)
2364template <
class VALUE,
class ALLOCATOR>
2365list<VALUE, ALLOCATOR>::list(size_type numElements)
2367, d_alloc_and_size(ALLOCATOR(), size_type(-1))
2371 list tmp(this->allocatorImp());
2376 iterator pos = tmp.end();
2377 for (size_type i = 0; i < numElements; ++i) {
2384template <
class VALUE,
class ALLOCATOR>
2385list<VALUE, ALLOCATOR>::list(size_type numElements,
2386 const ALLOCATOR& basicAllocator)
2388, d_alloc_and_size(basicAllocator, size_type(-1))
2392 list tmp(this->allocatorImp());
2397 const_iterator pos = tmp.cend();
2398 for (size_type i = 0; i < numElements; ++i) {
2405template <
class VALUE,
class ALLOCATOR>
2406list<VALUE, ALLOCATOR>::list(size_type numElements,
2408 const ALLOCATOR& basicAllocator)
2410, d_alloc_and_size(basicAllocator, size_type(-1))
2414 list tmp(this->allocatorImp());
2415 tmp.insert(tmp.cbegin(), numElements, value);
2420template <
class VALUE,
class ALLOCATOR>
2421list<VALUE, ALLOCATOR>::list(
const list& original)
2424 AllocTraits::select_on_container_copy_construction(original.allocatorImp()),
2427 list tmp(this->allocatorImp());
2429 tmp.insert(tmp.cbegin(), original.begin(), original.end());
2434template <
class VALUE,
class ALLOCATOR>
2435list<VALUE, ALLOCATOR>::list(
const list& original,
2436 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2438, d_alloc_and_size(basicAllocator, size_type(-1))
2440 list tmp(this->allocatorImp());
2442 tmp.insert(tmp.cbegin(), original.begin(), original.end());
2447template <
class VALUE,
class ALLOCATOR>
2448list<VALUE, ALLOCATOR>::list(BloombergLP::bslmf::MovableRef<list> original)
2450, d_alloc_and_size(MoveUtil::access(original).allocatorImp(), 0)
2461 quickSwap(&MoveUtil::access(original));
2464template <
class VALUE,
class ALLOCATOR>
2465list<VALUE, ALLOCATOR>::list(
2466 BloombergLP::bslmf::MovableRef<list> original,
2467 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2469, d_alloc_and_size(basicAllocator, size_type(-1))
2473 list& lvalue = original;
2474 if (this->allocatorImp() == lvalue.allocatorImp()) {
2483 list tmp(this->allocatorImp());
2488 NodePtr endPtr = lvalue.d_sentinel;
2489 for (NodePtr p = lvalue.headNode(); endPtr != p; p = p->d_next_p) {
2490 tmp.emplace_back(MoveUtil::move(p->d_value));
2499#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2500template <
class VALUE,
class ALLOCATOR>
2502list<VALUE, ALLOCATOR>::list(std::initializer_list<VALUE> values,
2503 const ALLOCATOR& basicAllocator)
2504: d_alloc_and_size(basicAllocator, size_type(-1))
2512 list tmp(this->allocatorImp());
2513 tmp.insert(tmp.cbegin(), values.begin(), values.end());
2519template <
class VALUE,
class ALLOCATOR>
2520list<VALUE, ALLOCATOR>::~list()
2525 if (sizeRef() != size_type(-1)) {
2534template <
class VALUE,
class ALLOCATOR>
2535list<VALUE, ALLOCATOR>& list<VALUE, ALLOCATOR>::operator=(
const list& rhs)
2538 AllocTraits::propagate_on_container_copy_assignment Propagate;
2541 if (Propagate::value && allocatorImp() != rhs.allocatorImp()) {
2545 BloombergLP::bslma::AllocatorUtil::assign(&allocatorImp(),
2550 assign(rhs.begin(), rhs.end());
2556template <
class VALUE,
class ALLOCATOR>
2557list<VALUE, ALLOCATOR>& list<VALUE, ALLOCATOR>::operator=(
2558 BloombergLP::bslmf::MovableRef<list> rhs)
2562 AllocTraits::propagate_on_container_move_assignment Propagate;
2566 if (
this == &lvalue) {
2570 if (this->allocatorImp() == lvalue.allocatorImp()) {
2575 else if (Propagate::value) {
2589 list other(MoveUtil::move(lvalue));
2592 using BloombergLP::bslma::AllocatorUtil;
2594 AllocatorUtil::swap(
2595 &allocatorImp(), &other.allocatorImp(), Propagate());
2596 swap(d_sentinel, other.d_sentinel);
2597 swap(sizeRef(), other.sizeRef());
2605 NodePtr dstPtr = this->headNode();
2606 const const_iterator dstEnd = this->
cend();
2607 const NodePtr dstEndPtr = dstEnd.d_node_p;
2609 NodePtr srcPtr = lvalue.headNode();
2610 const NodePtr srcEndPtr = lvalue.d_sentinel;
2612 for (; srcEndPtr != srcPtr && dstEndPtr != dstPtr;
2613 srcPtr = srcPtr->d_next_p, dstPtr = dstPtr->d_next_p) {
2614 dstPtr->d_value = MoveUtil::move(srcPtr->d_value);
2617 erase(const_iterator(dstPtr), dstEnd);
2619 for (; srcEndPtr != srcPtr; srcPtr = srcPtr->d_next_p) {
2620 emplace(dstEnd, MoveUtil::move(srcPtr->d_value));
2627#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2628template <
class VALUE,
class ALLOCATOR>
2630list<VALUE, ALLOCATOR>& list<VALUE, ALLOCATOR>::operator=(
2631 std::initializer_list<VALUE> rhs)
2633 assign(rhs.begin(), rhs.end());
2638template <
class VALUE,
class ALLOCATOR>
2639void list<VALUE, ALLOCATOR>::assign(size_type numElements,
const VALUE& value)
2641 NodePtr dst_p = this->headNode();
2642 const const_iterator dstEnd = this->
cend();
2643 const NodePtr dstEnd_p = dstEnd.d_node_p;
2645 for (; 0 < numElements && dstEnd_p != dst_p;
2646 --numElements, dst_p = dst_p->d_next_p) {
2647 dst_p->d_value = value;
2650 erase(const_iterator(dst_p), dstEnd);
2652 for (; 0 < numElements; --numElements) {
2653 insert(dstEnd, value);
2657#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2658template <
class VALUE,
class ALLOCATOR>
2660void list<VALUE, ALLOCATOR>::assign(std::initializer_list<VALUE> values)
2662 assign(values.begin(), values.end());
2668template <
class VALUE,
class ALLOCATOR>
2670typename list<VALUE, ALLOCATOR>::iterator list<VALUE, ALLOCATOR>::begin()
2673 return iterator(headNode());
2676template <
class VALUE,
class ALLOCATOR>
2678typename list<VALUE, ALLOCATOR>::iterator list<VALUE, ALLOCATOR>::end()
2681 return iterator(d_sentinel);
2684template <
class VALUE,
class ALLOCATOR>
2686typename list<VALUE, ALLOCATOR>::reverse_iterator
2689 return reverse_iterator(
end());
2692template <
class VALUE,
class ALLOCATOR>
2694typename list<VALUE, ALLOCATOR>::reverse_iterator
2697 return reverse_iterator(
begin());
2702template <
class VALUE,
class ALLOCATOR>
2706 const NodePtr e = d_sentinel;
2707 for (NodePtr p = d_sentinel->d_next_p; e != p; ) {
2708 NodePtr condemned = p;
2710 deleteNode(condemned);
2713 linkNodes(d_sentinel, d_sentinel);
2717template <
class VALUE,
class ALLOCATOR>
2718void list<VALUE, ALLOCATOR>::resize(size_type newSize)
2720 if (newSize > sizeRef()) {
2721 const_iterator ce =
cend();
2724 }
while (newSize > sizeRef());
2727 NodePtr e = d_sentinel;
2728 NodePtr p = e->d_prev_p;
2729 for (size_type d = sizeRef() - newSize; d > 0; --d) {
2730 NodePtr condemned = p;
2732 deleteNode(condemned);
2735 sizeRef() = newSize;
2739template <
class VALUE,
class ALLOCATOR>
2740void list<VALUE, ALLOCATOR>::resize(size_type newSize,
const VALUE& value)
2742 if (newSize > sizeRef()) {
2743 const_iterator ce =
cend();
2746 }
while (newSize > sizeRef());
2749 NodePtr e = d_sentinel;
2750 NodePtr p = e->d_prev_p;
2751 for (size_type d = sizeRef() - newSize; d > 0; --d) {
2752 NodePtr condemned = p;
2754 deleteNode(condemned);
2757 sizeRef() = newSize;
2763template <
class VALUE,
class ALLOCATOR>
2765typename list<VALUE, ALLOCATOR>::reference
2766list<VALUE, ALLOCATOR>::back()
2770 return d_sentinel->d_prev_p->d_value;
2773template <
class VALUE,
class ALLOCATOR>
2775typename list<VALUE, ALLOCATOR>::reference
2776list<VALUE, ALLOCATOR>::front()
2780 return headNode()->d_value;
2785template <
class VALUE,
class ALLOCATOR>
2787void list<VALUE, ALLOCATOR>::pop_back()
2794template <
class VALUE,
class ALLOCATOR>
2796void list<VALUE, ALLOCATOR>::pop_front()
2805template <
class VALUE,
class ALLOCATOR>
2806typename list<VALUE, ALLOCATOR>::iterator
2807list<VALUE, ALLOCATOR>::erase(const_iterator position)
2811 NodePtr condemned = position.d_node_p;
2812 iterator ret(condemned->d_next_p);
2814 linkNodes(condemned->d_prev_p, condemned->d_next_p);
2815 deleteNode(condemned);
2820template <
class VALUE,
class ALLOCATOR>
2821typename list<VALUE, ALLOCATOR>::iterator
2822list<VALUE, ALLOCATOR>::erase(const_iterator dstBegin, const_iterator dstEnd)
2824 NodePtr p = dstBegin.d_node_p;
2825 const NodePtr e = dstEnd. d_node_p;
2827 linkNodes(p->d_prev_p, e);
2829 size_type numDeleted = 0;
2830 for (; e != p; ++numDeleted) {
2831 NodePtr condemned = p;
2833 deleteNode(condemned);
2836 sizeRef() -= numDeleted;
2843#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2846#ifndef BSLSTL_LIST_VARIADIC_LIMIT
2847#define BSLSTL_LIST_VARIADIC_LIMIT 10
2849#ifndef BSLSTL_LIST_VARIADIC_LIMIT_D
2850#define BSLSTL_LIST_VARIADIC_LIMIT_D BSLSTL_LIST_VARIADIC_LIMIT
2852#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 0
2853template <
class VALUE,
class ALLOCATOR>
2855typename list<VALUE, ALLOCATOR>::reference
2856list<VALUE, ALLOCATOR>::emplace_back(
2864#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 1
2865template <
class VALUE,
class ALLOCATOR>
2866template <
class ARGS_01>
2868typename list<VALUE, ALLOCATOR>::reference
2869list<VALUE, ALLOCATOR>::emplace_back(
2877#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 2
2878template <
class VALUE,
class ALLOCATOR>
2879template <
class ARGS_01,
2882typename list<VALUE, ALLOCATOR>::reference
2883list<VALUE, ALLOCATOR>::emplace_back(
2893#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 3
2894template <
class VALUE,
class ALLOCATOR>
2895template <
class ARGS_01,
2899typename list<VALUE, ALLOCATOR>::reference
2900list<VALUE, ALLOCATOR>::emplace_back(
2912#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 4
2913template <
class VALUE,
class ALLOCATOR>
2914template <
class ARGS_01,
2919typename list<VALUE, ALLOCATOR>::reference
2920list<VALUE, ALLOCATOR>::emplace_back(
2934#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 5
2935template <
class VALUE,
class ALLOCATOR>
2936template <
class ARGS_01,
2942typename list<VALUE, ALLOCATOR>::reference
2943list<VALUE, ALLOCATOR>::emplace_back(
2959#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 6
2960template <
class VALUE,
class ALLOCATOR>
2961template <
class ARGS_01,
2968typename list<VALUE, ALLOCATOR>::reference
2969list<VALUE, ALLOCATOR>::emplace_back(
2987#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 7
2988template <
class VALUE,
class ALLOCATOR>
2989template <
class ARGS_01,
2997typename list<VALUE, ALLOCATOR>::reference
2998list<VALUE, ALLOCATOR>::emplace_back(
3018#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 8
3019template <
class VALUE,
class ALLOCATOR>
3020template <
class ARGS_01,
3029typename list<VALUE, ALLOCATOR>::reference
3030list<VALUE, ALLOCATOR>::emplace_back(
3052#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 9
3053template <
class VALUE,
class ALLOCATOR>
3054template <
class ARGS_01,
3064typename list<VALUE, ALLOCATOR>::reference
3065list<VALUE, ALLOCATOR>::emplace_back(
3089#if BSLSTL_LIST_VARIADIC_LIMIT_D >= 10
3090template <
class VALUE,
class ALLOCATOR>
3091template <
class ARGS_01,
3102typename list<VALUE, ALLOCATOR>::reference
3103list<VALUE, ALLOCATOR>::emplace_back(
3132template <
class VALUE,
class ALLOCATOR>
3133template <
class... ARGS>
3135typename list<VALUE, ALLOCATOR>::reference
3136list<VALUE, ALLOCATOR>::emplace_back(
3145#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3148#ifndef BSLSTL_LIST_VARIADIC_LIMIT
3149#define BSLSTL_LIST_VARIADIC_LIMIT 10
3151#ifndef BSLSTL_LIST_VARIADIC_LIMIT_E
3152#define BSLSTL_LIST_VARIADIC_LIMIT_E BSLSTL_LIST_VARIADIC_LIMIT
3154#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 0
3155template <
class VALUE,
class ALLOCATOR>
3157typename list<VALUE, ALLOCATOR>::reference
3158list<VALUE, ALLOCATOR>::emplace_front(
3166#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 1
3167template <
class VALUE,
class ALLOCATOR>
3168template <
class ARGS_01>
3170typename list<VALUE, ALLOCATOR>::reference
3171list<VALUE, ALLOCATOR>::emplace_front(
3179#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 2
3180template <
class VALUE,
class ALLOCATOR>
3181template <
class ARGS_01,
3184typename list<VALUE, ALLOCATOR>::reference
3185list<VALUE, ALLOCATOR>::emplace_front(
3195#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 3
3196template <
class VALUE,
class ALLOCATOR>
3197template <
class ARGS_01,
3201typename list<VALUE, ALLOCATOR>::reference
3202list<VALUE, ALLOCATOR>::emplace_front(
3214#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 4
3215template <
class VALUE,
class ALLOCATOR>
3216template <
class ARGS_01,
3221typename list<VALUE, ALLOCATOR>::reference
3222list<VALUE, ALLOCATOR>::emplace_front(
3236#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 5
3237template <
class VALUE,
class ALLOCATOR>
3238template <
class ARGS_01,
3244typename list<VALUE, ALLOCATOR>::reference
3245list<VALUE, ALLOCATOR>::emplace_front(
3261#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 6
3262template <
class VALUE,
class ALLOCATOR>
3263template <
class ARGS_01,
3270typename list<VALUE, ALLOCATOR>::reference
3271list<VALUE, ALLOCATOR>::emplace_front(
3289#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 7
3290template <
class VALUE,
class ALLOCATOR>
3291template <
class ARGS_01,
3299typename list<VALUE, ALLOCATOR>::reference
3300list<VALUE, ALLOCATOR>::emplace_front(
3320#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 8
3321template <
class VALUE,
class ALLOCATOR>
3322template <
class ARGS_01,
3331typename list<VALUE, ALLOCATOR>::reference
3332list<VALUE, ALLOCATOR>::emplace_front(
3354#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 9
3355template <
class VALUE,
class ALLOCATOR>
3356template <
class ARGS_01,
3366typename list<VALUE, ALLOCATOR>::reference
3367list<VALUE, ALLOCATOR>::emplace_front(
3391#if BSLSTL_LIST_VARIADIC_LIMIT_E >= 10
3392template <
class VALUE,
class ALLOCATOR>
3393template <
class ARGS_01,
3404typename list<VALUE, ALLOCATOR>::reference
3405list<VALUE, ALLOCATOR>::emplace_front(
3434template <
class VALUE,
class ALLOCATOR>
3435template <
class... ARGS>
3437typename list<VALUE, ALLOCATOR>::reference
3438list<VALUE, ALLOCATOR>::emplace_front(
3447template <
class VALUE,
class ALLOCATOR>
3449void list<VALUE, ALLOCATOR>::push_back(
const VALUE& value)
3451 emplace(
cend(), value);
3454template <
class VALUE,
class ALLOCATOR>
3456void list<VALUE, ALLOCATOR>::push_back(
3457 BloombergLP::bslmf::MovableRef<VALUE> value)
3459 emplace(
cend(), MoveUtil::move(value));
3462template <
class VALUE,
class ALLOCATOR>
3464void list<VALUE, ALLOCATOR>::push_front(
const VALUE& value)
3466 emplace(
cbegin(), value);
3469template <
class VALUE,
class ALLOCATOR>
3471void list<VALUE, ALLOCATOR>::push_front(
3472 BloombergLP::bslmf::MovableRef<VALUE> value)
3474 emplace(
cbegin(), MoveUtil::move(value));
3479#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3482#ifndef BSLSTL_LIST_VARIADIC_LIMIT
3483#define BSLSTL_LIST_VARIADIC_LIMIT 10
3485#ifndef BSLSTL_LIST_VARIADIC_LIMIT_F
3486#define BSLSTL_LIST_VARIADIC_LIMIT_F BSLSTL_LIST_VARIADIC_LIMIT
3488#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 0
3489template <
class VALUE,
class ALLOCATOR>
3490typename list<VALUE, ALLOCATOR>::iterator
3491list<VALUE, ALLOCATOR>::emplace(const_iterator position)
3493 NodePtr p = allocateNode();
3494 NodeProctor proctor(
this, p);
3495 AllocTraits::construct(allocatorImp(),
3496 BloombergLP::bsls::Util::addressOf(p->d_value));
3498 return insertNode(position, p);
3502#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 1
3503template <
class VALUE,
class ALLOCATOR>
3504template <
class ARGS_01>
3505typename list<VALUE, ALLOCATOR>::iterator
3506list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3509 NodePtr p = allocateNode();
3510 NodeProctor proctor(
this, p);
3511 AllocTraits::construct(allocatorImp(),
3512 BloombergLP::bsls::Util::addressOf(p->d_value),
3515 return insertNode(position, p);
3519#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 2
3520template <
class VALUE,
class ALLOCATOR>
3521template <
class ARGS_01,
3523typename list<VALUE, ALLOCATOR>::iterator
3524list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3528 NodePtr p = allocateNode();
3529 NodeProctor proctor(
this, p);
3530 AllocTraits::construct(allocatorImp(),
3531 BloombergLP::bsls::Util::addressOf(p->d_value),
3535 return insertNode(position, p);
3539#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 3
3540template <
class VALUE,
class ALLOCATOR>
3541template <
class ARGS_01,
3544typename list<VALUE, ALLOCATOR>::iterator
3545list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3550 NodePtr p = allocateNode();
3551 NodeProctor proctor(
this, p);
3552 AllocTraits::construct(allocatorImp(),
3553 BloombergLP::bsls::Util::addressOf(p->d_value),
3558 return insertNode(position, p);
3562#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 4
3563template <
class VALUE,
class ALLOCATOR>
3564template <
class ARGS_01,
3568typename list<VALUE, ALLOCATOR>::iterator
3569list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3575 NodePtr p = allocateNode();
3576 NodeProctor proctor(
this, p);
3577 AllocTraits::construct(allocatorImp(),
3578 BloombergLP::bsls::Util::addressOf(p->d_value),
3584 return insertNode(position, p);
3588#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 5
3589template <
class VALUE,
class ALLOCATOR>
3590template <
class ARGS_01,
3595typename list<VALUE, ALLOCATOR>::iterator
3596list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3603 NodePtr p = allocateNode();
3604 NodeProctor proctor(
this, p);
3605 AllocTraits::construct(allocatorImp(),
3606 BloombergLP::bsls::Util::addressOf(p->d_value),
3613 return insertNode(position, p);
3617#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 6
3618template <
class VALUE,
class ALLOCATOR>
3619template <
class ARGS_01,
3625typename list<VALUE, ALLOCATOR>::iterator
3626list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3634 NodePtr p = allocateNode();
3635 NodeProctor proctor(
this, p);
3636 AllocTraits::construct(allocatorImp(),
3637 BloombergLP::bsls::Util::addressOf(p->d_value),
3645 return insertNode(position, p);
3649#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 7
3650template <
class VALUE,
class ALLOCATOR>
3651template <
class ARGS_01,
3658typename list<VALUE, ALLOCATOR>::iterator
3659list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3668 NodePtr p = allocateNode();
3669 NodeProctor proctor(
this, p);
3670 AllocTraits::construct(allocatorImp(),
3671 BloombergLP::bsls::Util::addressOf(p->d_value),
3680 return insertNode(position, p);
3684#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 8
3685template <
class VALUE,
class ALLOCATOR>
3686template <
class ARGS_01,
3694typename list<VALUE, ALLOCATOR>::iterator
3695list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3705 NodePtr p = allocateNode();
3706 NodeProctor proctor(
this, p);
3707 AllocTraits::construct(allocatorImp(),
3708 BloombergLP::bsls::Util::addressOf(p->d_value),
3718 return insertNode(position, p);
3722#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 9
3723template <
class VALUE,
class ALLOCATOR>
3724template <
class ARGS_01,
3733typename list<VALUE, ALLOCATOR>::iterator
3734list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3745 NodePtr p = allocateNode();
3746 NodeProctor proctor(
this, p);
3747 AllocTraits::construct(allocatorImp(),
3748 BloombergLP::bsls::Util::addressOf(p->d_value),
3759 return insertNode(position, p);
3763#if BSLSTL_LIST_VARIADIC_LIMIT_F >= 10
3764template <
class VALUE,
class ALLOCATOR>
3765template <
class ARGS_01,
3775typename list<VALUE, ALLOCATOR>::iterator
3776list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3788 NodePtr p = allocateNode();
3789 NodeProctor proctor(
this, p);
3790 AllocTraits::construct(allocatorImp(),
3791 BloombergLP::bsls::Util::addressOf(p->d_value),
3803 return insertNode(position, p);
3810template <
class VALUE,
class ALLOCATOR>
3811template <
class... ARGS>
3812typename list<VALUE, ALLOCATOR>::iterator
3813list<VALUE, ALLOCATOR>::emplace(const_iterator position,
3816 NodePtr p = allocateNode();
3817 NodeProctor proctor(
this, p);
3818 AllocTraits::construct(allocatorImp(),
3819 BloombergLP::bsls::Util::addressOf(p->d_value),
3822 return insertNode(position, p);
3827template <
class VALUE,
class ALLOCATOR>
3828typename list<VALUE, ALLOCATOR>::iterator
3829list<VALUE, ALLOCATOR>::insert(const_iterator dstPosition,
const VALUE& value)
3831 return emplace(dstPosition, value);
3834template <
class VALUE,
class ALLOCATOR>
3835typename list<VALUE, ALLOCATOR>::iterator
3836list<VALUE, ALLOCATOR>::insert(
3837 const_iterator dstPosition,
3838 BloombergLP::bslmf::MovableRef<VALUE> value)
3840 return emplace(dstPosition, MoveUtil::move(value));
3843template <
class VALUE,
class ALLOCATOR>
3844typename list<VALUE, ALLOCATOR>::iterator
3845list<VALUE, ALLOCATOR>::insert(const_iterator dstPosition,
3846 size_type numElements,
3849 if (0 == numElements) {
3850 return dstPosition.unconst();
3855 iterator ret = emplace(dstPosition, value);
3859 for (--numElements; numElements > 0; --numElements) {
3860 emplace(dstPosition, value);
3866#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3867template <
class VALUE,
class ALLOCATOR>
3868typename list<VALUE, ALLOCATOR>::iterator
3869list<VALUE, ALLOCATOR>::insert(const_iterator dstPosition,
3870 std::initializer_list<VALUE> values)
3872 return insert(dstPosition, values.begin(), values.end());
3878template <
class VALUE,
class ALLOCATOR>
3880void list<VALUE, ALLOCATOR>::merge(list& other)
3884 merge(other, DefaultLessThan());
3887template <
class VALUE,
class ALLOCATOR>
3889void list<VALUE, ALLOCATOR>::merge(BloombergLP::bslmf::MovableRef<list> other)
3891 list& lvalue = other;
3895 merge(lvalue, DefaultLessThan());
3898template <
class VALUE,
class ALLOCATOR>
3899template <
class COMPARE>
3900void list<VALUE, ALLOCATOR>::merge(list& other, COMPARE comparator)
3902 if (&other ==
this) {
3906 BSLS_ASSERT(this->allocatorImp() == other.allocatorImp());
3908 if (other.empty()) {
3917 NodePtr xfirst = other.d_sentinel->d_next_p;
3918 splice(
end(), other);
3924 mergeImp(d_sentinel->d_next_p, xfirst, d_sentinel, comparator);
3927template <
class VALUE,
class ALLOCATOR>
3928template <
class COMPARE>
3930void list<VALUE, ALLOCATOR>::merge(
3931 BloombergLP::bslmf::MovableRef<list> other,
3934 list& lvalue = other;
3938 merge(lvalue, comparator);
3941template <
class VALUE,
class ALLOCATOR>
3942typename list<VALUE, ALLOCATOR>::size_type
3943list<VALUE, ALLOCATOR>::remove(
const VALUE& value)
3945 const size_type origSize = this->size();
3946 const const_iterator e =
cend();
3947 for (const_iterator i =
cbegin(); e != i; ) {
3958 return origSize - this->size();
3961template <
class VALUE,
class ALLOCATOR>
3962template <
class PREDICATE>
3963typename list<VALUE, ALLOCATOR>::size_type
3964list<VALUE, ALLOCATOR>::remove_if(PREDICATE predicate)
3966 const size_type origSize = this->size();
3967 const iterator e =
end();
3968 for (iterator i =
begin(); e != i; ) {
3969 if (predicate(*i)) {
3977 return origSize - this->size();
3980template <
class VALUE,
class ALLOCATOR>
3983 NodePtr sentinel = d_sentinel;
3984 NodePtr p = sentinel;
3987 NodePtr tmp = p->d_next_p;
3988 p->d_next_p = p->d_prev_p;
3991 }
while (p != sentinel);
3994template <
class VALUE,
class ALLOCATOR>
3996void list<VALUE, ALLOCATOR>::sort()
3998 sort(DefaultLessThan());
4001template <
class VALUE,
class ALLOCATOR>
4002template <
class COMPARE>
4003void list<VALUE, ALLOCATOR>::sort(COMPARE comparator)
4005 if (sizeRef() < 2) {
4008 NodePtr node1 = d_sentinel->d_next_p;
4009 sortImp(&node1,
size(), comparator);
4012template <
class VALUE,
class ALLOCATOR>
4013void list<VALUE, ALLOCATOR>::splice(const_iterator dstPosition, list& src)
4015 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
4022 NodePtr pPos = dstPosition.d_node_p;
4023 NodePtr pFirst = src.headNode();
4024 NodePtr pLast = src.d_sentinel->d_prev_p;
4025 size_type n = src.sizeRef();
4029 linkNodes(src.d_sentinel, src.d_sentinel);
4034 linkNodes(pPos->d_prev_p, pFirst);
4035 linkNodes(pLast, pPos);
4039template <
class VALUE,
class ALLOCATOR>
4041void list<VALUE, ALLOCATOR>::splice(
4042 const_iterator dstPosition,
4043 BloombergLP::bslmf::MovableRef<list> src)
4045 splice(dstPosition, MoveUtil::access(src));
4048template <
class VALUE,
class ALLOCATOR>
4049void list<VALUE, ALLOCATOR>::splice(const_iterator dstPosition,
4051 const_iterator srcNode)
4053 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
4055 NodePtr pPos = dstPosition.d_node_p;
4056 NodePtr pSrcNode = srcNode.d_node_p;
4057 NodePtr pAfterSrcNode = pSrcNode->d_next_p;
4059 if (pPos == pSrcNode || pPos == pAfterSrcNode) {
4065 linkNodes(pSrcNode->d_prev_p, pAfterSrcNode);
4070 linkNodes(pPos->d_prev_p, pSrcNode);
4071 linkNodes(pSrcNode, pPos);
4075template <
class VALUE,
class ALLOCATOR>
4077void list<VALUE, ALLOCATOR>::splice(
4078 const_iterator dstPosition,
4079 BloombergLP::bslmf::MovableRef<list> src,
4080 const_iterator srcNode)
4082 splice(dstPosition, MoveUtil::access(src), srcNode);
4085template <
class VALUE,
class ALLOCATOR>
4086void list<VALUE, ALLOCATOR>::splice(const_iterator dstPosition,
4088 const_iterator first,
4089 const_iterator last)
4091 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
4093 size_type n = bsl::distance(first, last);
4099 NodePtr pPos = dstPosition.d_node_p;
4100 NodePtr pFirst = first.d_node_p;
4101 NodePtr pLast = last.d_node_p;
4102 NodePtr pSrcLast = pLast->d_prev_p;
4106 linkNodes(pFirst->d_prev_p, pLast);
4111 linkNodes(pPos->d_prev_p, pFirst);
4112 linkNodes(pSrcLast, pPos);
4116template <
class VALUE,
class ALLOCATOR>
4118void list<VALUE, ALLOCATOR>::splice(
4119 const_iterator dstPosition,
4120 BloombergLP::bslmf::MovableRef<list> src,
4121 const_iterator first,
4122 const_iterator last)
4124 splice(dstPosition, MoveUtil::access(src), first, last);
4127template <
class VALUE,
class ALLOCATOR>
4128void list<VALUE, ALLOCATOR>::unique()
4134 iterator i =
begin();
4137 reference match = *i++;
4138 while (i != e && *i == match) {
4144template <
class VALUE,
class ALLOCATOR>
4145template <
class EQ_PREDICATE>
4146void list<VALUE, ALLOCATOR>::unique(EQ_PREDICATE binaryPredicate)
4152 iterator i =
begin();
4155 reference match = *i++;
4156 while (i != e && binaryPredicate(*i, match)) {
4164template <
class VALUE,
class ALLOCATOR>
4165void list<VALUE, ALLOCATOR>::swap(list& other)
4171 typedef typename AllocTraits::propagate_on_container_swap Propagate;
4173 if (Propagate::value) {
4175 using BloombergLP::bslma::AllocatorUtil;
4177 AllocatorUtil::swap(
4178 &allocatorImp(), &other.allocatorImp(), Propagate());
4179 swap(d_sentinel, other.d_sentinel);
4180 swap(sizeRef(), other.sizeRef());
4183 allocatorImp() == other.allocatorImp())) {
4197 list toOtherCopy(MoveUtil::move(*
this), other.allocatorImp());
4198 list toThisCopy( MoveUtil::move(other), this->allocatorImp());
4200 toOtherCopy.quickSwap(&other);
4201 toThisCopy .quickSwap(
this);
4209template <
class VALUE,
class ALLOCATOR>
4211typename list<VALUE, ALLOCATOR>::const_iterator
4214 return const_iterator(headNode());
4217template <
class VALUE,
class ALLOCATOR>
4219typename list<VALUE, ALLOCATOR>::const_iterator
4222 return const_iterator(d_sentinel);
4225template <
class VALUE,
class ALLOCATOR>
4227typename list<VALUE, ALLOCATOR>::const_iterator
4233template <
class VALUE,
class ALLOCATOR>
4235typename list<VALUE, ALLOCATOR>::const_iterator
4241template <
class VALUE,
class ALLOCATOR>
4243typename list<VALUE, ALLOCATOR>::const_reverse_iterator
4249template <
class VALUE,
class ALLOCATOR>
4251typename list<VALUE, ALLOCATOR>::const_reverse_iterator
4257template <
class VALUE,
class ALLOCATOR>
4259typename list<VALUE, ALLOCATOR>::const_reverse_iterator
4262 return const_reverse_iterator(
end());
4265template <
class VALUE,
class ALLOCATOR>
4267typename list<VALUE, ALLOCATOR>::const_reverse_iterator
4270 return const_reverse_iterator(
begin());
4275template <
class VALUE,
class ALLOCATOR>
4279 return 0 == sizeRef();
4282template <
class VALUE,
class ALLOCATOR>
4284typename list<VALUE, ALLOCATOR>::size_type
4287 return AllocTraits::max_size(allocatorImp());
4290template <
class VALUE,
class ALLOCATOR>
4292typename list<VALUE, ALLOCATOR>::size_type list<VALUE, ALLOCATOR>::size() const
4300template <
class VALUE,
class ALLOCATOR>
4302typename list<VALUE, ALLOCATOR>::const_reference
4303list<VALUE, ALLOCATOR>::back()
const
4307 return d_sentinel->d_prev_p->d_value;
4310template <
class VALUE,
class ALLOCATOR>
4312typename list<VALUE, ALLOCATOR>::const_reference
4313list<VALUE, ALLOCATOR>::front()
const
4317 return headNode()->d_value;
4322template <
class VALUE,
class ALLOCATOR>
4326 return allocatorImp();
4332template <
class VALUE,
class ALLOCATOR>
4335 const list<VALUE, ALLOCATOR>& rhs)
4337 return BloombergLP::bslalg::RangeCompare::equal(lhs.begin(),
4345#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
4347template <
class VALUE,
class ALLOCATOR>
4350 const list<VALUE, ALLOCATOR>& rhs)
4352 return ! (lhs == rhs);
4357#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
4359template <
class VALUE,
class ALLOCATOR>
4361BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE> bsl::operator<=>(
4362 const list<VALUE, ALLOCATOR>& lhs,
4363 const list<VALUE, ALLOCATOR>& rhs)
4365 return bsl::lexicographical_compare_three_way(
4370 BloombergLP::bslalg::SynthThreeWayUtil::compare);
4375template <
class VALUE,
class ALLOCATOR>
4377bool bsl::operator< (
const list<VALUE, ALLOCATOR>& lhs,
4378 const list<VALUE, ALLOCATOR>& rhs)
4380 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.begin(),
4388template <
class VALUE,
class ALLOCATOR>
4390bool bsl::operator> (
const list<VALUE, ALLOCATOR>& lhs,
4391 const list<VALUE, ALLOCATOR>& rhs)
4396template <
class VALUE,
class ALLOCATOR>
4399 const list<VALUE, ALLOCATOR>& rhs)
4401 return !(rhs < lhs);
4404template <
class VALUE,
class ALLOCATOR>
4407 const list<VALUE, ALLOCATOR>& rhs)
4409 return !(lhs < rhs);
4415template <
class VALUE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
4417bsl::erase(list<VALUE, ALLOCATOR>& l,
const BDE_OTHER_TYPE& value)
4422 typename list<VALUE, ALLOCATOR>::size_type oldSize = l.size();
4423 for (
typename list<VALUE, ALLOCATOR>::iterator it = l.begin();
4433 return oldSize - l.size();
4436template <
class VALUE,
class ALLOCATOR,
class PREDICATE>
4438bsl::erase_if(list<VALUE, ALLOCATOR>& l, PREDICATE predicate)
4440 return BloombergLP::bslstl::AlgorithmUtil::containerEraseIf(l, predicate);
4443template <
class VALUE,
class ALLOCATOR>
4445void bsl::swap(list<VALUE, ALLOCATOR>& a, list<VALUE, ALLOCATOR>& b)
4465template <
class VALUE,
class ALLOCATOR>
4466struct HasStlIterators<
bsl::list<VALUE, ALLOCATOR> >
4474template <
class VALUE,
class ALLOCATOR>
4475struct UsesBslmaAllocator<
bsl::list<VALUE, ALLOCATOR> >
4485template <
class VALUE,
class ALLOCATOR>
4486struct IsBitwiseMoveable<
bsl::list<VALUE, ALLOCATOR> >
4487 : BloombergLP::bslmf::IsBitwiseMoveable<ALLOCATOR>
4494# error Not valid except when included from bslstl_list.h
Definition bslstl_list.h:739
List_Iterator & operator--()
Definition bslstl_list.h:2134
friend class list
Definition bslstl_list.h:753
VALUE * pointer
Definition bslstl_list.h:773
List_Iterator & operator++()
Definition bslstl_list.h:2126
friend class List_Iterator
Definition bslstl_list.h:756
reference operator*() const
Definition bslstl_list.h:2162
friend bool operator==(List_Iterator< T1 >, List_Iterator< T2 >)
Definition bslstl_list.h:2178
std::bidirectional_iterator_tag iterator_category
Definition bslstl_list.h:770
VALUE & reference
Definition bslstl_list.h:774
NcType value_type
Definition bslstl_list.h:771
BloombergLP::bsls::Types::IntPtr difference_type
Definition bslstl_list.h:772
pointer operator->() const
Definition bslstl_list.h:2170
friend class list
Definition bslstl_list.h:709
friend class List_Iterator
Definition bslstl_list.h:712
Definition bslma_bslallocator.h:580
allocator_traits< ALLOCATOR >::size_type size_type
Definition bslstl_list.h:1076
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
static const bool value
Definition bslmf_integralconstant.h:258
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:635
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
int assign(LHS_TYPE *lhs, const RHS_TYPE &rhs)
TransformIterator< FUNCTOR, ITERATOR > operator--(TransformIterator< FUNCTOR, ITERATOR > &iterator, int)
bool operator>=(const Guid &lhs, const Guid &rhs)
FunctionOutputIterator< FUNCTION > & operator++(FunctionOutputIterator< FUNCTION > &iterator)
Do nothing and return specified iterator.
Definition bdlb_functionoutputiterator.h:405
bool operator<=(const Guid &lhs, const Guid &rhs)
Definition bdlb_printmethods.h:283
T::reverse_iterator rend(T &container)
Definition bslstl_iterator.h:1625
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
T::const_iterator cend(const T &container)
Definition bslstl_iterator.h:1611
T::const_reverse_iterator crbegin(const T &container)
Definition bslstl_iterator.h:1597
T::reverse_iterator rbegin(T &container)
Definition bslstl_iterator.h:1567
bool operator>=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator<=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4126
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
bool operator==(const memory_resource &a, const memory_resource &b)
T::const_iterator cbegin(const T &container)
Definition bslstl_iterator.h:1553
BSLS_KEYWORD_CONSTEXPR size_t size(const TYPE(&)[DIMENSION]) BSLS_KEYWORD_NOEXCEPT
Return the dimension of the specified array argument.
Definition bslstl_iterator.h:1331
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4135
bool operator!=(const memory_resource &a, const memory_resource &b)
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1279
T::const_reverse_iterator crend(const T &container)
Definition bslstl_iterator.h:1654
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
void swap(TYPE &a, TYPE &b)
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR_TYPE >::type size_type
Definition bslma_allocatortraits.h:1165
Definition bslmf_isconvertible.h:867
Definition bslmf_issame.h:146
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126
t_TYPE type
Definition bslmf_typeidentity.h:216