On Wed, Sep 2, 2020 at 6:30 PM Steve Hearnden <steve@hearnden.org.uk> wrote:

My proposal was intended to allow Arthur’s sample to be written as below.

 

template<class T, size_t Cap>

class fixed_capacity_vector {

    [[unconstructed]] T data_[ Cap];


So it saves you exactly zero lines of code. What's the point? (Trick question: There is no point. You don't need this feature.)
 

    T* data() { return data_; } // no cast necessary

    const T* data() const { return const_cast<const T*>(data_); }   // better cast - just a const_cast


FYI, you don't need the const_cast either; the data members of a `const fixed_capacity_vector` are themselves const already.

–Arthur