std::inplace_vector:
A pointer to an element of an inplace_vector may be passed to any function that expects a pointer to an element of a C-array.
That part is similar as for (most) std::vectors (vector of bool can be different)
This can be pretty handy if you deal with a C-Library where you provide arrays of variable size which have an upper limit, the limit may be defined by the library, maybe defined by your use case.
I think something which looks and feels like a std::vector is much nicer to use than a plain old C-array with a separate size variable.
On a std::vector it is easy to forget to reserve() properly which may lead to invalid pointers or just worse performance.
With a std::inplace_vector the compiler forces you to think about the reserved memory and instead of hard to detect invalid pointers you will notice the error at the push_back() which tries to exceed the max size.
So in some cases it can prevent you from making mistakes.
The elements of std::inplace_vector are stored as direct member of the object and thus potentially on the stack.
Watch out with big sizes on local variables, the stack is typically much smaller than the heap.
Edit: I came across another good reason:
A std::vector (or anything else which requires dynamic allocation) is not usable within a constexpr expression.
The inplace storage of std::inplace_vector allows it to be used as a constexpr value.
You could do things like iterate over the container and calculate the sum of all elements at compile time (as long as the container and all contents are constexpr).
Sure, the same is possible with an std::array but for the array you need to know exactly how many elements you have and use index access, while std::inplace_vector supports a simple push_back
inplace_vectorwon't use the heap, it does directly state: "Its capacity is fixed and its elements are stored within theinplace_vectorobject itself." This also means moves to/from them aren't normally "fast" or exception safe like they are withstd::vector.std::inplace_vectorbefore, thanks for learning something new today :). Now, I just wonder whether we will ever have a combination ofvectorandinplace_vectorin the standard library, something as Boost'ssmall_vectoror LLVM'sSmallVector.