我有一个类型声明为:
using Buffer = std::unique_ptr<std::array<uint8_t, N>>;
Run Code Online (Sandbox Code Playgroud)
我还有一个模板函数声明为:
template<typename Buffer>
bool temp_func()
{
// do something
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Buffer 类型调用 temp_func:
temp_func<Buffer>();
Run Code Online (Sandbox Code Playgroud)
现在,在 temp_func 中,我想获取该类型的大小Buffer,而不创建该类型的实例。
我需要的是类似于std::tuple_size<Buffer>::value除了我不能调用std::tuple_size,unique_ptr只能直接调用std::array。
我只能使用 C++11。我该怎么做?