Boost logo

Boost Users :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-03-28 13:10:31


Samuel Charron wrote:
> Hi,
>
> I'm currently using the apply metafunction, and I have two different
> behaviors depending on the used compiler.
>

<snip code>

>
> With g++ 4.1, there is no error.
> With g++ 4.2, icc 9.1, an error occurs:

I can't verify, but I believe it's might be:

> - g++ :
> no class template named 'apply' in 'class
> std::tr1::unordered_set<mpl_::arg<1>, std::equal_to<int>,
> std::tr1::hash<int>, std::allocator<int>, false>'
                                             ^^^^^^

Placeholder substitution won't work in argument lists of templates with
non-type parameters (well, sometimes it does work, but only if there is
a default and if the compiler deduces template template arguments in a
certain, probably non-standard way).

>
> Can you give me some help to make this work ?
>

To work around this limitation, you can use a custom Metafunction

     template<typename T>
     struct specialize_unordered_set
     {
         typedef std::tr1:unordered_set<T> type;
     };

and then use it in a Placeholder Expression. Alternatively (this way
might save you some compile time), you can write a Metafunction Class to
replace the Placeholder Expression:

     struct specialize_unordered_set
     {
         template<typename T>
         struct apply
         {
             typedef std::tr1::unordered_set<T> type;
         };
     };

HTH. Regards,
Tobias


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