Boost logo

Boost :

From: Alisdair Meredith (alisdair.meredith_at_[hidden])
Date: 2005-06-01 17:46:50


Rob Stewart wrote:

> I fail to see how relying on behavior of the language is not
> having sympathy for those reading the code. This is akin to
> explicitly invoking a default base ctor in an initializer list in
> my mind.

Explicit is good.
Consistent is also good.

Consider:

struct base
{
  double a;
};

struct derived1 : base
{
  derived1() : base() {}
};

struct derived2 : base
{
  derived2() {}
};

Which of the 2 derived classes do you think is more subtle? derived1,
which initialized base so member a == 0.0, or derived2 which does not
initialize base, so a could be anything including a troublesome NaN.

Which would you rather call attention to by breaking with convention?

And how many 'typical' C++ programmers do you believe are even aware of
the difference?

Relying (un-necessarily) on subtlety in the language, and trying to
second guess whether it was intended or not, is generally a hard way to
share code and an invitation for trouble in a shared-source environment.

This thread is also heading off topic for a Boost list and would be
more at home in comp.lang.c++.moderated.

AlisdairM


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk