Files
cppdraft_translate/cppdraft/refwrap/const.md
2025-10-25 03:02:53 +03:00

54 lines
1.7 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[refwrap.const]
# 22 General utilities library [[utilities]](./#utilities)
## 22.10 Function objects [[function.objects]](function.objects#refwrap.const)
### 22.10.6 Class template reference_wrapper [[refwrap]](refwrap#const)
#### 22.10.6.2 Constructors [refwrap.const]
[🔗](#lib:reference_wrapper,constructor)
`template<class U>
constexpr reference_wrapper(U&& u) noexcept(see below);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11724)
Let *FUN* denote the exposition-only functionsvoid *FUN*(T&) noexcept;void *FUN*(T&&) = delete;
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11731)
*Constraints*: The expression *FUN*(declval<U>()) is well-formed andis_same_v<remove_cvref_t<U>, reference_wrapper> is false[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11736)
*Effects*: Creates a variable r as if by T& r = std::forward<U>(u),
then constructs a reference_wrapper object
that stores a reference to r[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11743)
*Remarks*: The exception specification is equivalent tonoexcept(*FUN*(declval<U>()))[.](#4.sentence-1)
[🔗](#lib:reference_wrapper,constructor_)
`constexpr reference_wrapper(const reference_wrapper& x) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11755)
*Effects*: Constructs a reference_wrapper object that
stores a reference to x.get()[.](#5.sentence-1)