xtd 0.2.0
Loading...
Searching...
No Matches

◆ emplace()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
template<typename... args_t>
iterator xtd::collections::generic::list< type_t, allocator_t >::emplace ( const_iterator  pos,
args_t &&...  args 
)
inline

Inserts a new element into the container directly before pos.

Parameters
posThe iterator before which the new element will be constructed.
argsarguments to forward to the constructor of the element.
Remarks
The element is constructed through std::allocator_traits::construct, which typically uses placement-new to construct the element in-place at a location provided by the container. However, if the required location has been occupied by an existing element, the inserted element is constructed at another location at first, and then move assigned into the required location.
The arguments args... are forwarded to the constructor as std::forward<args_t>(args).... args... may directly or indirectly refer to a value in the container.
If after the operation the new xtd::collections::generic::list::size() is greater than old xtd::collections::generic::list::capacity() a reallocation takes place, in which case all iterators (including the xtd::collections::generic::list::end() iterator) and all references to the elements are invalidated. Otherwise, only the iterators and references before the insertion point remain valid.