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

后端 未结 8 1417
深忆病人
深忆病人 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:59

    I got an inspiration from What breaking changes are introduced in C++11?:

    #define u8 "abc"
    
    bool isCpp0x() {
       const std::string s = u8"def"; // Previously "abcdef", now "def"
       return s == "def";
    }
    

    This is based on the new string literals that take precedence over macro expansion.

提交回复
热议问题