What differences, if any, between C++03 and C++11 can be detected at run-time?

后端 未结 8 1409
深忆病人
深忆病人 2020-12-02 04:44

It is possible to write a function, which, when compiled with a C compiler will return 0, and when compiled with a C++ compiler, will return 1 (the trivial sulution with

8条回答
  •  攒了一身酷
    2020-12-02 04:52

    This isn't quite a correct example, but it's an interesting example that can distinguish C vs. C++0x (it's invalid C++03 though):

     int IsCxx03()
     {
       auto x = (int *)0;
       return ((int)(x+1) != 1);
    }
    

提交回复
热议问题