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?
N
in your declaration? – ExcitorBuffer::element_type
would be your array type. Andstd::tuple_size
would work on that type. – TessieBuffer
(i.e.std::unique_ptr<std::array<uint8_t, N>>
), the size ofstd::array<uint8_t, N>
or the valueN
? These are all different things and your question seems to imply all three at different places. – Cryoscopysizeof
and std::declval but it might be better if you define an alias for the intermediate typestd::array<uint8_t, N>
, and then haveusing Buffer = std::unique_ptr<Intermediate_t>;
– Quinarray::size()
is nonstatic, so it requires an instance. Instead, you can usestd::tuple_size<typename Buffer::element_type>::value
. – WillnerN
is hard coded unsigned value:std::size_t N = 50000U
. I want to get backN
– Infringement