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

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

    #include 
    
    template void test(T t) { t.first = false; }
    
    bool isCpp0x()
    {
       bool b = true;
       test( std::make_pair(b, 0) );
       return b;
    }
    

提交回复
热议问题