C++ Logo


Advanced search

Subject: [ub] WG23 - paper on safe means of special member functions
From: Peter Sommerlad (peter.sommerlad_at_[hidden])
Date: 2018-03-12 15:37:33

Hi folks

I took the task from MISRA C++ to write a paper on senseful class
designs, i.e., categories of class types with respect to
defining/declaring special member functions with the least amount of
safety risks, i.e. by developer surprises. C++ syntax allows much more
than is useful in that context, so a goal is to restrict (rule-of-zero
vs. rule-of-plenty) and funnel useful construction principles for class

Initially MISRA C++ came up with the following useful type categories:

* value types (following rule-of-zero, copyable in general)
* monomorphic object types (no-copying, no virtual, just encapsulation
of (mutable) stuff to implement an abstraction)
* polymorphic object types (no-copying, no-move, defaulted virtual dtor
in base class)
* resource management types (move only, or sharing, non-default dtor) -
might be obsoleted by unique_resource and existing RAII types, but not
sure in general (own value types might need that for memory, but I
believe they could/should use unique_ptr then, but still might require a
special dtor for deleting contained elements of a non-default
constructible type)

There might be exceptions, but MISRA expects a paper to be able to refer to.

I wonder in which of the plenty (and unfamiliar to me) sections of WG23
paper such a guideline would fit, if at all. Having it as a WG21-SG12
paper is OK as well, but I think WG23 could benefit from it as well.

Further ideas and guidance appreciated. I hope to have such a paper
ready for Rapperswil meeting (time permitting).


Prof. Peter Sommerlad
Institute for Software: Better Software - Simple, Faster!
HSR Hochschule für Technik Rapperswil
Oberseestr 10, Postfach 1475, CH-8640 Rapperswil
http://ifs.hsr.ch http://cevelop.com http://linticator.com
tel:+41 55 222 49 84 == mobile:+41 79 432 23 32
fax:+41 55 222 46 29 == mailto:peter.sommerlad_at_[hidden]

SG12 list run by sg12-owner@lists.isocpp.org