Standard library header <forward_list> (C++11)
From cppreference.net
此头文件是 容器 库的组成部分。
包含文件 |
||
|
(C++20)
|
三路比较运算符 支持 | |
|
(C++11)
|
std::initializer_list 类模板 | |
类 |
||
|
(C++11)
|
单向链表
(类模板) |
|
函数 |
||
|
(C++11)
(C++11)
(C++20 中移除)
(C++11)
(C++20 中移除)
(C++11)
(C++20 中移除)
(C++11)
(C++20 中移除)
(C++11)
(C++20 中移除)
(C++20)
|
按字典序比较两个
forward_list
的值
(函数模板) |
|
|
(C++11)
|
特化
std::swap
算法
(函数模板) |
|
|
擦除所有满足特定条件的元素
(函数模板) |
||
范围访问 |
||
|
(C++11)
(C++14)
|
返回指向容器或数组起始的迭代器
(函数模板) |
|
|
(C++11)
(C++14)
|
返回指向容器或数组末尾的迭代器
(函数模板) |
|
|
(C++14)
|
返回指向容器或数组起始的反向迭代器
(函数模板) |
|
|
(C++14)
|
返回容器或数组的末尾反向迭代器
(函数模板) |
|
|
(C++17)
(C++20)
|
返回容器或数组的大小
(函数模板) |
|
|
(C++17)
|
检查容器是否为空
(函数模板) |
|
|
(C++17)
|
获取底层数组的指针
(函数模板) |
|
概要
#include <compare> #include <initializer_list> namespace std { // 类模板 forward_list template<class T, class Allocator = allocator<T>> class forward_list; template<class T, class Allocator> bool operator==(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y); template<class T, class Allocator> /*synth-three-way-result*/<T> operator<=>(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y); template<class T, class Allocator> void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y) noexcept(noexcept(x.swap(y))); // 擦除操作 template<class T, class Allocator, class U = T> typename forward_list<T, Allocator>::size_type erase(forward_list<T, Allocator>& c, const U& value); template<class T, class Allocator, class Predicate> typename forward_list<T, Allocator>::size_type erase_if(forward_list<T, Allocator>& c, Predicate pred); namespace pmr { template<class T> using forward_list = std::forward_list<T, polymorphic_allocator<T>>; } }
类模板 std::forward_list
namespace std { template<class T, class Allocator = allocator<T>> class forward_list { public: // 类型定义 using value_type = T; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = /* 实现定义 */; using difference_type = /* 实现定义 */; using iterator = /* 实现定义 */; using const_iterator = /* 实现定义 */; // 构造/复制/销毁 forward_list() : forward_list(Allocator()) { } explicit forward_list(const Allocator&); explicit forward_list(size_type n, const Allocator& = Allocator()); forward_list(size_type n, const T& value, const Allocator& = Allocator()); template<class InputIter> forward_list(InputIter first, InputIter last, const Allocator& = Allocator()); template<container-compatible-range<T> R> forward_list(from_range_t, R&& rg, const Allocator& = Allocator()); forward_list(const forward_list& x); forward_list(forward_list&& x); forward_list(const forward_list& x, const type_identity_t<Allocator>&); forward_list(forward_list&& x, const type_identity_t<Allocator>&); forward_list(initializer_list<T>, const Allocator& = Allocator()); ~forward_list(); forward_list& operator=(const forward_list& x); forward_list& operator=(forward_list&& x) noexcept( allocator_traits<Allocator>::is_always_equal::value); forward_list& operator=(initializer_list<T>); template<class InputIter> void assign(InputIter first, InputIter last); template<container-compatible-range<T> R> void assign_range(R&& rg); void assign(size_type n, const T& t); void assign(initializer_list<T>); allocator_type get_allocator() const noexcept; // 迭代器 iterator before_begin() noexcept; const_iterator before_begin() const noexcept; iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cbefore_begin() const noexcept; const_iterator cend() const noexcept; // 容量 bool empty() const noexcept; size_type max_size() const noexcept; // 元素访问 reference front(); const_reference front() const; // 修改器 template<class... Args> reference emplace_front(Args&&... args); void push_front(const T& x); void push_front(T&& x); template<container-compatible-range<T> R> void prepend_range(R&& rg); void pop_front(); template<class... Args> iterator emplace_after(const_iterator position, Args&&... args); iterator insert_after(const_iterator position, const T& x); iterator insert_after(const_iterator position, T&& x); iterator insert_after(const_iterator position, size_type n, const T& x)<span class="sy