std::refere...ence_wrapper(3)
π std::reference_wrapper::reference_wrapper
okay so bestie, welcome to the std::reference_wrapper constructor page β that's std::refere...ence_wrapper(3) from the C++ Standard Libary if you're being formal about it. yes the title's truncated, she's shy, it's giving "name too long for the terminal." anyway. this is the constructor. let's get into it π«Ά
β¨ Synopsis
template< class U > (1) (since C++11)
reference_wrapper( U&& x ) noexcept(/*see below*/) ;
(constexpr since C++20)
reference_wrapper( const reference_wrapper& other ) (2) (since C++11)
noexcept;
(constexpr since C++20)
Constructs a new reference wrapper. that's the whole vibe π«
- Converts
xtoT&as if byT& t = std::forward<U>(x);, then stores a reference tot. This overload participates in overload resolution only iftypename std::decay<U>::typeis not the same type asreference_wrapperand the expressionFUN(std::declval<U>())is well-formed, whereFUNnames the set of imaginary functions:
void FUN(T&) noexcept;
void FUN(T&&) = delete;
like, yes, "imaginary functions," she said what she said π§ not me inventing overload resolution rules and calling them imaginary π
- Copy constructor. Stores a reference to
other.get().
πΈ Parameters
xβ an object to wrap πotherβ another reference wrapper π
π₯ Exceptions
noexceptspecification:
noexcept(noexcept(FUN(std::declval<U>())))
where FUN is the set of imaginary functions described in the description above. it's giving noexcept inception, iykyk π
π¦ Example
This section is incomplete
Reason: no example
not me being obsessed with a page that literally has no example π it's fine, we're fine, everything's fine
π Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. retroactive glow-ups, we love to see it β¨
- DR
LWG 2993, applied to C++11 β behavior as published: deletedreference_wrapper(T&&)constructor interferes with overload resolution in some cases. Correct behavior: replaced with a constructor template. she ate and left no crumbs π
β Categories
- conditionally
noexcept - Todo no example
okay that's the whole page bestie, every flag, every overload, every imaginary function accounted for π₯ no cap. this little cutie dropped 2024.06.10 courtesy of http://cppreference.com β go drink some water and go read a book (a C++ book, obviously) ππ bye bye π«Ά
π¦ 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