MPL apply on some exotic system

I'm compiling some code on the Cell processor main CPU using its dedicated gcc. The code is calling mpl::apply1 onto a custom meta-function. The compiler -v is : ppu-g++ -v Using built-in specs. Target: ppu Configured with: ../toolchain/gcc/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-as=/usr/bin/ppu-as --with-ld=/usr/bin/ppu-ld --enable-threads --with-system-zlib --disable-checking --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,fortran,ada --disable-nls --enable-clocale=gnu --enable-version-specific-runtime-libs --with-long-double-128 --program-prefix=ppu- --disable-bootstrap --host=ppu --build=powerpc64-unknown-linux-gnu --target=ppu Thread model: posix gcc version 4.1.1 The code : template<class T> struct scalar_mode { typedef mpl::false_ status; struct base { template<class Type> struct apply : mpl::if_< is_same<T,none>, Type, T> {}; }; }; typedef mpl::apply1< scalar_mode<none>::base, float>::type type; The compiler errors are : ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp: In instantiation of 'const int boost::mpl::aux::template_arity_impl<nt2::scalar_mode<nt2::none>::base, 1>::value': ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:93: instantiated from 'const int boost::mpl::aux::template_arity<nt2::scalar_mode<nt2::none>::base>::value' ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:98: instantiated from 'boost::mpl::aux::template_arity<nt2::scalar_mode<nt2::none>::base>' ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/apply.hpp:48: instantiated from 'boost::mpl::apply1<nt2::scalar_mode<nt2::none>::base, float>' essais/simd.cpp:13: instantiated from here ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:85: error: call of overloaded 'arity_helper(boost::mpl::aux::type_wrapper<nt2::scalar_mode<nt2::none>::base>, boost::mpl::aux::arity_tag<1>)' is ambiguous ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:30: note: candidates are: char (& boost::mpl::aux::arity_helper(...))[1] ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:37: note: char (& boost::mpl::aux::arity_helper(boost::mpl::aux::type_wrapper<F<T1> >, boost::mpl::aux::arity_tag<1>))[2] [with F = nt2::scalar_mode<T>::base, T1 = nt2::none] ../../../lib/include/boost-1_35/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:37: note: char (& boost::mpl::aux::arity_helper(boost::mpl::aux::type_wrapper<F<T1> >, boost::mpl::aux::arity_tag<1>))[2] [with F = nt2::scalar_mode<T>::base, T1 = nt2::none] I know that "officially" boost is not supported on this kidn of platform but most of my code compiles and works flawlessly except for this. Any hints on what to do to fix this even locally ? Thanks in advance

AMDG Joel Falcou wrote:
I'm compiling some code on the Cell processor main CPU using its dedicated gcc. The code is calling mpl::apply1 onto a custom meta-function.
<snip>
I know that "officially" boost is not supported on this kidn of platform but most of my code compiles and works flawlessly except for this. Any hints on what to do to fix this even locally ?
Does mpl::apply work for namespace scope metafunctions? You can try moving the metafunction outside the class and typedefing it. Alternately, you can try quote: #include <boost/mpl/bool.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/apply.hpp> #include <boost/mpl/quote.hpp> using namespace boost; struct none {}; template<class T> struct scalar_mode_base { template<class Type> struct apply : mpl::if_< is_same<T,none>, Type, T> {}; }; template<class T> struct scalar_mode { typedef mpl::false_ status; //template<class Type> //struct base_impl : mpl::if_< is_same<T,none>, Type, T> {}; //typedef mpl::quote1<base_impl> base; typedef scalar_mode_base<T> base; }; typedef mpl::apply1< scalar_mode<none>::base, float>::type type; In Christ, Steven Watanabe

Steven Watanabe a écrit :
Does mpl::apply work for namespace scope metafunctions? You can try moving the metafunction outside the class and typedefing it. Alternately, you can try quote: Thanks, mpl::quote did the trick. I've modified all such instance of apply in my code and all works perfectly now. What's exactly the "missing feature" that quote emulates on - i assume - non-conformant compiler ?
-- Joel FALCOU Research Engineer @ Institut d'Electronique Fondamentale Université PARIS SUD XI France

AMDG Joel FALCOU wrote:
Thanks, mpl::quote did the trick. I've modified all such instance of apply in my code and all works perfectly now. What's exactly the "missing feature" that quote emulates on - i assume - non-conformant compiler ?
quote converts a metafunction (of the form template<class T>) to a metafunction class (with a nested apply). I don't really understand the problem. I couldn't duplicate it, so I was just guessing possible variations. In Christ, Steven Watanabe
participants (3)
-
Joel Falcou
-
Joel FALCOU
-
Steven Watanabe