首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

template的用法疑点

2012-09-17 
template的用法疑问C/C++ code templateboolstruct _Destroy_aux{templatetypename _ForwardIterators

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.
[解决办法]
探讨
介个叫 explicit specialization.

[解决办法]
一般像楼主这样光是一个bool的非模板类型参数,常常会与explicit specialization结合使用,所以可能会配合下面这样的形式
C/C++ code
template<>    struct _Destroy_aux<true>//这里也可能是false    {     ...    }; 

热点排行