Topic: Explicit-keyword and default constructors


Author: ncm@netcom.com (Nathan Myers)
Date: 1995/09/05
Raw View
In article <42gjou$1m9@proffa.cc.tut.fi>,
Pulkkinen Esa <p150651@proffa.cc.tut.fi> wrote:
>class A
>{
>public:
>  explicit A() {}
>};
>A a; // Legal? (IMHO: no) [yes]
>A b=A(); // OK, as always
>A c(); // OK, c is a function returning A :)
>
>class B : public A {}
>// Default constructor generated, and calls A()? Legal?
>// (IMHO: no) ... [yes]
>My analysis:
>[dcl.fct.spec]/5 states: ...
>[class.conv.ctor]/1: ...
>
>These were the only places I could find, where the semantics of
>the explicit specifier was explained.

Esa has called attention to an embarrassment: the April '95 Draft
doesn't actually specify *any* semantics for "explicit", because
it defines "nonconverting constructor" but never uses the term.

Steve's explanation of the intent is accurate, though.  The omission
is considered "editorial", which means fixing it doesn't require a
committee vote.

Nathan Myers
myersn@roguewave.com

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]