Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2007-03-28 19:49:15


JOAQUIN LOPEZ MU?Z wrote:
> I think you want to write
>
> mpl::end<Constraints>::type

Thanks for the suggestion, but it doesn't change the behavior of the program:
the result of the insertion of a new element into the two-element set is a new
set with only two elements (one of the original elements is lost). Please try
it and see if you get the same thing I do.

> Well, excuse me if the following is obvious to you,
> but ::type is to a metafunction what actual invocation is
> to a run-time function. So, mpl::end<Constraints> refers
> to the name of the entity, but does not actually compute
> its "return value" unless you add the ::type suffix.

I don't think this always holds. For example, I don't need to add the ::type
suffix when I make a typedef or when I do an assertion:

   typedef mpl::set<A, B> MySet;
   BOOST_MPL_ASSERT(( mpl::equal<mpl::set<A,B>, mpl::set<A,B> > ));

Until this thread, I figured I could wallow in ignorance about when ::type was
needed and when not, because I assumed that if I got it wrong, the code would
not compile. (Sort of the way a lot of people think about const...) Now I know
better, sigh.

Scott


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net