sizeof2.c

来自「this is a gcc file, you can download it 」· C语言 代码 · 共 21 行

C
21
字号
// Although template class B is not used at all, it causes the// incorrect specialization of A to be selected// Adapted from testcase by Oskar Enoksson <osken393@student.liu.se>extern "C" void abort();template<int N, class T> // Base classclass A { public: static int n() { return sizeof(T); } };template<int N> // Derived #1class B: public A<N,char[N]> {};template<int N, int M> // Derived #2 (wrong!)class C: public A<N,char[M]> {};int main() {  if (C<1,2>::n() != 2)    abort();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?