Boost logo

Boost :

From: Reid Sweatman (reids_at_[hidden])
Date: 1999-08-18 13:58:13

> What do you mean exactly ?
> The following ?
> class foo
> {public:
> foo (bool initialise) { if (initialise) value = 0; }
> };

Well, something more like:

        class foo {
                foo(bool initialise = false) { if(initialize) Initialize();

save with template syntax, which I assume we're leaving out for clarity's
sake. With the Boolean as the last argument, it might also make sense to
allow yet another argument, to specify the initialization value, as follows:

        class foo {
                foo(value_type& T = nValue,bool initialise = false) {
if(initialize) Initialize(T); }

where T is the value_type for the container in question (assuming templates,
of course), and nValue is its value (not necessarily a numeric as my tidbit
of Hungarian notation implies). Then you'd supply the last two arguments
only if the Boolean were false. On second thought, I guess you could also
test the value_type argument and not even have the Boolean, but that might
unnecessarily complicate the container's value_type, which might get
expensive with large containers. Besides, as you pointed out earlier, the
idea is to modify the iterator, not the container being iterated.

I admit, I may be unclear on what's being initialized here: the iterator
itself, or the container, since I've lost some thread continuity. Still,
the idea should work in the former case the same way; just make value_type
be the value type of the iterator. I had the distinct impression it was the
container you were allocating an iterator for that was to be initialized or
not, though. Correct me if I've misunderstood, please.

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