现在的位置: 首页 > 综合 > 正文

ISO/IEC14882:2003之条款14.4——类型等价

2012年06月15日 ⁄ 综合 ⁄ 共 483字 ⁄ 字号 评论关闭

14.4 类型等价

两个template-id引用相同的类或函数,如果其模板名是相同的,它们引用相同的模板,其类型template-argument是相同的类型,其整型或枚举类型的非类型template-argument有相同的值,其指针或引用类型的非类型template-argument引用相同的外部对象或函数,并且其模板template-argument引用相同的模板。[例:

template<class E, int size> class buffer { /* ... */ };
buffer<char, 2*512> x;
buffer<char, 1024> y;

声明了x和y为相同的类型,并且

template<class T, void(*err_fct)()> class list { /* ... */ };
list<int, &error_handler1> x1;
list<int, &error_handler2> x2;
list<int, &error_handler2> x3;
list<char, &error_handler2> x4;

声明了x2和x3是相同的类型。它们的类型不同于x1和x4。

抱歉!评论已关闭.