Eric Niebler の range-v3 ライブラリの使用方法を学ぼうとしてソース コードを読んだところ、次のマクロ定義が見つかりました。
#define CONCEPT_PP_CAT_(X, Y) X ## Y
#define CONCEPT_PP_CAT(X, Y) CONCEPT_PP_CAT_(X, Y)
/// \addtogroup group-concepts
/// @{
#define CONCEPT_REQUIRES_(...) \
int CONCEPT_PP_CAT(_concept_requires_, __LINE__) = 42, \
typename std::enable_if< \
(CONCEPT_PP_CAT(_concept_requires_, __LINE__) == 43) || (__VA_ARGS__), \
int \
>::type = 0 \
/**/
つまり、要するに、次のようなテンプレート定義です。
template<typename I, typename O,
CONCEPT_REQUIRES_(InputIterator<I>() &&
WeaklyIncrementable<O>())>
void fun_signature() {}
は次のように翻訳されます。
template<typename I, typename O,
int a_unique_name = 42,
typename std::enable_if
<false || (InputIterator<I>() &&
WeaklyIncrementable<O>()), int>::type = 0
>
void fun_signature() {}
そのマクロがそのように実装されている理由を知りたいです。なぜその整数が必要なのですか? また、テンプレート引数false || cond
だけでなく、なぜそれが必要なのですか?cond