samedi 25 février 2023

get the size of std::array inside unique_ptr without an instance in c++

I have a type declared as:

using Buffer = std::unique_ptr<std::array<uint8_t, N>>;

I also have a template function declared as:

template<typename Buffer>
bool temp_func()
{
    // do something
}

and I'm calling temp_func with type Buffer:

temp_func<Buffer>();

now, inside temp_func I want to get the size of the type Buffer without creating an instance of this type.

what I need is something similar to std::tuple_size<Buffer>::value except I can't call std::tuple_size on unique_ptr, only directly on std::array.

I can use C++11 only. How can I do it?

Aucun commentaire:

Enregistrer un commentaire