How to force use of curiously recurring template pattern in C++
我有以下基本模板类。
1 2 3 4 5 6 | template<typename T> class Base { public: void do_something() { } }; |
它是用来作为一个奇怪的重复模板模式。它应该像
我要做的是把一个
我不知道这是否是实现这一目标的最佳方式。我觉得很恶心。
但是我想做的更多。我想确保
(P)1.Make the constructor(or destructor)of EDOCX1 commercial private,and then make EDOCX1 commercial a EDOCX1 commercial 2.This way the only thing that can construct/destruct a EDOCX1 a menocx1 is a EDOCX1.(p)
(P)如果你的阶级包含了一些代码说:(p)字母名称(P)如果EDOCX1的英文字母1不符合EDOCX1的英文字母0,它们将成为一个汇编错误。(p)(P)This kind of check is formased in C++11 so you don't have to write it by hand and can get helpful mistake messages:(p)字母名称(P)As to ensuring that EDOCX1 penographic 0's type parameter is exactly the class that is deriving from it,that seems conceptually flawed.a class that is acting as a base class can't"talk about"the type that is inhering it.It may be inherited more than once through multiple inheritance,or not at all.(p)
(P)两个美好的夜晚如此遥远。这是另一个用以产生海关准入的方法(在这种情况下是一个建筑商)的特点。It provides an absolute guarantee of correct use while not exposing private methods in the base to the derived.(p)(P)它还可用于控制以其他方法获取基于个案的基于个案的数据。(p)字母名称