| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_FORWARD_LIST_H |
| 17 |
#define CPPREFERENCE_FORWARD_LIST_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
#include <initializer_list> |
| 21 |
|
| 22 |
namespace std { |
| 23 |
|
| 24 |
template<class T, class Allocator = allocator<T>> |
| 25 |
class forward_list { |
| 26 |
public: |
| 27 |
typedef T value_type; |
| 28 |
typedef Allocator allocator_type; |
| 29 |
typedef size_t size_type; // actual type unspecified |
| 30 |
typedef ptrdiff_t difference_type; // actual type not specified |
| 31 |
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS |
| 32 |
typedef T& reference; |
| 33 |
typedef const T& const_reference; |
| 34 |
typedef T* pointer; |
| 35 |
typedef const T* const_pointer; |
| 36 |
#else |
| 37 |
typedef value_type& reference; |
| 38 |
typedef const value_type& const_reference; |
| 39 |
typedef typename std::allocator_traits<Allocator>::pointer pointer; |
| 40 |
typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer; |
| 41 |
#endif |
| 42 |
typedef T* iterator; // actual type is unspecified |
| 43 |
typedef const T* const_iterator; // actual type is unspecified |
| 44 |
|
| 45 |
// constructor |
| 46 |
#if CPPREFERENCE_STDVER <2014 |
| 47 |
explicit forward_list(const Allocator& alloc = Allocator()); |
| 48 |
#else |
| 49 |
forward_list(); |
| 50 |
explicit forward_list(const Allocator&); |
| 51 |
#endif |
| 52 |
|
| 53 |
forward_list(size_type count, |
| 54 |
const T& value, |
| 55 |
const Allocator& alloc = Allocator()); |
| 56 |
|
| 57 |
#if CPPREFERENCE_STDVER <2014 |
| 58 |
explicit forward_list(size_type n); |
| 59 |
#else |
| 60 |
explicit forward_list(size_type n, const Allocator& alloc = Allocator()); |
| 61 |
#endif |
| 62 |
|
| 63 |
template<class InputIt> |
| 64 |
forward_list(InputIt first, InputIt last, |
| 65 |
const Allocator& alloc = Allocator()); |
| 66 |
|
| 67 |
forward_list(const forward_list& other); |
| 68 |
forward_list(const forward_list& other, const Allocator& alloc); |
| 69 |
|
| 70 |
forward_list(forward_list&& other); |
| 71 |
forward_list(forward_list&& other, const Allocator& alloc); |
| 72 |
|
| 73 |
forward_list(std::initializer_list<T> init, |
| 74 |
const Allocator& alloc = Allocator()); |
| 75 |
|
| 76 |
~forward_list(); |
| 77 |
|
| 78 |
forward_list& operator=(const forward_list& other); |
| 79 |
forward_list& operator=(forward_list&& other); |
| 80 |
forward_list& operator=(initializer_list<T> ilist); |
| 81 |
|
| 82 |
void assign(size_type count, const value_type& value); |
| 83 |
template <class InputIt> |
| 84 |
void assign(InputIt first, InputIt last); |
| 85 |
void assign(std::initializer_list<T> ilist); |
| 86 |
|
| 87 |
allocator_type get_allocator() const; |
| 88 |
|
| 89 |
// element access |
| 90 |
reference front(); |
| 91 |
const_reference front() const; |
| 92 |
|
| 93 |
// iterators |
| 94 |
iterator before_begin(); |
| 95 |
const_iterator before_begin() const; |
| 96 |
iterator begin(); |
| 97 |
const_iterator begin() const; |
| 98 |
iterator end(); |
| 99 |
const_iterator end() const; |
| 100 |
|
| 101 |
const_iterator cbefore_begin() const; |
| 102 |
const_iterator cbefore_end() const; |
| 103 |
const_iterator cbegin() const; |
| 104 |
const_iterator cend() const; |
| 105 |
const_reverse_iterator crbegin() const; |
| 106 |
const_reverse_iterator crend() const; |
| 107 |
|
| 108 |
// copacity |
| 109 |
bool empty() const; |
| 110 |
size_type max_size() const; |
| 111 |
|
| 112 |
// modifiers |
| 113 |
void clear(); |
| 114 |
|
| 115 |
iterator insert_after(const_iterator pos, const T& value); |
| 116 |
iterator insert_after(const_iterator pos, T&& value); |
| 117 |
iterator insert_after(const_iterator pos, size_type count, const T& value); |
| 118 |
template<class InputIt> |
| 119 |
iterator insert_after(const_iterator pos, InputIt first, InputIt last); |
| 120 |
iterator insert_after(const_iterator pos, std::initializer_list<T> ilist); |
| 121 |
|
| 122 |
template<class... Args> |
| 123 |
iterator emplace_after(const_iterator pos, Args&& ... args); |
| 124 |
|
| 125 |
iterator erase_after(const_iterator pos); |
| 126 |
iterator erase_after(const_iterator first, const_iterator last); |
| 127 |
|
| 128 |
void push_front(const T& value); |
| 129 |
void push_front(T&& value); |
| 130 |
|
| 131 |
template<class... Args> |
| 132 |
void emplace_front(Args&& ... args); |
| 133 |
|
| 134 |
void pop_front(); |
| 135 |
|
| 136 |
void resize(size_type count); |
| 137 |
void resize(size_type count, const value_type& value); |
| 138 |
|
| 139 |
void swap(forward_list& other); |
| 140 |
|
| 141 |
// operations |
| 142 |
void merge(forward_list& other); |
| 143 |
void merge(forward_list&& other); |
| 144 |
|
| 145 |
template <class Compare> |
| 146 |
void merge(forward_list& other, Compare comp); |
| 147 |
template <class Compare> |
| 148 |
void merge(forward_list&& other, Compare comp); |
| 149 |
|
| 150 |
void splice_after(const_iterator pos, forward_list& other); |
| 151 |
void splice_after(const_iterator pos, forward_list& other, const_iterator it); |
| 152 |
void splice_after(const_iterator pos, forward_list& other, |
| 153 |
const_iterator first, const_iterator last); |
| 154 |
void splice_after(const_iterator pos, forward_list&& other); |
| 155 |
void splice_after(const_iterator pos, forward_list&& other, const_iterator it); |
| 156 |
void splice_after(const_iterator pos, forward_list&& other, |
| 157 |
const_iterator first, const_iterator last); |
| 158 |
|
| 159 |
void remove(const T& value); |
| 160 |
|
| 161 |
template<class UnaryPredicate> |
| 162 |
void remove_if(UnaryPredicate p); |
| 163 |
|
| 164 |
void reverse(); |
| 165 |
|
| 166 |
void unique(); |
| 167 |
|
| 168 |
template<class BinaryPredicate> |
| 169 |
void unique(BinaryPredicate p); |
| 170 |
|
| 171 |
void sort(); |
| 172 |
|
| 173 |
template<class Compare> |
| 174 |
void sort(Compare comp); |
| 175 |
}; |
| 176 |
|
| 177 |
template<class T, class Alloc> |
| 178 |
bool operator==(const forward_list<T, Alloc>& lhs, |
| 179 |
const forward_list<T, Alloc>& rhs); |
| 180 |
|
| 181 |
template<class T, class Alloc> |
| 182 |
bool operator!=(const forward_list<T, Alloc>& lhs, |
| 183 |
const forward_list<T, Alloc>& rhs); |
| 184 |
|
| 185 |
template<class T, class Alloc> |
| 186 |
bool operator<(const forward_list<T, Alloc>& lhs, |
| 187 |
const forward_list<T, Alloc>& rhs); |
| 188 |
|
| 189 |
template<class T, class Alloc> |
| 190 |
bool operator<=(const forward_list<T, Alloc>& lhs, |
| 191 |
const forward_list<T, Alloc>& rhs); |
| 192 |
|
| 193 |
template<class T, class Alloc> |
| 194 |
bool operator>(const forward_list<T, Alloc>& lhs, |
| 195 |
const forward_list<T, Alloc>& rhs); |
| 196 |
|
| 197 |
template<class T, class Alloc> |
| 198 |
bool operator>=(const forward_list<T, Alloc>& lhs, |
| 199 |
const forward_list<T, Alloc>& rhs); |
| 200 |
|
| 201 |
} // namespace std |
| 202 |
|
| 203 |
#endif // CPPREFERENCE_STDVER>= 2011 |
| 204 |
|
| 205 |
#endif // CPPREFERENCE_FORWARD_LIST_H |