Add noexcept specification to list
This commit is contained in:
parent
dff3303733
commit
2fe6f0b4e1
@ -20,12 +20,14 @@
|
|||||||
#define REXY_LLIST_HPP
|
#define REXY_LLIST_HPP
|
||||||
|
|
||||||
#include <cstddef> //size_t, ptrdiff_t
|
#include <cstddef> //size_t, ptrdiff_t
|
||||||
#include "allocator.hpp" //TODO
|
#include "allocator.hpp"
|
||||||
#include "detail/hasallocator.hpp"
|
#include "detail/hasallocator.hpp"
|
||||||
|
#include "traits.hpp"
|
||||||
#include <iterator> //bidirectional_iterator_tag, reverse_iterator
|
#include <iterator> //bidirectional_iterator_tag, reverse_iterator
|
||||||
#include <memory> //allocator_traits
|
#include <memory> //allocator_traits
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <utility> //pair
|
#include <utility> //pair
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
@ -74,21 +76,58 @@ namespace rexy{
|
|||||||
size_type m_size = 0;
|
size_type m_size = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr list(void) = default;
|
constexpr list(void)noexcept = default;
|
||||||
constexpr explicit list(const allocator_type& alloc);
|
|
||||||
REXY_CPP20_CONSTEXPR list(size_type count, const_reference value = value_type(), const allocator_type& = allocator_type());
|
constexpr explicit list(const allocator_type& alloc)noexcept;
|
||||||
REXY_CPP20_CONSTEXPR explicit list(size_type count, const allocator_type& alloc = allocator_type());
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list(size_type count, const_reference value = value_type(), const allocator_type& = allocator_type())noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
explicit list(size_type count, const allocator_type& alloc = allocator_type())noexcept(
|
||||||
|
std::is_nothrow_default_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR list(InputIt first, InputIt last, const allocator_type& alloc = allocator_type());
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR list(const list& other, const allocator_type& alloc = allocator_type());
|
list(InputIt first, InputIt last, const allocator_type& alloc = allocator_type())noexcept(
|
||||||
REXY_CPP20_CONSTEXPR list(list&& other, const allocator_type& alloc = allocator_type());
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
REXY_CPP20_CONSTEXPR list(std::initializer_list<value_type> l, const allocator_type& alloc = allocator_type());
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR ~list(void);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list(const list& other, const allocator_type& alloc = allocator_type())noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR list& operator=(const list& other);
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR list& operator=(list&& other);
|
list(list&& other, const allocator_type& alloc = allocator_type())noexcept;
|
||||||
REXY_CPP20_CONSTEXPR list& operator=(std::initializer_list<value_type> l);
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list(std::initializer_list<value_type> l, const allocator_type& alloc = allocator_type())noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
~list(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list& operator=(const list& other)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list& operator=(list&& other)noexcept;
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list& operator=(std::initializer_list<value_type> l)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
constexpr bool operator==(const list& other)const noexcept;
|
constexpr bool operator==(const list& other)const noexcept;
|
||||||
#if __cpp_impl_three_way_comparison
|
#if __cpp_impl_three_way_comparison
|
||||||
@ -101,17 +140,45 @@ namespace rexy{
|
|||||||
constexpr bool operator>=(const list& other)const noexcept;
|
constexpr bool operator>=(const list& other)const noexcept;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void assign(size_type count, const_reference value);
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void assign(size_type count, const_reference value)noexcept(
|
||||||
|
std::conditional_t<
|
||||||
|
std::is_copy_assignable_v<value_type>,
|
||||||
|
std::is_nothrow_copy_assignable<value_type>,
|
||||||
|
std::true_type>::value &&
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR void assign(InputIt first, InputIt last);
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR void assign(std::initializer_list<value_type> l);
|
void assign(InputIt first, InputIt last)noexcept(
|
||||||
|
std::conditional_t<
|
||||||
|
std::is_assignable_v<value_type, decltype(*first)>,
|
||||||
|
std::is_nothrow_assignable<value_type, decltype(*first)>,
|
||||||
|
std::true_type>::value &&
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void assign(std::initializer_list<value_type> l)noexcept(
|
||||||
|
std::conditional_t<
|
||||||
|
std::is_assignable_v<value_type, decltype(*l.begin())>,
|
||||||
|
std::is_nothrow_assignable<value_type, decltype(*l.begin())>,
|
||||||
|
std::true_type>::value &&
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
constexpr allocator_type get_allocator(void)const noexcept;
|
constexpr allocator_type get_allocator(void)const noexcept;
|
||||||
|
|
||||||
constexpr reference front(void);
|
constexpr reference front(void)noexcept;
|
||||||
constexpr const_reference front(void)const;
|
constexpr const_reference front(void)const noexcept;
|
||||||
constexpr reference back(void);
|
constexpr reference back(void)noexcept;
|
||||||
constexpr const_reference back(void)const;
|
constexpr const_reference back(void)const noexcept;
|
||||||
|
|
||||||
constexpr iterator begin(void)noexcept;
|
constexpr iterator begin(void)noexcept;
|
||||||
constexpr const_iterator begin(void)const noexcept;
|
constexpr const_iterator begin(void)const noexcept;
|
||||||
@ -137,74 +204,193 @@ namespace rexy{
|
|||||||
constexpr size_type size(void)const noexcept;
|
constexpr size_type size(void)const noexcept;
|
||||||
constexpr size_type max_size(void)const noexcept;
|
constexpr size_type max_size(void)const noexcept;
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void clear(void)noexcept;
|
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR iterator insert(const_iterator pos, const_reference value);
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR iterator insert(const_iterator pos, value_type&& value);
|
void clear(void)noexcept(
|
||||||
REXY_CPP20_CONSTEXPR iterator insert(const_iterator pos, size_type count, const_reference value);
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
iterator insert(const_iterator pos, const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
iterator insert(const_iterator pos, value_type&& value)noexcept(
|
||||||
|
std::is_nothrow_move_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
iterator insert(const_iterator pos, size_type count, const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR iterator insert(const_iterator pos, InputIt first, InputIt last);
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR iterator insert(const_iterator pos, std::initializer_list<value_type> l);
|
iterator insert(const_iterator pos, InputIt first, InputIt last)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
iterator insert(const_iterator pos, std::initializer_list<value_type> l)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
REXY_CPP20_CONSTEXPR iterator emplace(const_iterator pos, Args&&... args);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
iterator emplace(const_iterator pos, Args&&... args)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, Args&&...> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR iterator erase(const_iterator pos);
|
|
||||||
REXY_CPP20_CONSTEXPR iterator erase(const_iterator first, const_iterator last);
|
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR reference push_back(const_reference value);
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR reference push_back(value_type&& value);
|
iterator erase(const_iterator pos)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
iterator erase(const_iterator first, const_iterator last)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
reference push_back(const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
reference push_back(value_type&& value)noexcept(
|
||||||
|
std::is_nothrow_move_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
REXY_CPP20_CONSTEXPR reference emplace_back(Args&&... args);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
reference emplace_back(Args&&... args)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, Args&&...> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void pop_back(void);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void pop_back(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
reference push_front(const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
reference push_front(value_type&& value)noexcept(
|
||||||
|
std::is_nothrow_move_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR reference push_front(const_reference value);
|
|
||||||
REXY_CPP20_CONSTEXPR reference push_front(value_type&& value);
|
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
REXY_CPP20_CONSTEXPR reference emplace_front(Args&&... args);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
reference emplace_front(Args&&... args)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, Args&&...> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void pop_front(void);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void pop_front(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void resize(size_type count);
|
|
||||||
REXY_CPP20_CONSTEXPR void resize(size_type count, value_type value);
|
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void swap(list& other);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void resize(size_type count)noexcept(
|
||||||
|
std::is_nothrow_default_constructible_v<value_type> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void merge(list&& other);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void resize(size_type count, value_type value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void swap(list& other)noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void merge(list&& other)noexcept;
|
||||||
template<class Comp>
|
template<class Comp>
|
||||||
REXY_CPP20_CONSTEXPR void merge(list&& other, Comp comp);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void merge(list&& other, Comp comp)noexcept;
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void splice(const_iterator pos, list&& other);
|
|
||||||
REXY_CPP20_CONSTEXPR void splice(const_iterator pos, list&& other, const_iterator it);
|
|
||||||
REXY_CPP20_CONSTEXPR void splice(const_iterator pos, list&& other, const_iterator first, const_iterator last);
|
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR size_type remove(const_reference value);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void splice(const_iterator pos, list&& other)noexcept;
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void splice(const_iterator pos, list&& other, const_iterator it)noexcept;
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void splice(const_iterator pos, list&& other, const_iterator first, const_iterator last)noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
size_type remove(const_reference value)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class UnaryPred>
|
template<class UnaryPred>
|
||||||
REXY_CPP20_CONSTEXPR size_type remove_if(UnaryPred p);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
size_type remove_if(UnaryPred p)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void reverse(void)noexcept;
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void reverse(void)noexcept;
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
size_type unique(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR size_type unique(void);
|
|
||||||
template<class BinaryPred>
|
template<class BinaryPred>
|
||||||
REXY_CPP20_CONSTEXPR size_type unique(BinaryPred p);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
size_type unique(BinaryPred p)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void sort(void)noexcept;
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR void sort(void);
|
|
||||||
template<class Comp>
|
template<class Comp>
|
||||||
REXY_CPP20_CONSTEXPR void sort(Comp comp);
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void sort(Comp comp)noexcept;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR void iterator_initialize_(InputIt first, InputIt last);
|
REXY_CPP20_CONSTEXPR
|
||||||
REXY_CPP20_CONSTEXPR void constant_initialize_(size_type count, const_reference value);
|
void iterator_initialize_(InputIt first, InputIt last)noexcept(
|
||||||
REXY_CPP20_CONSTEXPR void default_initialize_(size_type count);
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void constant_initialize_(size_type count, const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void default_initialize_(size_type count)noexcept(
|
||||||
|
std::is_nothrow_default_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>);
|
||||||
|
|
||||||
template<class Comp>
|
template<class Comp>
|
||||||
static iterator mergesort(iterator first, size_type firstlen, Comp comp);
|
static iterator mergesort(iterator first, size_type firstlen, Comp comp)noexcept;
|
||||||
static std::pair<iterator,size_type> ms_split(iterator it, size_type len);
|
static std::pair<iterator,size_type> ms_split(iterator it, size_type len)noexcept;
|
||||||
|
|
||||||
static void insert_node_(detail::list_node_base* prev, detail::list_node_base* n);
|
static void insert_node_(detail::list_node_base* prev, detail::list_node_base* n)noexcept;
|
||||||
static void remove_node_(detail::list_node_base* rm);
|
static void remove_node_(detail::list_node_base* rm)noexcept;
|
||||||
static detail::list_node_base* get_next_then_move_node_(detail::list_node_base* dest, detail::list_node_base* n);
|
static detail::list_node_base* get_next_then_move_node_(detail::list_node_base* dest, detail::list_node_base* n)noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -173,62 +173,91 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr list<T,Alloc>::list(const allocator_type& alloc):
|
constexpr list<T,Alloc>::list(const allocator_type& alloc)noexcept:
|
||||||
node_allocator_type(alloc){}
|
node_allocator_type(alloc){}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::list(size_type count, const_reference value, const allocator_type& alloc):
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::list(size_type count, const_reference value, const allocator_type& alloc)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>):
|
||||||
node_allocator_type(alloc)
|
node_allocator_type(alloc)
|
||||||
{
|
{
|
||||||
constant_initialize_(count, value);
|
constant_initialize_(count, value);
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::list(size_type count, const allocator_type& alloc):
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::list(size_type count, const allocator_type& alloc)noexcept(
|
||||||
|
std::is_nothrow_default_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>):
|
||||||
node_allocator_type(alloc)
|
node_allocator_type(alloc)
|
||||||
{
|
{
|
||||||
default_initialize_(count);
|
default_initialize_(count);
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::list(InputIt first, InputIt last, const allocator_type& alloc):
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::list(InputIt first, InputIt last, const allocator_type& alloc)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>):
|
||||||
node_allocator_type(alloc)
|
node_allocator_type(alloc)
|
||||||
{
|
{
|
||||||
iterator_initialize_(first, last);
|
iterator_initialize_(first, last);
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::list(const list& other, const allocator_type& alloc):
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::list(const list& other, const allocator_type& alloc)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>):
|
||||||
node_allocator_type(alloc)
|
node_allocator_type(alloc)
|
||||||
{
|
{
|
||||||
iterator_initialize_(other.begin(), other.end());
|
iterator_initialize_(other.begin(), other.end());
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::list(list&& other, const allocator_type& alloc):
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::list(list&& other, const allocator_type& alloc)noexcept:
|
||||||
node_allocator_type(alloc)
|
node_allocator_type(alloc)
|
||||||
{
|
{
|
||||||
swap(other);
|
swap(other);
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::list(std::initializer_list<value_type> l, const allocator_type& alloc):
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::list(std::initializer_list<value_type> l, const allocator_type& alloc)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>):
|
||||||
node_allocator_type(alloc)
|
node_allocator_type(alloc)
|
||||||
{
|
{
|
||||||
iterator_initialize_(l.begin(), l.end());
|
iterator_initialize_(l.begin(), l.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR list<T,Alloc>::~list(void){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
list<T,Alloc>::~list(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::operator=(const list& other) -> list&{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::operator=(const list& other)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> list&
|
||||||
|
{
|
||||||
return (*this = list(other));
|
return (*this = list(other));
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::operator=(list&& other) -> list&{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::operator=(list&& other)noexcept -> list&{
|
||||||
swap(other);
|
swap(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::operator=(std::initializer_list<value_type> l) -> list&{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::operator=(std::initializer_list<value_type> l)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> list&
|
||||||
|
{
|
||||||
return (*this = list(l));
|
return (*this = list(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,37 +296,38 @@ namespace rexy{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::assign(size_type count, const_reference value){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::assign(size_type count, const_reference value)noexcept(
|
||||||
|
std::conditional_t<
|
||||||
|
std::is_copy_assignable_v<value_type>,
|
||||||
|
std::is_nothrow_copy_assignable<value_type>,
|
||||||
|
std::true_type>::value &&
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
assign(sized_constant_iterator{value, count}, sized_constant_iterator<value_type>{{}, 0});
|
assign(sized_constant_iterator{value, count}, sized_constant_iterator<value_type>{{}, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::iterator_initialize_(InputIt first, InputIt last){
|
REXY_CPP20_CONSTEXPR
|
||||||
for(;first != last;++first){
|
void list<T,Alloc>::assign(InputIt first, InputIt last)noexcept(
|
||||||
emplace_back(*first);
|
std::conditional_t<
|
||||||
}
|
std::is_assignable_v<value_type, decltype(*first)>,
|
||||||
}
|
std::is_nothrow_assignable<value_type, decltype(*first)>,
|
||||||
template<class T, class Alloc>
|
std::true_type>::value &&
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::constant_initialize_(size_type count, const_reference value){
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
for(;count > 0;--count){
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
emplace_back(value);
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
}
|
{
|
||||||
}
|
|
||||||
template<class T, class Alloc>
|
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::default_initialize_(size_type count){
|
|
||||||
for(;count > 0;--count){
|
|
||||||
emplace_back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class T, class Alloc>
|
|
||||||
template<class InputIt>
|
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::assign(InputIt first, InputIt last){
|
|
||||||
auto current = begin();
|
auto current = begin();
|
||||||
size_type i = 0;
|
size_type i = 0;
|
||||||
|
if constexpr(std::is_assignable_v<value_type, decltype(*first)>){
|
||||||
for(;i < m_size && first != last;++i){
|
for(;i < m_size && first != last;++i){
|
||||||
*current++ = *first++;
|
*current++ = *first++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(first != last){
|
if(first != last){
|
||||||
m_size = i;
|
m_size = i;
|
||||||
while(first != last){
|
while(first != last){
|
||||||
@ -308,7 +338,16 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::assign(std::initializer_list<value_type> l){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::assign(std::initializer_list<value_type> l)noexcept(
|
||||||
|
std::conditional_t<
|
||||||
|
std::is_assignable_v<value_type, decltype(*l.begin())>,
|
||||||
|
std::is_nothrow_assignable<value_type, decltype(*l.begin())>,
|
||||||
|
std::true_type>::value &&
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
assign(l.begin(), l.end());
|
assign(l.begin(), l.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,13 +356,13 @@ namespace rexy{
|
|||||||
|
|
||||||
//Direct accessors
|
//Direct accessors
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::front(void) -> reference{return *begin();}
|
constexpr auto list<T,Alloc>::front(void)noexcept -> reference{return *begin();}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::front(void)const -> const_reference{return *begin();}
|
constexpr auto list<T,Alloc>::front(void)const noexcept -> const_reference{return *begin();}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::back(void) -> reference{return *(--end());}
|
constexpr auto list<T,Alloc>::back(void)noexcept -> reference{return *(--end());}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::back(void)const -> const_reference{return *(--end());}
|
constexpr auto list<T,Alloc>::back(void)const noexcept-> const_reference{return *(--end());}
|
||||||
|
|
||||||
//Iterators
|
//Iterators
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
@ -339,9 +378,7 @@ namespace rexy{
|
|||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::cend(void)const noexcept -> const_iterator{return const_iterator{&m_sentinel};}
|
constexpr auto list<T,Alloc>::cend(void)const noexcept -> const_iterator{return const_iterator{&m_sentinel};}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::next(iterator i)noexcept -> iterator{
|
constexpr auto list<T,Alloc>::next(iterator i)noexcept -> iterator{return i.next();}
|
||||||
return i.next();
|
|
||||||
}
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
constexpr auto list<T,Alloc>::next(const_iterator i)noexcept -> const_iterator{return i.next();}
|
constexpr auto list<T,Alloc>::next(const_iterator i)noexcept -> const_iterator{return i.next();}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
@ -370,16 +407,28 @@ namespace rexy{
|
|||||||
constexpr auto list<T,Alloc>::max_size(void)const noexcept -> size_type{return std::numeric_limits<difference_type>::max();}
|
constexpr auto list<T,Alloc>::max_size(void)const noexcept -> size_type{return std::numeric_limits<difference_type>::max();}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::clear(void)noexcept{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::clear(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
erase(begin(), end());
|
erase(begin(), end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::insert(const_iterator pos, const_reference value) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::insert(const_iterator pos, const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
return insert(pos, value_type{value});
|
return insert(pos, value_type{value});
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::insert(const_iterator pos, value_type&& value) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::insert(const_iterator pos, value_type&& value)noexcept(
|
||||||
|
std::is_nothrow_move_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
auto* prev = (--pos).unconst().nod();
|
auto* prev = (--pos).unconst().nod();
|
||||||
auto* next = prev->next;
|
auto* next = prev->next;
|
||||||
prev->next = this->allocate(1);
|
prev->next = this->allocate(1);
|
||||||
@ -389,7 +438,11 @@ namespace rexy{
|
|||||||
return iterator{prev->next};
|
return iterator{prev->next};
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::insert(const_iterator pos, size_type count, const_reference value) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::insert(const_iterator pos, size_type count, const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
auto start = pos.unconst();
|
auto start = pos.unconst();
|
||||||
for(auto i = count;i > 0;--i){
|
for(auto i = count;i > 0;--i){
|
||||||
pos = ++(insert(pos, value_type{value}));
|
pos = ++(insert(pos, value_type{value}));
|
||||||
@ -398,7 +451,11 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class InputIt>
|
template<class InputIt>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::insert(const_iterator pos, InputIt first, InputIt last) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::insert(const_iterator pos, InputIt first, InputIt last)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
auto start = pos.unconst();
|
auto start = pos.unconst();
|
||||||
while(first != last){
|
while(first != last){
|
||||||
pos = ++(insert(pos, *first++));
|
pos = ++(insert(pos, *first++));
|
||||||
@ -406,13 +463,21 @@ namespace rexy{
|
|||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::insert(const_iterator pos, std::initializer_list<value_type> l) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::insert(const_iterator pos, std::initializer_list<value_type> l)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*l.begin())> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
return insert(pos, l.begin(), l.end());
|
return insert(pos, l.begin(), l.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::emplace(const_iterator pos, Args&&... args) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::emplace(const_iterator pos, Args&&... args)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, Args&&...> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
auto* prev = (--pos).unconst().nod();
|
auto* prev = (--pos).unconst().nod();
|
||||||
auto* next = prev->next;
|
auto* next = prev->next;
|
||||||
prev->next = this->allocate(1);
|
prev->next = this->allocate(1);
|
||||||
@ -423,7 +488,11 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::erase(const_iterator pos) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::erase(const_iterator pos)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
auto* n = pos.unconst().nod();
|
auto* n = pos.unconst().nod();
|
||||||
auto* next = n->next;
|
auto* next = n->next;
|
||||||
|
|
||||||
@ -434,7 +503,11 @@ namespace rexy{
|
|||||||
return iterator{next};
|
return iterator{next};
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::erase(const_iterator first, const_iterator last) -> iterator{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::erase(const_iterator first, const_iterator last)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> iterator
|
||||||
|
{
|
||||||
while(first != last){
|
while(first != last){
|
||||||
first = erase(first);
|
first = erase(first);
|
||||||
}
|
}
|
||||||
@ -442,49 +515,91 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::push_back(const_reference value) -> reference{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::push_back(const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> reference
|
||||||
|
{
|
||||||
return *insert(cend(), value);
|
return *insert(cend(), value);
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::push_back(value_type&& value) -> reference{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::push_back(value_type&& value)noexcept(
|
||||||
|
std::is_nothrow_move_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> reference
|
||||||
|
{
|
||||||
return *insert(cend(), std::move(value));
|
return *insert(cend(), std::move(value));
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::emplace_back(Args&&... args) -> reference{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::emplace_back(Args&&... args)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, Args&&...> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> reference
|
||||||
|
{
|
||||||
return *emplace(cend(), std::forward<Args>(args)...);
|
return *emplace(cend(), std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::pop_back(void){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::pop_back(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
erase(--cend());
|
erase(--cend());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::push_front(const_reference value) -> reference{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::push_front(const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> reference
|
||||||
|
{
|
||||||
return insert(cbegin(), value);
|
return insert(cbegin(), value);
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::push_front(value_type&& value) -> reference{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::push_front(value_type&& value)noexcept(
|
||||||
|
std::is_nothrow_move_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> reference
|
||||||
|
{
|
||||||
return insert(cbegin(), std::move(value));
|
return insert(cbegin(), std::move(value));
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::emplace_front(Args&&... args) -> reference{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::emplace_front(Args&&... args)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, Args&&...> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> reference
|
||||||
|
{
|
||||||
return emplace(cbegin(), std::forward<Args>(args)...);
|
return emplace(cbegin(), std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::pop_front(void){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::pop_front(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
erase(cbegin());
|
erase(cbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::resize(size_type count){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::resize(size_type count)noexcept(
|
||||||
|
std::is_nothrow_default_constructible_v<value_type> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
resize(count, value_type{});
|
resize(count, value_type{});
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::resize(size_type count, value_type value){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::resize(size_type count, value_type value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
while(count > m_size){
|
while(count > m_size){
|
||||||
insert(cend(), value);
|
insert(cend(), value);
|
||||||
}
|
}
|
||||||
@ -494,18 +609,21 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::swap(list& other){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::swap(list& other)noexcept{
|
||||||
std::swap(m_sentinel, other.m_sentinel);
|
std::swap(m_sentinel, other.m_sentinel);
|
||||||
std::swap(m_size, other.m_size);
|
std::swap(m_size, other.m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::merge(list&& other){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::merge(list&& other)noexcept{
|
||||||
merge(std::move(other), [](const_reference a, const_reference b){return a < b;});
|
merge(std::move(other), [](const_reference a, const_reference b){return a < b;});
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class Comp>
|
template<class Comp>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::merge(list&& other, Comp comp){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::merge(list&& other, Comp comp)noexcept{
|
||||||
if(&other == this){
|
if(&other == this){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -524,11 +642,13 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::splice(const_iterator pos, list&& other){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::splice(const_iterator pos, list&& other)noexcept{
|
||||||
splice(pos, std::move(other), other.begin(), other.end());
|
splice(pos, std::move(other), other.begin(), other.end());
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::splice(const_iterator pos, list&& other, const_iterator it){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::splice(const_iterator pos, list&& other, const_iterator it)noexcept{
|
||||||
auto oit = it.unconst();
|
auto oit = it.unconst();
|
||||||
auto prev = (--pos).unconst();
|
auto prev = (--pos).unconst();
|
||||||
remove_node_(oit.nod());
|
remove_node_(oit.nod());
|
||||||
@ -538,7 +658,8 @@ namespace rexy{
|
|||||||
--other.m_size;
|
--other.m_size;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::splice(const_iterator pos, list&& other, const_iterator first, const_iterator last){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::splice(const_iterator pos, list&& other, const_iterator first, const_iterator last)noexcept{
|
||||||
for(auto oit = first;oit != last;){
|
for(auto oit = first;oit != last;){
|
||||||
auto onext = oit.next();
|
auto onext = oit.next();
|
||||||
splice(pos, std::move(other), oit);
|
splice(pos, std::move(other), oit);
|
||||||
@ -547,7 +668,11 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::remove(const_reference value) -> size_type{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::remove(const_reference value)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> size_type
|
||||||
|
{
|
||||||
return remove_if(
|
return remove_if(
|
||||||
[&value](const_reference r) -> bool{
|
[&value](const_reference r) -> bool{
|
||||||
return r == value;
|
return r == value;
|
||||||
@ -556,7 +681,11 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class UnaryPred>
|
template<class UnaryPred>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::remove_if(UnaryPred pred) -> size_type{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::remove_if(UnaryPred pred)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> size_type
|
||||||
|
{
|
||||||
size_type count = 0;
|
size_type count = 0;
|
||||||
for(auto it = begin();it != end();){
|
for(auto it = begin();it != end();){
|
||||||
if(pred(*it)){
|
if(pred(*it)){
|
||||||
@ -570,7 +699,8 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::reverse(void)noexcept{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::reverse(void)noexcept{
|
||||||
auto* it = begin().nod();
|
auto* it = begin().nod();
|
||||||
std::swap(m_sentinel.next, m_sentinel.prev);
|
std::swap(m_sentinel.next, m_sentinel.prev);
|
||||||
|
|
||||||
@ -580,7 +710,11 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::unique(void) -> size_type{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::unique(void)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> size_type
|
||||||
|
{
|
||||||
return unique(
|
return unique(
|
||||||
[](const_reference first, const_reference second) -> bool{
|
[](const_reference first, const_reference second) -> bool{
|
||||||
return first == second;
|
return first == second;
|
||||||
@ -589,7 +723,11 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class BinaryPred>
|
template<class BinaryPred>
|
||||||
REXY_CPP20_CONSTEXPR auto list<T,Alloc>::unique(BinaryPred pred) -> size_type{
|
REXY_CPP20_CONSTEXPR
|
||||||
|
auto list<T,Alloc>::unique(BinaryPred pred)noexcept(
|
||||||
|
std::is_nothrow_destructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>) -> size_type
|
||||||
|
{
|
||||||
size_type count = 0;
|
size_type count = 0;
|
||||||
for(auto it = begin();it != end();++it){
|
for(auto it = begin();it != end();++it){
|
||||||
auto next = it.next();
|
auto next = it.next();
|
||||||
@ -602,20 +740,54 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::sort(void){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::sort(void)noexcept{
|
||||||
mergesort(begin(), m_size, [](const_reference first, const_reference second)->bool{
|
mergesort(begin(), m_size, [](const_reference first, const_reference second)->bool{
|
||||||
return first < second;
|
return first < second;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class Comp>
|
template<class Comp>
|
||||||
REXY_CPP20_CONSTEXPR void list<T,Alloc>::sort(Comp comp){
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::sort(Comp comp)noexcept{
|
||||||
mergesort(begin(), m_size, comp);
|
mergesort(begin(), m_size, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T, class Alloc>
|
||||||
|
template<class InputIt>
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::iterator_initialize_(InputIt first, InputIt last)noexcept(
|
||||||
|
std::is_nothrow_constructible_v<value_type, decltype(*first)> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
|
for(;first != last;++first){
|
||||||
|
emplace_back(*first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<class T, class Alloc>
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::constant_initialize_(size_type count, const_reference value)noexcept(
|
||||||
|
std::is_nothrow_copy_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
|
for(;count > 0;--count){
|
||||||
|
emplace_back(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<class T, class Alloc>
|
||||||
|
REXY_CPP20_CONSTEXPR
|
||||||
|
void list<T,Alloc>::default_initialize_(size_type count)noexcept(
|
||||||
|
std::is_nothrow_default_constructible_v<value_type> &&
|
||||||
|
is_nothrow_allocator_v<node_allocator_type>)
|
||||||
|
{
|
||||||
|
for(;count > 0;--count){
|
||||||
|
emplace_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class Comp>
|
template<class Comp>
|
||||||
auto list<T,Alloc>::mergesort(iterator first, size_type firstlen, Comp comp) -> iterator{
|
auto list<T,Alloc>::mergesort(iterator first, size_type firstlen, Comp comp)noexcept -> iterator{
|
||||||
if(firstlen == 1)
|
if(firstlen == 1)
|
||||||
return first;
|
return first;
|
||||||
auto [second, secondlen] = ms_split(first, firstlen);
|
auto [second, secondlen] = ms_split(first, firstlen);
|
||||||
@ -651,7 +823,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
auto list<T,Alloc>::ms_split(iterator it, size_type len) -> std::pair<iterator,size_type>{
|
auto list<T,Alloc>::ms_split(iterator it, size_type len)noexcept -> std::pair<iterator,size_type>{
|
||||||
size_type second_half_len = len / 2;
|
size_type second_half_len = len / 2;
|
||||||
size_type dist = len - second_half_len;
|
size_type dist = len - second_half_len;
|
||||||
for(auto i = dist;i > 0;--i){
|
for(auto i = dist;i > 0;--i){
|
||||||
@ -661,19 +833,19 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
void list<T,Alloc>::insert_node_(detail::list_node_base* prev, detail::list_node_base* n){
|
void list<T,Alloc>::insert_node_(detail::list_node_base* prev, detail::list_node_base* n)noexcept{
|
||||||
n->next = prev->next;
|
n->next = prev->next;
|
||||||
n->prev = prev;
|
n->prev = prev;
|
||||||
prev->next->prev = n;
|
prev->next->prev = n;
|
||||||
prev->next = n;
|
prev->next = n;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
void list<T,Alloc>::remove_node_(detail::list_node_base* rm){
|
void list<T,Alloc>::remove_node_(detail::list_node_base* rm)noexcept{
|
||||||
rm->prev->next = rm->next;
|
rm->prev->next = rm->next;
|
||||||
rm->next->prev = rm->prev;
|
rm->next->prev = rm->prev;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
detail::list_node_base* list<T,Alloc>::get_next_then_move_node_(detail::list_node_base* dest, detail::list_node_base* n){
|
detail::list_node_base* list<T,Alloc>::get_next_then_move_node_(detail::list_node_base* dest, detail::list_node_base* n)noexcept{
|
||||||
auto* next = n->next;
|
auto* next = n->next;
|
||||||
remove_node_(n);
|
remove_node_(n);
|
||||||
insert_node_(dest, n);
|
insert_node_(dest, n);
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
#include <cstddef> //std::size_t,ptrdiff
|
#include <cstddef> //std::size_t,ptrdiff
|
||||||
#include <climits> //CHAR_BIT
|
#include <climits> //CHAR_BIT
|
||||||
#include <iterator> //reverse_iterator
|
#include <iterator> //reverse_iterator
|
||||||
#include <iostream> //ostream
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "steal.hpp"
|
#include "steal.hpp"
|
||||||
@ -526,12 +525,4 @@ namespace rexy{
|
|||||||
|
|
||||||
#include "string_base.tpp"
|
#include "string_base.tpp"
|
||||||
|
|
||||||
namespace{
|
|
||||||
template<class Char, class Alloc>
|
|
||||||
std::ostream& operator<<(std::ostream& os, const rexy::basic_string<Char,Alloc>& str){
|
|
||||||
return os << str.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user