|
Boost : |
From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-27 17:08:00
On Mon, Oct 27, 2003 at 10:06:05AM -1000, David Abrahams wrote:
> Brian McNamara <lorgon_at_[hidden]> writes:
> > Presumably MPL has
> > some magical way to make
> >
> > is_base_of<B,_>
> > and
> > is_base_of<_,D>
> >
> > turn into the corresponding metafunctions that test if "T is a subtype
> > of B" or "T is a supertype of D", respectively, yes?
>
> Well, yes it does. It's just what you quoted above about visual
> binding:
>
> is_base_of<D,_>
>
> Looks like a way of testing whether something is a base of D. How
> would you name a metafunction which tests if something is a base of
> some fixed class Foo? Probably "is_base_of_Foo", right?
Yes. I'm not sure where the boundary between error-prone-ness and
common sense lies. One can say that
fcpp::minus(3)
looks like a function to subtract 3 from a number, but a couple moments'
thought should reveal the correct thing to say is
fcpp::minus(_,3)
I don't think this reveals a flaw in the construction/naming of minus(),
but rather it just reveals a bit of human psychology, namely that we are
prone to slip up when currying a subset of a function's arguments. (In
Haskell, sugar like "infix syntax" and "operator sections" save the
day, but such tools don't exist for C++ template meta-programming.)
IMO this isn't worth the amount of discussion it's receiving, though.
Just give me a "proper" (in the sense of "subset" v "proper subset")
version of is_base_and_derived, as well as the current version, and
call them whatever you like, and I will make sure that my code using it
works.
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk