sizeof2.c

来自「linux下编程用 编译软件」· C语言 代码 · 共 31 行

C
31
字号
// { dg-do compile }// Contributed by Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>// PR c++/9259: Allow non-qualified member calls in sizeof expressions.template <bool> struct StaticAssert;template <> struct StaticAssert<true> {};struct S {  static int check ();  static double check2 ();  static const int value = sizeof(check());  static const int value2 = sizeof(check2());};template <class>struct T{  static int check ();  static double check2 ();  static const int value = sizeof(check());  static const int value2 = sizeof(check2());};StaticAssert<(S::value == sizeof(int))> s;StaticAssert<(S::value2 == sizeof(double))> s2;StaticAssert<(T<void>::value == sizeof(int))> t;StaticAssert<(T<void>::value2 == sizeof(double))> t2;

⌨️ 快捷键说明

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