|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-02-19 18:09:48
Ed Brey wrote:
>>> [Use of a member function instead of a free function.]
>>
>> It's easy to make this case if you assume dependent variants are an
>> edge case.
>
> Let's assume that dependent variants are not an edge case. Would you
> say that the advantages of tight binding for non-template cases and
> prettier syntax for dependent variants are each strong enough to
> justify a dual interface, i.e. free and member?
>
> Interestingly, of the two, I'd say that member is most natural and
> free is pragmatic, working around the compiler's lack of omnicience.
I'll also be needing variant a lot from inside template code. I dislike the
template keyword that gets in the way. IMO, the way to go is the
C++ cast style syntax: extract<T>(v). There should only be one way
to do this. Not two. And FWIW, there's a precedent. Although currently,
boost::tuples has two ways to access its elements get<N>(t) and t.get<N>(),
the TR (and the one that will be a part of the standard) for tuples does not
have the member get anymore. IMO, this is a strong case *for* the free
cast style and *against* the member function style. The variant and optional
should strive to follow tuple's lead. In fact, come to think of it, why not just:
get<T>(v)
???
-- Joel de Guzman joel_at_[hidden] http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk