[vtk-developers] Introducing (optional) C++11 features in VTK

Marcus D. Hanwell marcus.hanwell at kitware.com
Mon Aug 18 13:45:37 EDT 2014


Hi,

As we move forward, it would be great to get a feeling for people's
thoughts about integrating some components of C++11 optionally. So if
C++11 is available/enabled, there are several features we could enable
optionally at compile time.

A very simple example is that of the new override keyword, that is
used to indicate that a member function is overriding a virtual
function. Using this can avoid mistakes where the signature changes
and derived classes are missed. It can be defined in a header (empty
on old compilers, override with recent compilers). Final is similar,
indicating that the virtual function cannot be overridden in derived
classes.

This would introduce changes to the VTK coding style, where we now use
virtual for all virtual functions (first declaration, or subsequent
overrides). We could introduce this gradually for new code, even
having one or two dashboards compiling this way would help spot simple
errors such as an incorrect signature not actually overriding a
function, but in fact declaring a new virtual for example.

In these cases I would suggest simple naming, so VTK_OVERRIDE and
VTK_FINAL would be used where a C++11 only code would simply use the
new keywords.

Thoughts, objections? There are lots of other features, and I know it
will be a while before we can use them all but it would be great to
make a start with some of the easier ones that can improve code
quality with little overhead.

Marcus



More information about the vtk-developers mailing list