Created on 2025-11-05.00:00:00 last changed 1 month ago
Proposed resolution:
This wording is relative to N5014.
Modify [indirect.syn], as indicated:
namespace std {
template<class T, class Allocator = allocator<T>>
class indirect {
public:
[…]
// [indirect.obs], observers
constexpr operator const T& () const & noexcept;
constexpr operator T& () & noexcept;
constexpr operator const T&& () const && noexcept;
constexpr operator T&& () && noexcept;
constexpr const T& operator*() const & noexcept;
constexpr T& operator*() & noexcept;
constexpr const T&& operator*() const && noexcept;
constexpr T&& operator*() && noexcept;
constexpr const_pointer operator->() const noexcept;
constexpr pointer operator->() noexcept;
[…]
Modify [indirect.obs], as indicated:
constexpr operator const T& () const & noexcept; constexpr operator T& () & noexcept; constexpr const T& operator*() const & noexcept; constexpr T& operator*() & noexcept;-1- Preconditions: `*this` is not valueless.
-2- Returns: *p.constexpr operator const T&& () const && noexcept; constexpr operator T&& () && noexcept; constexpr const T&& operator*() const && noexcept; constexpr T&& operator*() && noexcept;-3- Preconditions: `*this` is not valueless.
-4- Returns: std::move(*p).
In addition to serving as a better unique_ptr<T> in Pimpl, indirect<T> can also appear as a drop-in replacement for `T` when `T` may conditionally be an incomplete type. In which case, if indirect<T> is convertible to T&, certain tasks can be done without meta-programming (e.g., returning the object of type `T` or indirect<T> from a function with a return type T&).
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-06 16:51:20 | admin | set | messages: + msg15565 |
| 2025-11-05 00:00:00 | admin | create | |