|
Boost : |
From: Martin Bonner (Martin.Bonner_at_[hidden])
Date: 2007-07-10 09:33:33
From: Andrew Sutton
> On Jul 10, 2007, at 9:02 AM, Cédric Venet wrote:
>
>>
>>> 2. I've run into the situation where parameters are truly optional -
>>> they don't specify default values, but optional components to an
>>> algorithm. What's the best way to implement this? How can I test
>>> (within a function) to determine if a parameter has been passed or
>>> not? I've hacked together an approach using a `not_given` struct. Is
>>> there something already like this in the library.
>>
>> boost.optional should serve your purpose.
>
> I had previously considered that as an option (no pun).
> Unfortunately, I don't think this helps if I choose to adopt a
> compile-time function selection. Otherwise, it would work very nicely
> at runtime. I've still got it on my short list of solutions.
I'm not clear what your "truly optional" parameters are actually for, but if (for example) they supply a functor could the default value be some sort of identity functor?
-- Martin Bonner Project Leader PI SHURLOK LTD Telephone: +44 1223 441434 / 203894 (direct) Fax: +44 1223 203999 Email: martin.bonner_at_[hidden] www.pi-shurlok.com disclaimer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk