std::experi...al::emplace(3)
π NAME π
bestie, welcome to the std::experi...al::emplace page from the C++ Standard Libary manual π this is your group-chat crash course, and yes we are keeping every detail.
std::experimental::optional::emplace β std::experimental::optional::emplace
β¨ Synopsis β¨
okay so here are the two overloads, and they are giving βin-place constructionβ energy:
template< class... Args > (library
fundamentals TS)
void emplace( Args&&... args );
template< class U, class... Args >
void emplace( std::initializer_list<U> ilist, Args&&... (library
fundamentals TS)
args );
So the vibe is: this constructs the contained value in-place. If *this already contains a value before the call, that contained value is destroyed by calling its destructor. no cap, it really said that.
- Initializes the contained value by direct-initializing (but not direct-list-initializing) with
std::forward<Args>(args)...as parameters. - Initializes the contained value by calling its constructor with
ilist,std::forward<Args>(args)...as parameters. This overload participates in overload resolution only ifstd::is_constructible<T, std::initializer_list<U>&, Args&&...>::valueis true.
πΈ Parameters πΈ
args...β the arguments to pass to the constructorilistβ the initializer list to pass to the constructor
π¦ Type requirements π¦
Tmust be constructible fromArgs...Tmust be constructible fromstd::initializer_listandArgs...
π Return value π
(none) β literally nothing, bestie. it's giving void energy π
π Exceptions π
Any exception thrown by the selected constructor of T. If an exception is thrown, *this does not contain a value after this call β and the previously contained value, if any, had been destroyed.
π«Ά this is the important part: if it throws, the old value is already gone. not a drill.
π See also π
operator=β assigns contents (public member function)
π Category π
* Noindexed pages
okay bye bestie, thatβs the whole page β source/version: http://cppreference.com, date: 2024.06.10, page: std::experi...al::emplace(3). mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms