|
Boost Users : |
From: Samuel Charron (chammm_at_[hidden])
Date: 2007-07-28 12:54:52
On 7/28/07, Joaquin M Lopez Munoz <joaquin_at_[hidden]> wrote:
> David Abrahams <dave <at> boost-consulting.com> writes:
>
> > on Fri Jul 27 2007, "JOAQUIN LOPEZ MU?Z" <joaquin-AT-tid.es> wrote:
> >
> > > According to the MPL reference, a placeholder expression
> > > X<a1,..,an> must satisfy (among others) the following
> > > condition:
> > >
> > > "All of X's template parameters, including the
> > > default ones, are types."
> > >
> > > According to that the following should then compile
> > > without errors:
> [...]
> > I don't see how you can conclude the above will compile without error
> > just from (a part of) the definition of placeholder expression.
> >
> > Are you saying that since foo<_1> is not a placeholder expression,
> > when applied to int it should be treated as a metafunction class?
>
> Yes, this is exactly my point. Another way in which foo<_1>
> can be forced to not be treated as a ph expression is this:
>
> // no of parms > BOOST_MPL_LIMIT_METAFUNCTION_ARITY
> template<typename T,
> typename=int,typename=int,typename=int,
> typename=int,typename=int>
> struct foo
> {
> template<typename Q>
> struct apply{
> typedef Q type;
> };
> };
>
> You can try yourself this variation and see that the program
> really resolves to t1 <- int. But for some reason, the
> int=0 variation does not do the same, at least in GCC 3.4.4.
>
> JoaquÃn M López Muñoz
> Telefónica, Investigación y Desarrollo
>
> PS: I'd greatly appreciate if you could you try the snippet
> (the int=0 version) with other compilers --my current compiler
> count is so very limited. Thx!
>
> PPS: In case you're wondering, this is not a purely academic
> question: I've got a real world scenario where I want to
> prevent foo<x> from being treated as a ph expression, namely
> when foo<x> is a metafunction class parameterized by
> a lambda expression (i.e. a ph expression or metafunction
> class) x.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi,
I tried the snippet with :
gcc 4.1.2 : it doesn't compile because of the assert
gcc 4.2.0 : it works
icc 9.1 : it works.
The second snippet works with all compilers.
I already had a discussion about a similar problem on this list, and I
finally conclude that not all compilers are using default parameters
the same way: In a template template expression, some are expecting
the non-type default parameter to be part of the template template
expression, and others are not.
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