tmp/tmprxiyvfaf/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="optional.optional.ref.general">[[optional.optional.ref.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class T>
|
| 6 |
+
class optional<T&> {
|
| 7 |
+
public:
|
| 8 |
+
using value_type = T;
|
| 9 |
+
using iterator = implementation-defined; // see~[optional.ref.iterators]
|
| 10 |
+
|
| 11 |
+
public:
|
| 12 |
+
// [optional.ref.ctor], constructors
|
| 13 |
+
constexpr optional() noexcept = default;
|
| 14 |
+
constexpr optional(nullopt_t) noexcept : optional() {}
|
| 15 |
+
constexpr optional(const optional& rhs) noexcept = default;
|
| 16 |
+
|
| 17 |
+
template<class Arg>
|
| 18 |
+
constexpr explicit optional(in_place_t, Arg&& arg);
|
| 19 |
+
template<class U>
|
| 20 |
+
constexpr explicit(see below) optional(U&& u) noexcept(see below);
|
| 21 |
+
template<class U>
|
| 22 |
+
constexpr explicit(see below) optional(optional<U>& rhs) noexcept(see below);
|
| 23 |
+
template<class U>
|
| 24 |
+
constexpr explicit(see below) optional(const optional<U>& rhs) noexcept(see below);
|
| 25 |
+
template<class U>
|
| 26 |
+
constexpr explicit(see below) optional(optional<U>&& rhs) noexcept(see below);
|
| 27 |
+
template<class U>
|
| 28 |
+
constexpr explicit(see below) optional(const optional<U>&& rhs) noexcept(see below);
|
| 29 |
+
|
| 30 |
+
constexpr ~optional() = default;
|
| 31 |
+
|
| 32 |
+
// [optional.ref.assign], assignment
|
| 33 |
+
constexpr optional& operator=(nullopt_t) noexcept;
|
| 34 |
+
constexpr optional& operator=(const optional& rhs) noexcept = default;
|
| 35 |
+
|
| 36 |
+
template<class U> constexpr T& emplace(U&& u) noexcept(see below);
|
| 37 |
+
|
| 38 |
+
// [optional.ref.swap], swap
|
| 39 |
+
constexpr void swap(optional& rhs) noexcept;
|
| 40 |
+
|
| 41 |
+
// [optional.ref.iterators], iterator support
|
| 42 |
+
constexpr iterator begin() const noexcept;
|
| 43 |
+
constexpr iterator end() const noexcept;
|
| 44 |
+
|
| 45 |
+
// [optional.ref.observe], observers
|
| 46 |
+
constexpr T* operator->() const noexcept;
|
| 47 |
+
constexpr T& operator*() const noexcept;
|
| 48 |
+
constexpr explicit operator bool() const noexcept;
|
| 49 |
+
constexpr bool has_value() const noexcept;
|
| 50 |
+
constexpr T& value() const; // freestanding-deleted
|
| 51 |
+
template<class U = remove_cv_t<T>>
|
| 52 |
+
constexpr remove_cv_t<T> value_or(U&& u) const;
|
| 53 |
+
|
| 54 |
+
// [optional.ref.monadic], monadic operations
|
| 55 |
+
template<class F> constexpr auto and_then(F&& f) const;
|
| 56 |
+
template<class F> constexpr optional<invoke_result_t<F, T&>> transform(F&& f) const;
|
| 57 |
+
template<class F> constexpr optional or_else(F&& f) const;
|
| 58 |
+
|
| 59 |
+
// [optional.ref.mod], modifiers
|
| 60 |
+
constexpr void reset() noexcept;
|
| 61 |
+
|
| 62 |
+
private:
|
| 63 |
+
T* val = nullptr; // exposition only
|
| 64 |
+
|
| 65 |
+
// [optional.ref.expos], exposition only helper functions
|
| 66 |
+
template<class U>
|
| 67 |
+
constexpr void convert-ref-init-val(U&& u); // exposition only
|
| 68 |
+
};
|
| 69 |
+
}
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
An object of type `optional<T&>` *contains a value* if and only if
|
| 73 |
+
`val != nullptr` is `true`. When an `optional<T&>` contains a value, the
|
| 74 |
+
*contained value* is a reference to `*val`.
|
| 75 |
+
|