Is it a good idea to enable the final
C++11 keyword conditionally to the standard version in a header file? I'm thinking of something like:
#if __cplusplus >= 201103L
# define MY_FINAL final
#else
# define MY_FINAL
#endif
// ...
class Derived : public Base
{
public:
virtual int f() MY_FINAL;
};
I have two doubts here:
- whether the method with and without
final
will be ABI-compatible (it seems reasonable to assume so to me, and a quick check withg++
confirms that), - that the C++98 compiler won't complain when someone tries to override the method. But I believe that documenting the method as don't override it should handle this.