【发布时间】:2014-04-28 21:54:40
【问题描述】:
宏通常用于文本替换。就我而言,我需要有条件地清除一些关键字,以便在没有特定功能的编译器中进行编译。
具体来说,我一直在研究 cpp11 range 这个 sn-p 来自哪里
template <typename C>
struct has_size {
template <typename T>
static constexpr auto check(T*) -> // problem in VS2013
typename std::is_integral<
decltype(std::declval<T const>().size())>::type;
// .. some more stuff
};
我提供这个作为引发问题的示例。在上面的代码中我最终做了
template <typename T>
static
#if COMPILE_WITH_GCC_NEW_ENOUGH
constexpr
#endif
auto check(T*) ->
因为还有其他部分需要将constexpr 替换为const 才能编译。
我要问的是一种表达方式
#define Constexpr ?????????
以便在 gcc 编译中将其替换为 constexpr,在 VS 编译中将其替换为 textually nothing。
【问题讨论】:
-
只需
#define constexpr