相关疑难解决方法(0)

如何消除此模板的歧义?

我有一个将大小作为模板参数的类(live demo):

template <std::size_t SIZE> class A
{
    char b[SIZE];
}
Run Code Online (Sandbox Code Playgroud)

它具有用于不同目的的多个构造函数:

using const_buffer_t = const char (&)[SIZE];
using my_type = A<SIZE>;

A()                         : b{} {} // (1) no params
A(const_buffer_t)           : b{} {} // (2) copy contents of given buffer
A(const char * const)       : b{} {} // (3) copy as many items as they fit into the size
explicit A(const my_type &) : b{} {} // (4) copy constructor

// (5) copy as many items as …
Run Code Online (Sandbox Code Playgroud)

c++ templates disambiguation c++11

5
推荐指数
1
解决办法
507
查看次数

标签 统计

c++ ×1

c++11 ×1

disambiguation ×1

templates ×1