|
4451 | 4451 | namespace std { |
4452 | 4452 | template<class T> |
4453 | 4453 | class optional<T&> { |
4454 | | - public: |
4455 | | - using value_type = T; |
4456 | | - using iterator = @\impdefnc@; // see~\ref{optional.ref.iterators} |
| 4454 | + public: |
| 4455 | + using value_type = T; |
| 4456 | + using iterator = @\impdefnc@; // see~\ref{optional.ref.iterators} |
4457 | 4457 |
|
4458 | | - public: |
4459 | | - // \ref{optional.ref.ctor}, constructors |
4460 | | - constexpr optional() noexcept = default; |
4461 | | - constexpr optional(nullopt_t) noexcept : optional() {} |
4462 | | - constexpr optional(const optional& rhs) noexcept = default; |
4463 | | - |
4464 | | - template<class Arg> |
4465 | | - constexpr explicit optional(in_place_t, Arg&& arg); |
4466 | | - template<class U> |
4467 | | - constexpr explicit(@\seebelow@) optional(U&& u) noexcept(@\seebelow@); |
4468 | | - template<class U> |
4469 | | - constexpr explicit(@\seebelow@) optional(optional<U>& rhs) noexcept(@\seebelow@); |
4470 | | - template<class U> |
4471 | | - constexpr explicit(@\seebelow@) optional(const optional<U>& rhs) noexcept(@\seebelow@); |
4472 | | - template<class U> |
4473 | | - constexpr explicit(@\seebelow@) optional(optional<U>&& rhs) noexcept(@\seebelow@); |
4474 | | - template<class U> |
4475 | | - constexpr explicit(@\seebelow@) optional(const optional<U>&& rhs) noexcept(@\seebelow@); |
4476 | | - |
4477 | | - constexpr ~optional() = default; |
4478 | | - |
4479 | | - // \ref{optional.ref.assign}, assignment |
4480 | | - constexpr optional& operator=(nullopt_t) noexcept; |
4481 | | - constexpr optional& operator=(const optional& rhs) noexcept = default; |
4482 | | - |
4483 | | - template<class U> constexpr T& emplace(U&& u) noexcept(@\seebelow@); |
4484 | | - |
4485 | | - // \ref{optional.ref.swap}, swap |
4486 | | - constexpr void swap(optional& rhs) noexcept; |
4487 | | - |
4488 | | - // \ref{optional.ref.iterators}, iterator support |
4489 | | - constexpr iterator begin() const noexcept; |
4490 | | - constexpr iterator end() const noexcept; |
4491 | | - |
4492 | | - // \ref{optional.ref.observe}, observers |
4493 | | - constexpr T* operator->() const noexcept; |
4494 | | - constexpr T& operator*() const noexcept; |
4495 | | - constexpr explicit operator bool() const noexcept; |
4496 | | - constexpr bool has_value() const noexcept; |
4497 | | - constexpr T& value() const; // freestanding-deleted |
4498 | | - template<class U = remove_cv_t<T>> |
4499 | | - constexpr remove_cv_t<T> value_or(U&& u) const; |
4500 | | - |
4501 | | - // \ref{optional.ref.monadic}, monadic operations |
4502 | | - template<class F> constexpr auto and_then(F&& f) const; |
4503 | | - template<class F> constexpr optional<invoke_result_t<F, T&>> transform(F&& f) const; |
4504 | | - template<class F> constexpr optional or_else(F&& f) const; |
4505 | | - |
4506 | | - // \ref{optional.ref.mod}, modifiers |
4507 | | - constexpr void reset() noexcept; |
4508 | | - |
4509 | | - private: |
4510 | | - T* @\exposidnc{val}@ = nullptr; // \expos |
4511 | | - |
4512 | | - // \ref{optional.ref.expos}, exposition only helper functions |
4513 | | - template<class U> |
4514 | | - constexpr void @\exposidnc{convert-ref-init-val}@(U&& u); // \expos |
4515 | | - }; |
| 4458 | + public: |
| 4459 | + // \ref{optional.ref.ctor}, constructors |
| 4460 | + constexpr optional() noexcept = default; |
| 4461 | + constexpr optional(nullopt_t) noexcept : optional() {} |
| 4462 | + constexpr optional(const optional& rhs) noexcept = default; |
| 4463 | + |
| 4464 | + template<class Arg> |
| 4465 | + constexpr explicit optional(in_place_t, Arg&& arg); |
| 4466 | + template<class U> |
| 4467 | + constexpr explicit(@\seebelow@) optional(U&& u) noexcept(@\seebelow@); |
| 4468 | + template<class U> |
| 4469 | + constexpr explicit(@\seebelow@) optional(optional<U>& rhs) noexcept(@\seebelow@); |
| 4470 | + template<class U> |
| 4471 | + constexpr explicit(@\seebelow@) optional(const optional<U>& rhs) noexcept(@\seebelow@); |
| 4472 | + template<class U> |
| 4473 | + constexpr explicit(@\seebelow@) optional(optional<U>&& rhs) noexcept(@\seebelow@); |
| 4474 | + template<class U> |
| 4475 | + constexpr explicit(@\seebelow@) optional(const optional<U>&& rhs) noexcept(@\seebelow@); |
| 4476 | + |
| 4477 | + constexpr ~optional() = default; |
| 4478 | + |
| 4479 | + // \ref{optional.ref.assign}, assignment |
| 4480 | + constexpr optional& operator=(nullopt_t) noexcept; |
| 4481 | + constexpr optional& operator=(const optional& rhs) noexcept = default; |
| 4482 | + |
| 4483 | + template<class U> constexpr T& emplace(U&& u) noexcept(@\seebelow@); |
| 4484 | + |
| 4485 | + // \ref{optional.ref.swap}, swap |
| 4486 | + constexpr void swap(optional& rhs) noexcept; |
| 4487 | + |
| 4488 | + // \ref{optional.ref.iterators}, iterator support |
| 4489 | + constexpr iterator begin() const noexcept; |
| 4490 | + constexpr iterator end() const noexcept; |
| 4491 | + |
| 4492 | + // \ref{optional.ref.observe}, observers |
| 4493 | + constexpr T* operator->() const noexcept; |
| 4494 | + constexpr T& operator*() const noexcept; |
| 4495 | + constexpr explicit operator bool() const noexcept; |
| 4496 | + constexpr bool has_value() const noexcept; |
| 4497 | + constexpr T& value() const; // freestanding-deleted |
| 4498 | + template<class U = remove_cv_t<T>> |
| 4499 | + constexpr remove_cv_t<T> value_or(U&& u) const; |
| 4500 | + |
| 4501 | + // \ref{optional.ref.monadic}, monadic operations |
| 4502 | + template<class F> constexpr auto and_then(F&& f) const; |
| 4503 | + template<class F> constexpr optional<invoke_result_t<F, T&>> transform(F&& f) const; |
| 4504 | + template<class F> constexpr optional or_else(F&& f) const; |
| 4505 | + |
| 4506 | + // \ref{optional.ref.mod}, modifiers |
| 4507 | + constexpr void reset() noexcept; |
| 4508 | + |
| 4509 | + private: |
| 4510 | + T* @\exposidnc{val}@ = nullptr; // \expos |
| 4511 | + |
| 4512 | + // \ref{optional.ref.expos}, exposition only helper functions |
| 4513 | + template<class U> |
| 4514 | + constexpr void @\exposidnc{convert-ref-init-val}@(U&& u); // \expos |
| 4515 | + }; |
4516 | 4516 | } |
4517 | 4517 | \end{codeblock} |
4518 | 4518 |
|
|
0 commit comments