Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-07-12 13:40:13


David Abrahams wrote:
> That's because void_ is for MPL internal use only; it's not a type
> you should manipulate

While I agree that _some_ user needs for a special unique type a
better handled by introducing a new one (otherwise you'll get yourself
into situation like we have right now, only in your own code :), I don't
agree that we should deny the occasional need for a special type in
many simpler cases - like Drazen's one. It would just make user life
unnecessary more complicated than it should be.

Besides, 'void_' _is_ a public type:

    begin<non-sequence-type>::type === void_
    order<Set,non-existing-key>::type === void_

and a couple of others I don't remember off hand :).

> (I think Aleksey doesn't believe me, but I'm
> about to prove it... <wink>).

I don't _agree_ :).

>
> Observe the definition of identity (comments added for exposition
> purposes):
>
> template<typename T = void_>
> struct identity
> {
> typedef T type;
> };
>
>
> // identity<void_> is a metafunction class which makes it efficient
> // to pass mpl::identity<> where a lambda expr/metafunction class is
> // expected.
> template<>
> struct identity< void_ >
> {
> template<
> class T1, class T2 =void_, class T3 =void_, class T4 =void_, class
T5 =void_
> >
> struct apply
> : identity< T1 >
> {};
> };
>
> // specialization of lambda<identity<> > for efficiency.
> template<>
> struct lambda< identity< void_ > >
> {
> typedef identity< void_ > type;
> };

IMO we should just stop using 'void_' for internal purposes and give it
up to users :).

Aleksey


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