[gdal-dev] Big three rules for C++ classes

Mateusz Loskot mateusz at loskot.net
Sat Jul 11 20:56:34 EDT 2009


Christopher Hunt wrote:
> Hi there,
>
> I've just started using the classes from the ogr_geometry API and note
> that they do not obey the C++ Rule of Three:
>
> http://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)

Christopher,

Yes, you are right.
When working with GDAL/OGR classes, it's reasonable to be kind of
suspicious and sensitive to implicit assumptions not reflected in the code
itself. Personally, I consider them as "C with classes" than full-blown
super-duper modern-fancy C++ :-)

It's a good idea to scan the archives to learn more about that. For instance:

http://lists.osgeo.org/pipermail/gdal-dev/2001-July/003082.html
http://lists.osgeo.org/pipermail/gdal-dev/2006-May/009100.html
http://lists.osgeo.org/pipermail/gdal-dev/2005-January/004916.html
...

> Perhaps the copy ctor and assignment operators should receive a
> private scope in OGRGeometry unless they are implemented of course.

Safe implicit assumption: all GDAL/OGR classes are not CopyConstructible
nor Assignable types, in terms of of the C++ standard.

Best regards,
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the gdal-dev mailing list