Boost logo

Boost :

From: James Curran (jamescurran_at_[hidden])
Date: 2003-05-22 14:33:37


Rob Stewart wrote:
> Disagree strongly all you want, but I only use pointers to
> indicate optional arguments and to pass references (general
> meaning of the word) to objects that are expected to outlive the
> object to which they are given (usually in the ctor). In the
> former case, the argument may be null so I check for that case.
> In the latter, I often use RCSPs, but not always.
>
> I don't use non-const reference parameters often (and when I do
> they are always the first argument(s)). I find they work
> intuitively. You see, such functions always indicate, by their
> very name, that they are providing a value, so the name quite
> reasonably documents the output parameter.

    Actually, I think you agree more with me than you think.

Here is a sample of usage we are discussion:

 desc.add_options<custom_description>()
        // First parameter describes option name/short name
        // The second is parameter to option
        // The third is description
        ("help,h", "", "print usage message")
        ("output,o", parameter("<pathname>", &ofile), "pathname for
output");

Recast it to use a non-const reference parameter for "ofile" following your
guidelines of "the first argument" and "functions always indicate, by their
very name, that they are providing a value".

-- 
Truth,
James Curran
www.noveltheory.com (personal)
www.njtheater.com (professional)

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