Tim*_*ans 3 c++ decltype c++11
我有一个C++模块,它在C++ 03上下文和C++ 11上下文中编译.当它编译为C++ 11时,我decltype用来查找变量的类型.在C++ 03中,我可以(出于我的目的)decltype根据非标准定义为宏typeof:
// add zero to get rid of const qualifier on the type
#define decltype(x) typeof((x) + 0)
Run Code Online (Sandbox Code Playgroud)
当然我想使用原始版本(decltype如果可用),并仅在宏不可用时定义宏.我如何测试可用性decltype?
我#ifndef __cpp_decltype按照http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3694.htm的建议进行了尝试,但它不起作用.