deductiongu...rstd::deque(3)
π deduction guides for std::deque π
okay so this page is literally deductiongu...rstd::deque(3) from the C++ Standard Libary, and itβs giving deduction guides energy β¨. bestie, hereβs the whole thing, no cap.
β¨ NAME β¨
deductionguidesforstd::deque - deductionguidesforstd::deque
π Synopsis π
Defined in header: <deque>
(1) β since C++17
template< class InputIt,
class Alloc = std::allocator<
typename std::iterator_traits<InputIt>::value_type>
>
deque( InputIt, InputIt, Alloc = Alloc() )
-> deque<typename std::iterator_traits<InputIt>::value_type, Alloc>;
(2) β since C++23
template< ranges::input_range R,
class Alloc = std::allocator<ranges::range_value_t<R>> >
deque( std::from_range_t, R&&, Alloc = Alloc() )
-> deque<ranges::range_value_t<R>, Alloc>;
- This deduction guide is lowkey here for
dequeso you can deduce from an iterator range. This overload participates in overload resolution only ifInputItsatisfiesLegacyInputIteratorandAllocsatisfiesAllocator. periodt. - This one is also for
deque, and it lets you deduce from astd::from_range_ttag plus aninput_range. iconic.
Note, bestie: the extent to which the library determines that a type does not satisfyLegacyInputIteratoris 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 satisfyAllocatoris unspecified, except that as a minimum the member typeAlloc::value_typemust exist and the expressionstd::declval<Alloc&>().allocate(std::size_t{})must be well-formed when treated as an unevaluated operand.
π Notes π
The feature-test macro is having its little main-character moment:
__cpp_lib_containers_rangesβ value202202L, std(C++23), feature: Ranges-aware construction and insertion; overload(2).
πΈ Example πΈ
// Run this code
#include <deque>
#include <vector>
int main()
{
std::vector<int> v = {1, 2, 3, 4};
// uses explicit deduction guide to deduce std::deque<int>
std::deque x(v.begin(), v.end());
// deduces std::deque<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::deque y{v.begin(), v.end()};
}
okay thatβs the whole page, bestie π«Ά. source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: deductiongu...rstd::deque(3) β slay and goodbye π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms