Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-06-23 09:35:41

Is there any chance of getting rid of 'explicit' on the
default constructor for reg_expression?

This currently breaks Felix, which requires all types
to be implicitly default constructible. I can relax
the requirements, but it has two undesirable consequences:

         1) forces generation of explicit default initialisation
                  for every class, class member, and variable,
           which complicates the code generator and
            severaly clutters the generated code

        2) incurs an undesirable performance hit,
           initialising integral values to 0,
           and possibly invoking the copy constructor

It also breaks C compatibility (the shape of a struct
is currently C compatible: no member functions,
which ensures that if the component types are POD
types, then the struct is also a POD).

There is a tension between making C++ easier to
generate, and making it easier to use correctly
for human programmers. Note that 'generating'
code includes templates:

        template<class T> void f() {
                T t; // woops! not if T has explicit default ctor
                T t(); // woops! illformed local function declaration
                T t = T(); // woops: performance hit for PODs
                             // and possibly other types if the copy ctor
                             // is invoked by a dumb compiler

AFAIK the only way to avoid the performance hit is to get rid of

John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper
download Interscript

Boost list run by bdawes at, gregod at, cpdaniel at, john at