Reputation: 16824
How can I detect the presence of the Concepts TS with GCC 6.1?
This page suggests that the macro __cpp_experimental_concepts
should be predefined in a Concepts TS-supporting implementation. However, the following test program compiles without error on GCC 6.1 with the -fconcepts
flag:
#ifdef __cpp_experimental_concepts
static_assert(false, "Concepts TS found");
#endif
template <typename T>
concept bool Identity = true;
int main() {}
(I would expect either the static_assert
to fire, or the concept
keyword to go unrecognised.)
Does anyone know of any other method to conditionally compile code based on whether Concepts are available?
Upvotes: 2
Views: 556
Reputation: 37626
The correct macro is __cpp_concepts
for GCC:
#ifdef __cpp_concepts
static_assert(false, "Concepts TS found");
#endif
According to this, the name of the macro was changed in a recent draft.
The correct name is from the GCC support page (thanks to Jonathan Wakely), but the linked draft (2015-02-09) still requires __cpp_experimental_concepts
(which is strange... ). However, in this more recent draft (2015-09-25), the name has actually been changed to __cpp_concepts
.
Upvotes: 5