| 1 | // ================================================================ // |
|---|
| 2 | // // |
|---|
| 3 | // File : cxxforward.h // |
|---|
| 4 | // Purpose : macros for forward usage of C++11 features // |
|---|
| 5 | // w/o loosing compatibility to C++03 compilers // |
|---|
| 6 | // // |
|---|
| 7 | // Coded by Ralf Westram (coder@reallysoft.de) in December 2012 // |
|---|
| 8 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 9 | // http://www.arb-home.de/ // |
|---|
| 10 | // // |
|---|
| 11 | // ================================================================ // |
|---|
| 12 | |
|---|
| 13 | #ifndef CXXFORWARD_H |
|---|
| 14 | #define CXXFORWARD_H |
|---|
| 15 | |
|---|
| 16 | #ifndef GCCVER_H |
|---|
| 17 | #include "gccver.h" |
|---|
| 18 | #endif |
|---|
| 19 | |
|---|
| 20 | #if defined(__cplusplus) |
|---|
| 21 | # if (GCC_VERSION_CODE >= 407) |
|---|
| 22 | # if (__cplusplus == 199711L) |
|---|
| 23 | # else |
|---|
| 24 | # if (__cplusplus == 201103L) |
|---|
| 25 | # define ARB_ENABLE_Cxx11_FEATURES |
|---|
| 26 | # else |
|---|
| 27 | # if (__cplusplus == 201402L) |
|---|
| 28 | # define ARB_ENABLE_Cxx11_FEATURES |
|---|
| 29 | // # define ARB_ENABLE_Cxx14_FEATURES // not needed yet |
|---|
| 30 | # else |
|---|
| 31 | # error Unknown C++ standard defined in __cplusplus |
|---|
| 32 | # endif |
|---|
| 33 | # endif |
|---|
| 34 | # endif |
|---|
| 35 | # endif |
|---|
| 36 | #else |
|---|
| 37 | # warning C compilation includes cxxforward.h |
|---|
| 38 | #endif |
|---|
| 39 | |
|---|
| 40 | #ifdef ARB_ENABLE_Cxx11_FEATURES |
|---|
| 41 | |
|---|
| 42 | // C++11 is enabled starting with gcc 4.7 in ../Makefile@USE_Cxx11 |
|---|
| 43 | // |
|---|
| 44 | // Full support for C++11 is available starting with gcc 4.8. |
|---|
| 45 | // Use #ifdef Cxx11 to insert conditional sections using full C++11 |
|---|
| 46 | # if (GCC_VERSION_CODE >= 408) |
|---|
| 47 | # define Cxx11 1 |
|---|
| 48 | # endif |
|---|
| 49 | |
|---|
| 50 | // allows static member initialisation in class definition: |
|---|
| 51 | # define CONSTEXPR constexpr |
|---|
| 52 | # define CONSTEXPR_RETURN constexpr |
|---|
| 53 | |
|---|
| 54 | // allows to protect overloading functions against signature changes of overload functions: |
|---|
| 55 | # define OVERRIDE override |
|---|
| 56 | |
|---|
| 57 | #else |
|---|
| 58 | // backward (non C++11) compatibility defines: |
|---|
| 59 | # define CONSTEXPR const |
|---|
| 60 | # define CONSTEXPR_RETURN |
|---|
| 61 | # define OVERRIDE |
|---|
| 62 | |
|---|
| 63 | #endif |
|---|
| 64 | |
|---|
| 65 | #else |
|---|
| 66 | #error cxxforward.h included twice |
|---|
| 67 | #endif // CXXFORWARD_H |
|---|