A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../../cpp/utility/variant/emplace.html below:

std::variant<Types...>::emplace - cppreference.com

template< class T, class... Args >
T& emplace( Args&&... args );

(1) (since C++17)
(constexpr since C++20) (2) (since C++17)
(constexpr since C++20) (3) (since C++17)
(constexpr since C++20) (4) (since C++17)
(constexpr since C++20)

Creates a new value in-place, in an existing variant object

1)

Equivalent to

emplace<I>(std::forward<Args>(args)...)

, where

I

is the zero-based index of

T

in

Types...

.

2)

Equivalent to

emplace<I>(il, std::forward<Args>(args)...)

, where

I

is the zero-based index of

T

in

Types...

.

3)

First, destroys the currently contained value (if any). Then

direct-initializes

the contained value as if constructing a value of type

T_I

with the arguments

std::forward<Args>(args)...

. If an exception is thrown,

*this

may become

valueless_by_exception

.

[edit] Parameters args - constructor arguments to use when constructing the new value il - initializer_list argument to use when constructing the new value [edit] Return value

A reference to the new contained value.

[edit] Exceptions

1-4) Any exception thrown during the initialization of the contained value.

[edit] Notes [edit] Example [edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior P2231R1 C++20 emplace was not constexpr while the required operations can be constexpr in C++20 made constexpr [edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4