std::expected::emplace(3)

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

πŸ’– NAME πŸ’–

okay bestie, this is std::expected::emplace from the C++ Standard Libary β€” and the name is literally std::expected::emplace minus std::expected::emplace. iconic repetition, no notes πŸ’…βœ¨

✨ Synopsis ✨

T is not cv void:

template< class... Args >
constexpr T& emplace( Args&&... args ) noexcept;
  • (1) since C++23
template< class U, class... Args >
constexpr T& emplace( std::initializer_list<U> il, Args&&... args ) noexcept;
  • (2) since C++23

T is cv void:

constexpr void emplace() noexcept;
  • (3) since C++23

Constructs an expected value in-place. After the call, has_value() returns true. 🫢

  1. Destroys the contained value, then initializes the expected value contained in *this as if by direct-initializing an object of type T from the arguments std::forward<Args>(args)....

This overload participates in overload resolution only if std::is_nothrow_constructible_v<T, Args...> is true.

  1. Destroys the contained value, then initializes the expected value contained in *this as if by direct-initializing an object of type T from the arguments il and std::forward<Args>(args)....

This overload participates in overload resolution only if std::is_nothrow_constructible_v<T, std::initializer_list<U>&, Args...> is true.

  1. If *this contains an unexpected value, destroys that value.

πŸŽ€ Parameters πŸŽ€

  • args β€” the arguments to pass to the constructor
  • il β€” the initializer list to pass to the constructor

🫢 Return value 🫢

  • 1,2) A reference to the new contained value.
  • 3) (none)

🧚 Notes 🧚

If the construction of T is potentially-throwing, this function is not defined. In this case, it is the responsibility of the user to create a temporary object and move or copy it. 🫑

🌈 Example 🌈

This section is incomplete Reason: no example

πŸ‘‘ See also πŸ‘‘

  • operator= β€” assigns contents (public member function)

πŸ“ Category πŸ“

  • * Todo no example

that’s the whole page, bestie πŸ’– source: http://cppreference.com, version/date: 2024.06.10, page: std::expected::emplace(3) πŸ«ΆπŸ’…

πŸ“¦ where this page comes from