template的用法疑问
- C/C++ code
template<bool> struct _Destroy_aux { template<typename _ForwardIterator> static void __destroy(_ForwardIterator __first, _ForwardIterator __last) { for (; __first != __last; ++__first) std::_Destroy(std::__addressof(*__first)); } };template<bool>
template后面不都是class 或typename这里写个bool是怎么个意思啊!
[解决办法]
谷歌非类型模板参数
[解决办法]
介个叫 explicit specialization.
[解决办法]
[解决办法]
一般像楼主这样光是一个bool的非模板类型参数,常常会与explicit specialization结合使用,所以可能会配合下面这样的形式
- C/C++ code
template<> struct _Destroy_aux<true>//这里也可能是false { ... };