| Home | Libraries | People | FAQ | More

## Class template list

boost::intrusive::list

## Synopsis

    // In header: <boost/intrusive/list.hpp>

    template<typename T, class ... Options>
    class list {
    public:
      // types
      typedef ValueTraits                                          value_traits;
      typedef value_traits::pointer                                pointer;
      typedef value_traits::const_pointer                          const_pointer;
      typedef pointer_traits< pointer >::element_type              value_type;
      typedef pointer_traits< pointer >::reference                 reference;
      typedef pointer_traits< const_pointer >::reference           const_reference;
      typedef pointer_traits< pointer >::difference_type           difference_type;
      typedef SizeType                                             size_type;
      typedef list_iterator< value_traits, false >                 iterator;
      typedef list_iterator< value_traits, true >                  const_iterator;
      typedef boost::intrusive::reverse_iterator< iterator >       reverse_iterator;
      typedef boost::intrusive::reverse_iterator< const_iterator > const_reverse_iterator;
      typedef value_traits::node_traits                            node_traits;
      typedef node_traits::node                                    node;
      typedef node_traits::node_ptr                                node_ptr;
      typedef node_traits::const_node_ptr                          const_node_ptr;
      typedef circular_list_algorithms< node_traits >              node_algorithms;
      typedef unspecified                                          header_holder_type;

      // public member functions
      list();
      explicit list(const value_traits &);
      template<typename Iterator>
        list(Iterator, Iterator, const value_traits & = value_traits());
      list(list &&);
      list & operator=(list &&);
      ~list();
      void push_back(reference) noexcept;
      void push_front(reference) noexcept;
      void pop_back() noexcept;
      template<typename Disposer> void pop_back_and_dispose(Disposer) noexcept;
      void pop_front() noexcept;
      template<typename Disposer> void pop_front_and_dispose(Disposer) noexcept;
      reference front() noexcept;
      const_reference front() const noexcept;
      reference back() noexcept;
      const_reference back() const noexcept;
      iterator begin() noexcept;
      const_iterator begin() const noexcept;
      const_iterator cbegin() const noexcept;
      iterator end() noexcept;
      const_iterator end() const noexcept;
      const_iterator cend() const noexcept;
      reverse_iterator rbegin() noexcept;
      const_reverse_iterator rbegin() const noexcept;
      const_reverse_iterator crbegin() const noexcept;
      reverse_iterator rend() noexcept;
      const_reverse_iterator rend() const noexcept;
      const_reverse_iterator crend() const noexcept;
      size_type size() const noexcept;
      bool empty() const noexcept;
      void swap(list &) noexcept;
      void shift_backwards(size_type = 1) noexcept;
      void shift_forward(size_type = 1) noexcept;
      iterator erase(const_iterator) noexcept;
      iterator erase(const_iterator, const_iterator) noexcept;
      iterator erase(const_iterator, const_iterator, size_type) noexcept;
      template<typename Disposer>
        iterator erase_and_dispose(const_iterator, Disposer) noexcept;
      template<typename Disposer>
        iterator erase_and_dispose(const_iterator, const_iterator, Disposer) noexcept;
      void clear() noexcept;
      template<typename Disposer> void clear_and_dispose(Disposer) noexcept;
      template<typename Cloner, typename Disposer>
        void clone_from(const list &, Cloner, Disposer);
      template<typename Cloner, typename Disposer>
        void clone_from(list &&, Cloner, Disposer);
      iterator insert(const_iterator, reference) noexcept;
      template<typename Iterator>
        void insert(const_iterator, Iterator, Iterator) noexcept;
      template<typename Iterator> void assign(Iterator, Iterator) noexcept;
      template<typename Iterator, typename Disposer>
        void dispose_and_assign(Disposer, Iterator, Iterator) noexcept;
      void splice(const_iterator, list &) noexcept;
      void splice(const_iterator, list &, const_iterator) noexcept;
      void splice(const_iterator, list &, const_iterator, const_iterator) noexcept;
      void splice(const_iterator, list &, const_iterator, const_iterator,
                  size_type) noexcept;
      void sort();
      template<typename Predicate> void sort(Predicate);
      void merge(list &);
      template<typename Predicate> void merge(list &, Predicate);
      void reverse() noexcept;
      size_type remove(const_reference) noexcept;
      template<typename Disposer>
        size_type remove_and_dispose(const_reference, Disposer) noexcept;
      template<typename Pred> size_type remove_if(Pred);
      template<typename Pred, typename Disposer>
        size_type remove_and_dispose_if(Pred, Disposer);
      size_type unique();
      template<typename BinaryPredicate> size_type unique(BinaryPredicate);
      template<typename Disposer> size_type unique_and_dispose(Disposer);
      template<typename BinaryPredicate, typename Disposer>
        size_type unique_and_dispose(BinaryPredicate, Disposer);
      iterator iterator_to(reference) noexcept;
      const_iterator iterator_to(const_reference) const noexcept;
      void check() const;

      // public static functions
      static list & container_from_end_iterator(iterator) noexcept;
      static const list & container_from_end_iterator(const_iterator) noexcept;
      static iterator s_iterator_to(reference) noexcept;
      static const_iterator s_iterator_to(const_reference) noexcept;

      // public data members
      static const bool constant_time_size;
      static const bool stateful_value_traits;
      static const bool has_container_from_iterator;
    };

## Description

The class template list is an intrusive container that mimics most of the interface of std::list as described in the C++ standard.

The template parameter `T` is the type to be managed by the container. The user can specify additional options and if no options are provided default options are used.

The container supports the following options: `base_hook<>/member_hook<>/value_traits<>`, `constant_time_size<>` and `size_type<>`.

### `list` public member functions

1.     list();

   Effects: constructs an empty list.

   Complexity: Constant

   Throws: If value_traits::node_traits::node constructor throws (this does not happen with predefined Boost.Intrusive hooks).

2.     explicit list(const value_traits & v_traits);

   Effects: constructs an empty list.

   Complexity: Constant

   Throws: If value_traits::node_traits::node constructor throws (this does not happen with predefined Boost.Intrusive hooks).

3.     template<typename Iterator>
         list(Iterator b, Iterator e, const value_traits & v_traits = value_traits());

   Requires: Dereferencing iterator must yield an lvalue of type value_type.

   Effects: Constructs a list equal to the range [first,last).

   Complexity: Linear in distance(b, e). No copy constructors are called.

   Throws: If value_traits::node_traits::node constructor throws (this does not happen with predefined Boost.Intrusive hooks).

4.     list(list && x);

   Effects: Constructs a container moving resources from another container. Internal value traits are move constructed and nodes belonging to x (except the node representing the "end") are linked to *this.

   Complexity: Constant.

   Throws: If value_traits::node_traits::node's move constructor throws (this does not happen with predefined Boost.Intrusive hooks) or the move constructor of value traits throws.

5.     list & operator=(list && x);

   Effects: Equivalent to swap

6.     ~list();

   Effects: If it's not a safe-mode or an auto-unlink value_type the destructor does nothing (ie. no code is generated). Otherwise it detaches all elements from this. In this case the objects in the list are not deleted (i.e. no destructors are called), but the hooks according to the ValueTraits template parameter are set to their default value.

   Throws: Nothing.

   Complexity: Linear to the number of elements in the list, if it's a safe-mode or auto-unlink value . Otherwise constant.

7.     void push_back(reference value) noexcept;

   Requires: value must be an lvalue.

   Effects: Inserts the value in the back of the list. No copy constructors are called.

   Throws: Nothing.

   Complexity: Constant.

   Note: Does not affect the validity of iterators and references.

8.     void push_front(reference value) noexcept;

   Requires: value must be an lvalue.

   Effects: Inserts the value in the front of the list. No copy constructors are called.

   Throws: Nothing.

   Complexity: Constant.

   Note: Does not affect the validity of iterators and references.

9.     void pop_back() noexcept;

   Effects: Erases the last element of the list. No destructors are called.

   Throws: Nothing.

   Complexity: Constant.

   Note: Invalidates the iterators (but not the references) to the erased element.

10.     template<typename Disposer>
          void pop_back_and_dispose(Disposer disposer) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Erases the last element of the list. No destructors are called. Disposer::operator()(pointer) is called for the removed element.

    Throws: Nothing.

    Complexity: Constant.

    Note: Invalidates the iterators to the erased element.

11.     void pop_front() noexcept;

    Effects: Erases the first element of the list. No destructors are called.

    Throws: Nothing.

    Complexity: Constant.

    Note: Invalidates the iterators (but not the references) to the erased element.

12.     template<typename Disposer>
          void pop_front_and_dispose(Disposer disposer) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Erases the first element of the list. No destructors are called. Disposer::operator()(pointer) is called for the removed element.

    Throws: Nothing.

    Complexity: Constant.

    Note: Invalidates the iterators to the erased element.

13.     reference front() noexcept;

    Effects: Returns a reference to the first element of the list.

    Throws: Nothing.

    Complexity: Constant.

14.     const_reference front() const noexcept;

    Effects: Returns a const_reference to the first element of the list.

    Throws: Nothing.

    Complexity: Constant.

15.     reference back() noexcept;

    Effects: Returns a reference to the last element of the list.

    Throws: Nothing.

    Complexity: Constant.

16.     const_reference back() const noexcept;

    Effects: Returns a const_reference to the last element of the list.

    Throws: Nothing.

    Complexity: Constant.

17.     iterator begin() noexcept;

    Effects: Returns an iterator to the first element contained in the list.

    Throws: Nothing.

    Complexity: Constant.

18.     const_iterator begin() const noexcept;

    Effects: Returns a const_iterator to the first element contained in the list.

    Throws: Nothing.

    Complexity: Constant.

19.     const_iterator cbegin() const noexcept;

    Effects: Returns a const_iterator to the first element contained in the list.

    Throws: Nothing.

    Complexity: Constant.

20.     iterator end() noexcept;

    Effects: Returns an iterator to the end of the list.

    Throws: Nothing.

    Complexity: Constant.

21.     const_iterator end() const noexcept;

    Effects: Returns a const_iterator to the end of the list.

    Throws: Nothing.

    Complexity: Constant.

22.     const_iterator cend() const noexcept;

    Effects: Returns a constant iterator to the end of the list.

    Throws: Nothing.

    Complexity: Constant.

23.     reverse_iterator rbegin() noexcept;

    Effects: Returns a reverse_iterator pointing to the beginning of the reversed list.

    Throws: Nothing.

    Complexity: Constant.

24.     const_reverse_iterator rbegin() const noexcept;

    Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed list.

    Throws: Nothing.

    Complexity: Constant.

25.     const_reverse_iterator crbegin() const noexcept;

    Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed list.

    Throws: Nothing.

    Complexity: Constant.

26.     reverse_iterator rend() noexcept;

    Effects: Returns a reverse_iterator pointing to the end of the reversed list.

    Throws: Nothing.

    Complexity: Constant.

27.     const_reverse_iterator rend() const noexcept;

    Effects: Returns a const_reverse_iterator pointing to the end of the reversed list.

    Throws: Nothing.

    Complexity: Constant.

28.     const_reverse_iterator crend() const noexcept;

    Effects: Returns a const_reverse_iterator pointing to the end of the reversed list.

    Throws: Nothing.

    Complexity: Constant.

29.     size_type size() const noexcept;

    Effects: Returns the number of the elements contained in the list.

    Throws: Nothing.

    Complexity: Linear to the number of elements contained in the list. if constant-time size option is disabled. Constant time otherwise.

    Note: Does not affect the validity of iterators and references.

30.     bool empty() const noexcept;

    Effects: Returns true if the list contains no elements.

    Throws: Nothing.

    Complexity: Constant.

    Note: Does not affect the validity of iterators and references.

31.     void swap(list & other) noexcept;

    Effects: Swaps the elements of x and *this.

    Throws: Nothing.

    Complexity: Constant.

    Note: Does not affect the validity of iterators and references.

32.     void shift_backwards(size_type n = 1) noexcept;

    Effects: Moves backwards all the elements, so that the first element becomes the second, the second becomes the third... the last element becomes the first one.

    Throws: Nothing.

    Complexity: Linear to the number of shifts.

    Note: Does not affect the validity of iterators and references.

33.     void shift_forward(size_type n = 1) noexcept;

    Effects: Moves forward all the elements, so that the second element becomes the first, the third becomes the second... the first element becomes the last one.

    Throws: Nothing.

    Complexity: Linear to the number of shifts.

    Note: Does not affect the validity of iterators and references.

34.     iterator erase(const_iterator i) noexcept;

    Effects: Erases the element pointed by i of the list. No destructors are called.

    Returns: the first element remaining beyond the removed element, or end() if no such element exists.

    Throws: Nothing.

    Complexity: Constant.

    Note: Invalidates the iterators (but not the references) to the erased element.

35.     iterator erase(const_iterator b, const_iterator e) noexcept;

    Requires: b and e must be valid iterators to elements in *this.

    Effects: Erases the element range pointed by b and e No destructors are called.

    Returns: the first element remaining beyond the removed elements, or end() if no such element exists.

    Throws: Nothing.

    Complexity: Linear to the number of erased elements if it's a safe-mode or auto-unlink value, or constant-time size is enabled. Constant-time otherwise.

    Note: Invalidates the iterators (but not the references) to the erased elements.

36.     iterator erase(const_iterator b, const_iterator e, size_type n) noexcept;

    Requires: b and e must be valid iterators to elements in *this. n must be distance(b, e).

    Effects: Erases the element range pointed by b and e No destructors are called.

    Returns: the first element remaining beyond the removed elements, or end() if no such element exists.

    Throws: Nothing.

    Complexity: Linear to the number of erased elements if it's a safe-mode or auto-unlink value is enabled. Constant-time otherwise.

    Note: Invalidates the iterators (but not the references) to the erased elements.

37.     template<typename Disposer>
          iterator erase_and_dispose(const_iterator i, Disposer disposer) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Erases the element pointed by i of the list. No destructors are called. Disposer::operator()(pointer) is called for the removed element.

    Returns: the first element remaining beyond the removed element, or end() if no such element exists.

    Throws: Nothing.

    Complexity: Constant.

    Note: Invalidates the iterators to the erased element.

38.     template<typename Disposer>
          iterator erase_and_dispose(const_iterator b, const_iterator e,
                                     Disposer disposer) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Erases the element range pointed by b and e No destructors are called. Disposer::operator()(pointer) is called for the removed elements.

    Returns: the first element remaining beyond the removed elements, or end() if no such element exists.

    Throws: Nothing.

    Complexity: Linear to the number of elements erased.

    Note: Invalidates the iterators to the erased elements.

39.     void clear() noexcept;

    Effects: Erases all the elements of the container. No destructors are called.

    Throws: Nothing.

    Complexity: Linear to the number of elements of the list. if it's a safe-mode or auto-unlink value_type. Constant time otherwise.

    Note: Invalidates the iterators (but not the references) to the erased elements.

40.     template<typename Disposer> void clear_and_dispose(Disposer disposer) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Erases all the elements of the container. No destructors are called. Disposer::operator()(pointer) is called for the removed elements.

    Throws: Nothing.

    Complexity: Linear to the number of elements of the list.

    Note: Invalidates the iterators to the erased elements.

41.     template<typename Cloner, typename Disposer>
          void clone_from(const list & src, Cloner cloner, Disposer disposer);

    Requires: Disposer::operator()(pointer) shouldn't throw. Cloner should yield to nodes equivalent to the original nodes.

    Effects: Erases all the elements from *this calling Disposer::operator()(pointer), clones all the elements from src calling Cloner::operator()(const_reference ) and inserts them on *this.

    If cloner throws, all cloned elements are unlinked and disposed calling Disposer::operator()(pointer).

    Complexity: Linear to erased plus inserted elements.

    Throws: If cloner throws. Basic guarantee.

42.     template<typename Cloner, typename Disposer>
          void clone_from(list && src, Cloner cloner, Disposer disposer);

    Requires: Disposer::operator()(pointer) shouldn't throw. Cloner should yield to nodes equivalent to the original nodes.

    Effects: Erases all the elements from *this calling Disposer::operator()(pointer), clones all the elements from src calling Cloner::operator()(reference) and inserts them on *this.

    If cloner throws, all cloned elements are unlinked and disposed calling Disposer::operator()(pointer).

    Complexity: Linear to erased plus inserted elements.

    Throws: If cloner throws. Basic guarantee.

43.     iterator insert(const_iterator p, reference value) noexcept;

    Requires: value must be an lvalue and p must be a valid iterator of *this.

    Effects: Inserts the value before the position pointed by p.

    Returns: An iterator to the inserted element.

    Throws: Nothing.

    Complexity: Constant time. No copy constructors are called.

    Note: Does not affect the validity of iterators and references.

44.     template<typename Iterator>
          void insert(const_iterator p, Iterator b, Iterator e) noexcept;

    Requires: Dereferencing iterator must yield an lvalue of type value_type and p must be a valid iterator of *this.

    Effects: Inserts the range pointed by b and e before the position p. No copy constructors are called.

    Throws: Nothing.

    Complexity: Linear to the number of elements inserted.

    Note: Does not affect the validity of iterators and references.

45.     template<typename Iterator> void assign(Iterator b, Iterator e) noexcept;

    Requires: Dereferencing iterator must yield an lvalue of type value_type.

    Effects: Clears the list and inserts the range pointed by b and e. No destructors or copy constructors are called.

    Throws: Nothing.

    Complexity: Linear to the number of elements inserted plus linear to the elements contained in the list if it's a safe-mode or auto-unlink value. Linear to the number of elements inserted in the list otherwise.

    Note: Invalidates the iterators (but not the references) to the erased elements.

46.     template<typename Iterator, typename Disposer>
          void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Requires: Dereferencing iterator must yield an lvalue of type value_type.

    Effects: Clears the list and inserts the range pointed by b and e. No destructors or copy constructors are called. Disposer::operator()(pointer) is called for the removed elements.

    Throws: Nothing.

    Complexity: Linear to the number of elements inserted plus linear to the elements contained in the list.

    Note: Invalidates the iterators (but not the references) to the erased elements.

47.     void splice(const_iterator p, list & x) noexcept;

    Requires: p must be a valid iterator of *this.

    Effects: Transfers all the elements of list x to this list, before the the element pointed by p. No destructors or copy constructors are called.

    Throws: Nothing.

    Complexity: Constant.

    Note: Iterators of values obtained from list x now point to elements of this list. Iterators of this list and all the references are not invalidated.

48.     void splice(const_iterator p, list & x, const_iterator new_ele) noexcept;

    Requires: p must be a valid iterator of *this. new_ele must point to an element contained in list x.

    Effects: Transfers the value pointed by new_ele, from list x to this list, before the element pointed by p. No destructors or copy constructors are called. If p == new_ele or p == ++new_ele, this function is a null operation.

    Throws: Nothing.

    Complexity: Constant.

    Note: Iterators of values obtained from list x now point to elements of this list. Iterators of this list and all the references are not invalidated.

49.     void splice(const_iterator p, list & x, const_iterator f, const_iterator e) noexcept;

    Requires: p must be a valid iterator of *this. f and e must point to elements contained in list x.

    Effects: Transfers the range pointed by f and e from list x to this list, before the element pointed by p. No destructors or copy constructors are called.

    Throws: Nothing.

    Complexity: Linear to the number of elements transferred if constant-time size option is enabled. Constant-time otherwise.

    Note: Iterators of values obtained from list x now point to elements of this list. Iterators of this list and all the references are not invalidated.

50.     void splice(const_iterator p, list & x, const_iterator f, const_iterator e,
                    size_type n) noexcept;

    Requires: p must be a valid iterator of *this. f and e must point to elements contained in list x. n == distance(f, e)

    Effects: Transfers the range pointed by f and e from list x to this list, before the element pointed by p. No destructors or copy constructors are called.

    Throws: Nothing.

    Complexity: Constant.

    Note: Iterators of values obtained from list x now point to elements of this list. Iterators of this list and all the references are not invalidated.

51.     void sort();

    Effects: This function sorts the list *this according to operator <. The sort is stable, that is, the relative order of equivalent elements is preserved.

    Throws: If value_traits::node_traits::node constructor throws (this does not happen with predefined Boost.Intrusive hooks) or operator < throws. Basic guarantee.

    Notes: Iterators and references are not invalidated.

    Complexity: The number of comparisons is approximately N log N, where N is the list's size.

52.     template<typename Predicate> void sort(Predicate p);

    Requires: p must be a comparison function that induces a strict weak ordering

    Effects: This function sorts the list *this according to p. The sort is stable, that is, the relative order of equivalent elements is preserved.

    Throws: If value_traits::node_traits::node constructor throws (this does not happen with predefined Boost.Intrusive hooks) or the predicate throws. Basic guarantee.

    Notes: This won't throw if list_base_hook<> or list_member_hook are used. Iterators and references are not invalidated.

    Complexity: The number of comparisons is approximately N log N, where N is the list's size.

53.     void merge(list & x);

    Effects: This function removes all of x's elements and inserts them in order into *this according to operator <. The merge is stable; that is, if an element from *this is equivalent to one from x, then the element from *this will precede the one from x.

    Throws: If operator < throws. Basic guarantee.

    Complexity: This function is linear time: it performs at most size() + x.size() - 1 comparisons.

    Note: Iterators and references are not invalidated

54.     template<typename Predicate> void merge(list & x, Predicate p);

    Requires: p must be a comparison function that induces a strict weak ordering and both *this and x must be sorted according to that ordering The lists x and *this must be distinct.

    Effects: This function removes all of x's elements and inserts them in order into *this. The merge is stable; that is, if an element from *this is equivalent to one from x, then the element from *this will precede the one from x.

    Throws: If the predicate throws. Basic guarantee.

    Complexity: This function is linear time: it performs at most size() + x.size() - 1 comparisons.

    Note: Iterators and references are not invalidated.

55.     void reverse() noexcept;

    Effects: Reverses the order of elements in the list.

    Throws: Nothing.

    Complexity: This function is linear time.

    Note: Iterators and references are not invalidated

56.     size_type remove(const_reference value) noexcept;

    Effects: Removes all the elements that compare equal to value. No destructors are called.

    Throws: If operator == throws. Basic guarantee.

    Complexity: Linear time. It performs exactly size() comparisons for equality.

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

57.     template<typename Disposer>
          size_type remove_and_dispose(const_reference value, Disposer disposer) noexcept;

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Removes all the elements that compare equal to value. Disposer::operator()(pointer) is called for every removed element.

    Returns: The number of erased elements.

    Throws: If operator == throws. Basic guarantee.

    Complexity: Linear time. It performs exactly size() comparisons for equality.

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

58.     template<typename Pred> size_type remove_if(Pred pred);

    Effects: Removes all the elements for which a specified predicate is satisfied. No destructors are called.

    Returns: The number of removed elements.

    Throws: If pred throws. Basic guarantee.

    Complexity: Linear time. It performs exactly size() calls to the predicate.

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

59.     template<typename Pred, typename Disposer>
          size_type remove_and_dispose_if(Pred pred, Disposer disposer);

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Removes all the elements for which a specified predicate is satisfied. Disposer::operator()(pointer) is called for every removed element.

    Returns: The number of removed elements.

    Throws: If pred throws. Basic guarantee.

    Complexity: Linear time. It performs exactly size() comparisons for equality.

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

60.     size_type unique();

    Effects: Removes adjacent duplicate elements or adjacent elements that are equal from the list. No destructors are called.

    Returns: The number of removed elements.

    Throws: If the comparison operator throws. Basic guarantee.

    Complexity: Linear time (size()-1 comparisons calls to pred()).

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

61.     template<typename BinaryPredicate> size_type unique(BinaryPredicate pred);

    Effects: Removes adjacent duplicate elements or adjacent elements that satisfy some binary predicate from the list. No destructors are called.

    Returns: The number of removed elements.

    Throws: If pred throws. Basic guarantee.

    Complexity: Linear time (size()-1 comparisons equality comparisons).

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

62.     template<typename Disposer> size_type unique_and_dispose(Disposer disposer);

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Removes adjacent duplicate elements or adjacent elements that are equal from the list. Disposer::operator()(pointer) is called for every removed element.

    Returns: The number of removed elements.

    Throws: If the equality operator throws. Basic guarantee.

    Complexity: Linear time (size()-1) comparisons equality comparisons.

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

63.     template<typename BinaryPredicate, typename Disposer>
          size_type unique_and_dispose(BinaryPredicate pred, Disposer disposer);

    Requires: Disposer::operator()(pointer) shouldn't throw.

    Effects: Removes adjacent duplicate elements or adjacent elements that satisfy some binary predicate from the list. Disposer::operator()(pointer) is called for every removed element.

    Returns: The number of removed elements.

    Throws: If pred throws. Basic guarantee.

    Complexity: Linear time (size()-1) comparisons equality comparisons.

    Note: The relative order of elements that are not removed is unchanged, and iterators to elements that are not removed remain valid.

64.     iterator iterator_to(reference value) noexcept;

    Requires: `value` must be a reference to a value inserted in an instance of this container type.

    Effects: This function returns a const_iterator pointing to the element

    Throws: Nothing.

    Complexity: Constant time.

    Note: Iterators and references are not invalidated.

65.     const_iterator iterator_to(const_reference value) const noexcept;

    Requires: value must be a const reference to a value inserted in a list.

    Effects: This function returns an iterator pointing to the element.

    Throws: Nothing.

    Complexity: Constant time.

    Note: Iterators and references are not invalidated.

66.     void check() const;

    Effects: Asserts the integrity of the container.

    Complexity: Linear time.

    Note: The method has no effect when asserts are turned off (e.g., with NDEBUG). Experimental function, interface might change in future versions.

### `list` public static functions

1.     static list & container_from_end_iterator(iterator end_iterator) noexcept;

   Precondition: end_iterator must be a valid end iterator of list.

   Effects: Returns a const reference to the list associated to the end iterator

   Throws: Nothing.

   Complexity: Constant.

2.     static const list &
       container_from_end_iterator(const_iterator end_iterator) noexcept;

   Precondition: end_iterator must be a valid end const_iterator of list.

   Effects: Returns a const reference to the list associated to the end iterator

   Throws: Nothing.

   Complexity: Constant.

3.     static iterator s_iterator_to(reference value) noexcept;

   Requires: `value` must be a reference to a value inserted in an instance of this container type.

   Effects: This function returns a const_iterator pointing to the element

   Throws: Nothing.

   Complexity: Constant time.

   Note: Iterators and references are not invalidated. This static function is available only if the value traits is stateless.

4.     static const_iterator s_iterator_to(const_reference value) noexcept;

   Requires: value must be a const reference to a value inserted in a list.

   Effects: This function returns an iterator pointing to the element.

   Throws: Nothing.

   Complexity: Constant time.

   Note: Iterators and references are not invalidated. This static function is available only if the value traits is stateless.