提升::池中不需要模板参数
No template parameters needed in boost::pool
声明boost::poor如下。
boost::pool<> Obj();
我很好奇如何制作一个不需要模板参数而只需要<>的类模板?
我试着把它作为助推::pool.hpp和pool.fwd.hpp.中的pool
template<class T>
class Fakepool { }; // pool.hpp
template<class T = int>
class Fakepool; // boost::pool's declaration in poolfwd.hpp
int main()
{
Fakepool<float> a;
Fakepool<> a2; // Can't do this with only <>
}//main()
提前感谢!
这就是您想要的吗?
template<class T = int>
class Fakepool { };
int main()
{
Fakepool<float> a; // Use float
Fakepool<> a2; // Default as int
}
你也可以这样做(我想这就是你当时的想法)。这里的关键字是default template arguments
。然而,在您的示例中,您在声明类之前定义了它,这就是问题所在。
template<class T = int>
class Fakepool;
template<class T>
class Fakepool { };
int main()
{
Fakepool<float> a;
Fakepool<> a2;
}
相关文章:
- 无法使用模板参数编译提升元状态机
- 如何将提升回调作为参数传递给方法?
- 提升::P设置选项无法使所有参数都处于位置状态
- 提升::精神::qi::语法和可变参数模板
- 提升 MPL 排序模板参数包
- 使用提升的模板实例化:传递额外的参数
- 提升线程:术语的计算结果不为 0 个参数
- 在没有模板参数的情况下提升make_shared
- 提升程序参数可以解析WSTRING,但将其迫使其施加到字符串中
- 提升program_options:在 3D 矢量中读取作为命令行参数
- 提升 ODEINT 太多参数无法发挥作用
- 提升程序选项:参数被多次检测到
- 提升预定义为带有参数的全局 lambda 的变体访问者
- 使用可变参数模板参数提升变体访问者
- 可以对提升精神规则进行参数化
- 提升 1.55,而 13 信号参数错误数
- 使用动态参数提升内存池
- 使用额外参数提升变体访客
- 函数中的默认参数提升
- 使用默认参数提升 Python make_constructor