std::experi...pagate_const(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::experimental::propagate_const::propagate_const β€” bestie, this is the constructor page for propagate_const, and the manual name folded in at the top is C++ Standard Libary. The header calls it std::experi...pagate_const(3), and we are about to get into all five constructor overloads, no cap ✨


🌸 Synopsis 🌸

constexpr propagate_const() = default;              (1) (library
fundamentals TS v2)
constexpr propagate_const( propagate_const&& p ) =  (2) (library
fundamentals TS v2)
default;
template< class U >
/* see below */ constexpr propagate_const(          (3) (library
fundamentals TS v2)
propagate_const<U>&& pu );
template< class U >                                 (4) (library
fundamentals TS v2)
/* see below */ constexpr propagate_const( U&& u );
propagate_const( const propagate_const& ) = delete; (5) (library
fundamentals TS v2)

Let t_ be the private data member that is the wrapped pointer-like object. Okay so here's the breakdown, one iconic constructor at a time 🫢

  1. Constructs a propagate_const, default-initializing this->t_.
  2. Explicitly defaulted move constructor that move constructs this->t_ from p.t_.
  3. Initializes this->t_ as if by direct-non-list-initialization from the expression std::move(pu.t_). This constructor does not participate in overload resolution unless std::is_constructible<T, U>::value is true, and is explicit if and only if std::is_convertible<U, T>::value is false.
  4. Initializes this->t_ as if by direct-non-list-initialization with the expression std::forward<U>(u). This constructor does not participate in overload resolution unless std::is_constructible<T, U>::value is true and std::decay_t<U> is not a specialization of propagate_const. This constructor is explicit if and only if std::is_convertible<U, T>::value is false.
  5. Copy constructor is explicitly deleted. propagate_const is non-copyable.

πŸŽ€ Parameters πŸŽ€

  • p β€” another propagate_const object to move from.
  • pu β€” another propagate_const object of a different specialization to move from.
  • u β€” another object to initialize the contained pointer with.

πŸ’‘ Notes πŸ’‘

In Library Fundamental TS v2 (based on C++14), (4) and (5) are typically implemented in explicit/non-explicit overload pairs. Since Library Fundamental TS v3 (based on C++20), they can be implemented in conditional explicit specifiers.


Source/version/date tea β˜•: http://cppreference.com, 2024.06.10, and the footer title std::experi...pagate_const(3). That’s the whole page, bestie β€” go construct something iconic πŸ’…βœ¨

πŸ“¦ where this page comes from