std::inplace_vector<T,N>::unchecked_emplace_back

Appends a new element to the end of the container. Typically, the element is constructed using placement-new to construct the element in-place at the location provided by the container. The arguments args… are forwarded to the constructor as std::forward(args)…. Equivalent to return *try_emplace_back(std::forward(args)…);.

# Declarations

template< class... Args >
constexpr reference unchecked_emplace_back( Args&&... args );

(since C++26)

# Parameters

# Return value

back(), i.e. a reference to the inserted element.

# Notes

This section is incompleteReason: Explain the purpose of this API.

# Example

#include <inplace_vector>
#include <new>
#include <print>
#include <string>
#include <utility>
 
int main()
{
    std::inplace_vector<std::pair<std::string, std::string>, 2> fauna;
    std::string dog{"\N{DOG}"};
 
    fauna.unchecked_emplace_back("\N{CAT}", dog);
    fauna.unchecked_emplace_back("\N{CAT}", std::move(dog));
    std::println("fauna = {}", fauna);
 
    // fauna.unchecked_emplace_back("BUG", "BUG"); // undefined behavior: no space
}

# See also