How can I check at compile-time whether compiler support C++11 override
keyword? Maybe boost or something like this?
Asked
Active
Viewed 387 times
0

Felix Glas
- 15,065
- 7
- 53
- 82

FrozenHeart
- 19,844
- 33
- 126
- 242
-
1Nit-pick: `override` is not a keyword. – juanchopanza Feb 04 '14 at 11:36
-
2@Snps I'd point out that the accepted solution on that question does not work for `[[override]]` since Boost doesn't support it. So closing this question as a duplicate is a bad idea, IMO. – KitsuneYMG Feb 04 '14 at 13:11
-
The second most popular answer (`__cplusplus`) should work though, shouldn't it? A quote from a comment: "C++11 sets the value of __cplusplus to 201103L. That asserts full conformance to the 2011 standard;" This might not catch browsers that support override but not the complete c++11 standard though. And it wouldn't be pretty and not worth it for `override` in my opinion. – eerorika Feb 04 '14 at 15:18
1 Answers
2
Straightforward way does not exist. There are two ways:
Use good old autoconf or corresponding functionality in your other build system. cmake has one and, so does scons and any other system.
Meticulously check for the compiler versions known to support the features. Fortunately the list of compilers recently shrunk to 3 (clang, gcc and msc++) and Boost maintainers have done some of the work (it seems they didn't care about the
override
feature).

Jan Hudec
- 73,652
- 13
- 125
- 172
-
1As far as I can see, boost doesn't have the appropriate macro to check override support – FrozenHeart Feb 04 '14 at 12:50