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

后端 未结 8 1413
深忆病人
深忆病人 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 05:11

    From this question:

    struct T
    {
        bool flag;
        T() : flag(false) {}
        T(const T&) : flag(true) {}
    };
    
    std::vector test(1);
    bool is_cpp0x = !test[0].flag;
    

提交回复
热议问题