Boost logo

Boost Users :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2007-07-28 17:12:42


""JOAQUIN LOPEZ MU?Z"" <joaquin_at_[hidden]> wrote in message
news:f9a9e060691a.691af9a9e060_at_tid.es...
> 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:
>
> #include <boost/mpl/apply.hpp>
> #include <boost/mpl/assert.hpp>
> #include <boost/type_traits/is_same.hpp>
>
> using namespace boost;
> using namespace boost::mpl;
>
> template<typename T,int=0>
> struct foo
> {
> template<typename Q>
> struct apply{
> typedef Q type;
> };
> };
>
> typedef apply1<foo<_1>,int>::type t1;
>
> BOOST_MPL_ASSERT((is_same<t1,int>));
>
> int main(){}
>
> However, I've tried with GCC 3.4.4 and the static
> assertion fails! I'd like to know:
>
> 1. Whether I'm right in assuming that the code above
> should compile without assertion failures.

Yes.

> 2. What the behavior is for other versions of GCC and
> compilers: reports most welcome!!

Basically, this is a GCC-specific problem caused by a
non-conforming extension that was removed in 4.2.0
(http://gcc.gnu.org/gcc-4.2/changes.html, search for
"(undocumented) extension").

> 3. Whether this is a known problem specific to GCC
> or, more generally, what the status of this issue is.

It is, and it's not a issue anymore starting with GCC 4.2.
You should be able to work around it for older versions
by providing a specialization of the
'boost::mpl::aux::template_arity' template along the
following lines (untested):

    template<typename T,int n>
    struct template_arity<foo<T,n> > : int_<-1> {};

HTH,

--
Aleksey Gurtovoy
MetaCommunications Engineering

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