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。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案