deduction guides for std::list
From cppreference.com
C++
Containers library
(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::list
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides(C++17) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Defined in header <list>
|
||
| template< class InputIt, class Alloc = std::allocator< |
(1) | (since C++17) |
| template< ranges::input_range R, class Alloc = std::allocator<ranges::range_value_t<R>> > |
(2) | (since C++23) |
1) This deduction guide is provided for list to allow deduction from an iterator range. This overload participates in overload resolution only if
InputIt satisfies LegacyInputIterator and Alloc satisfies Allocator.2) This deduction guide is provided for list to allow deduction from a std::from_range_t tag and an
input_range.Note: the extent to which the library determines that a type does not satisfy LegacyInputIterator is unspecified, except that as a minimum integral types do not qualify as input iterators. Likewise, the extent to which it determines that a type does not satisfy Allocator is unspecified, except that as a minimum the member type Alloc::value_type must exist and the expression std::declval<Alloc&>().allocate(std::size_t{}) must be well-formed when treated as an unevaluated operand.
[edit] Notes
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_containers_ranges |
202202L |
(C++23) | Ranges-aware construction and insertion; overload (2) |
[edit] Example
Run this code
#include <list> #include <vector> int main() { std::vector<int> v = {1, 2, 3, 4}; / uses explicit deduction guide to deduce std::list<int> std::list x(v.begin(), v.end(); / deduces std::list<std::vector<int>::iterator> / first phase of overload resolution for list-initialization selects the candidate / synthesized from the initializer-list constructor; second phase is not performed / and deduction guide has no effect std::list y{v.begin(), v.end()}; }