Boost logo

Boost :

From: Reid Sweatman (reids_at_[hidden])
Date: 1999-08-19 13:56:48

> What about:
> class foo {
> public:
> template <bool initialise = false>
> foo( value_type& value ) { if (initialise) Initialise(value); }
> template <bool initialise = false>
> foo() { if (initialise) Initialise(default_value); }
> };
> In this case no moderately smart compiler will generate a
> line of code for
> initialization when initialise == false.
> [Unfortunately, if my memories are correct this code won't
> compile on MS VC++
> 5.0, Service Pack 3:-( ]
> The overhead in coding is not too big and the code does not
> rely that much on
> the optimization capabilities of compilers.

Looks pretty good. It may actually have been what Valentin meant, and I
just missed it because it wasn't phrased in template form. As it happens,
for at least the next month that's exactly the compiler I'm stuck with <g>.
I'm not so sure it's fixed in the latest one, though. There's a lot to be
desired in VC++ template and namespace handling, and that's as far as I'll
go with that topic, since I've already been chastened once <g>.

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