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

Appends copies of initial elements in rg before end(), until all elements are inserted or the internal storage is exhausted (i.e. size() == capacity() is true).

# Declarations

template< container-compatible-range<T> R >
constexpr std::ranges::borrowed_iterator_t<R> try_append_range( R&& rg );

(since C++26)

# Parameters

# Return value

An iterator pointing to the first element of rg that was not inserted into *this, or ranges::end(rg) if no such element exists.

# Notes

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

# Example

#include <cassert>
#include <initializer_list>
#include <inplace_vector>
 
int main()
{
    using I = std::inplace_vector<int, 8>;
    auto nums = I{1, 2, 3};
    const auto rg = {-1, -2, -3};
 
    auto it = nums.try_append_range(rg);
    assert(nums.size() == 6);
    assert((nums == I{1, 2, 3, -1, -2, -3}));
    assert(it == rg.end());
 
    it = nums.try_append_range(rg);
    assert(nums.size() == 8);
    assert((nums == I{1, 2, 3, -1, -2, -3, -1, -2}));
    assert(it == rg.begin() + 2);
}

# See also