STD::REFERENCE_WRAPPER(3)
π std::reference_wrapper< _Tp > π
okay bestie, so this is the manual for std::reference_wrapper< _Tp > from the libstdc++ Library Functions Manual, and it's giving "primary class template for reference_wrapper" energy, which is honestly iconic of it. sit down, grab a strawberry, let's go π
β¨ NAME β¨
std::reference_wrapper< _Tp > β the Primary class template for reference_wrapper. yes that's literally what it says, it's the main character and it knows it π
πΈ SYNOPSIS πΈ
#include <functional>
π Public Types π
typedef _Tp typeβ that's the type, no notes π
π¦ Public Member Functions π¦
- ```cpp template<typename _Up, typename = __not_same<_Up>, typename = decltype(reference_wrapper::_S_fun(std::declval<_Up>()))> constexpr reference_wrapper (_Up &&__uref) noexcept(noexcept(reference_wrapper::_S_fun(std::declval< _Up >())))
β the constructor, constexpr, and it's `noexcept` exactly when that `_S_fun` call is `noexcept`. very demure, very conditional π«Ά
- **`reference_wrapper (const reference_wrapper &)=default`** β copy constructor, defaulted, it's literally just vibing
- **`constexpr _Tp & get () const noexcept`** β hands you the reference back, constexpr, no-throw, slay
- **`constexpr operator _Tp & () const noexcept`** β implicit conversion to `_Tp &`, constexpr, noexcept, periodt
- ```cpp
template<typename... _Args> constexpr __invoke_result< _Tp &, _Args...
>::type operator() (_Args &&... __args) const
noexcept(__is_nothrow_invocable< _Tp &, _Args... >::value)
β call operator! it forwards to the thing you wrapped, returns whatever __invoke_result< _Tp &, _Args... >::type says, and it's noexcept iff __is_nothrow_invocable< _Tp &, _Args... >::value. the way that it's fully generic... π
reference_wrapper & operator= (const reference_wrapper &)=defaultβ copy assignment, defaulted, moving on π
π Friends π
constexpr auto operator<=> (reference_wrapper __x, const _Tp &__y)constexpr auto operator<=> (reference_wrapper __x, reference_wrapper __y)constexpr auto operator<=> (reference_wrapper __x, reference_wrapper< const _Tp > __y)constexpr bool operator== (reference_wrapper __x, const _Tp &__y)constexpr bool operator== (reference_wrapper __x, reference_wrapper __y)constexpr bool operator== (reference_wrapper __x, reference_wrapper< const _Tp > __y)
that's the whole spaceship-and-equality friend squad, all constexpr, all iconic β¨
π Related Symbols π
heads up bestie: these are not member symbols, they just hang around the same friend group
- ```cpp template<typename _Tp> constexpr reference_wrapper< _Tp > ref (_Tp &__t) noexcept
β Denotes a reference should be taken to a variable.
- ```cpp
template<typename _Tp> constexpr reference_wrapper< const _Tp > cref
(const _Tp &__t) noexcept
β Denotes a const reference should be taken to a variable.
- ```cpp template<typename _Tp> constexpr reference_wrapper< _Tp > ref (reference_wrapper< _Tp > __t) noexcept
β `std::ref` overload to prevent wrapping a `reference_wrapper`
- ```cpp
template<typename _Tp> constexpr reference_wrapper< const _Tp > cref
(reference_wrapper< _Tp > __t) noexcept
β std::cref overload to prevent wrapping a reference_wrapper
π Detailed Description π
template<typename _Tp>
class std::reference_wrapper< _Tp >
"Primary class template for reference_wrapper." that's it, that's the whole detailed description, and honestly? it ate π
π§ Friends And Related Symbol Documentation π§
template<typename _Tp> reference_wrapper< const _Tp > cref (const _Tp & __t) [related]
Denotes a const reference should be taken to a variable. yes bestie, a const one, respectfully πΈ
template<typename _Tp> reference_wrapper< const _Tp > cref (reference_wrapper< _Tp > __t) [related]
std::cref overload to prevent wrapping a reference_wrapper. it's a little bouncer at the door like "not today, no double-wrapping in this house" π
template<typename _Tp> reference_wrapper< _Tp > ref (_Tp & __t) [related]
Denotes a reference should be taken to a variable. that's the whole job description, and it does it flawlessly β¨
template<typename _Tp> reference_wrapper< _Tp > ref (reference_wrapper< _Tp > __t) [related]
std::ref overload to prevent wrapping a reference_wrapper. same bouncer, different door π₯
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. not a human, just a very diligent little robot bestie doing its thing π€π
and that's the whole page, bestie!! this one came to you from the libstdc++ manual, filed under std::refer...pper< _Tp >(3) β yeah they truncated the name, we don't talk about it π β and the footer just says libstdc++ with that same section-3 title. no cap, that's the entire tea. mwah π
π
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms