Macro for generalized lambda capture

I would like to use the generic lambda capture introduced in C ++ 14 (see Move capture to lambda for an explanation). However, the rest of my code is C ++ 11-friendly. I would like to do something line by line

#ifdef CPP14
// move capture in lambda
#else
// capture by-value
#endif

However, there are no good cross-compiler flags for versioning. Is there anything to offer? (except, of course, defining my own macros)

+4
source share
1 answer

Actually TC is correct, C ++ 11 FDIS says in "16.8 Predefined Macro Names [cpp.predefined]" , which

++ __cplusplus 201103L.

:

, . .

.

#if __cplusplus > 201103L
//c++1y or above
#else
//c++11 or below
#endif

, , _cplusplus ++ 1y.

GCC, , 1 4.7.0.

_cplusplus,

+2

Source: https://habr.com/ru/post/1547523/


All Articles