
Hi,
I have a function where I think mpl::for_each might be use full, but I
can not get it to work:
template<typename SYM>
BaseGamePlateHash holdClear(const BaseGamePlateHash& h) {
struct ClearSymbol {
ClearSymbol(BaseGamePlateHash& h) : hash(h) { }
template <typename _SYM>
void operator()(_SYM) {
hash.clear<_SYM>();
}
BaseGamePlateHash& hash;
};
BaseGamePlateHash new_hash = h;
typedef typename boost::mpl::remove< SymbolCounts, SYM>::type ClearSymbols;
ClearSymbol clearsymbol(new_hash);
clearsymbol(SYM()); // this is working
//boost::mpl::for_each< boost::mpl::vector<SYM> >( clearsymbol );
// not compiling, this is just a simple test
//boost::mpl::for_each< ClearSymbols >( clearsymbol ); // not
compiling, this is what I want to do...
return new_hash;
}
I had the impression that the following two statements would do the same:
clearsymbol(SYM()); // this is working
should be equal to:
boost::mpl::for_each< boost::mpl::vector<SYM> >( clearsymbol ); // not compiling
But this does not seems to be the case...
This is the compile error I get when enabling: boost::mpl::for_each<
boost::mpl::vector<SYM> >( clearsymbol );
test7.cxx:303:13: error: 'holdClear(const BaseGamePlateHash
&)::ClearSymbol::operator()(SymbolCntDice)::ClearSymbol::hash' is not
a member of class 'ClearSymbol'
hash.clear<_SYM>();
^
/usr/local/include/boost/mpl/for_each.hpp:75:9: note: in instantiation
of function template specialization 'holdClear(const BaseGamePlateHash
&)::ClearSymbol::operator()<SymbolCntDice>' requested here
aux::unwrap(f, 0)(boost::get(x));
^
/usr/local/include/boost/mpl/for_each.hpp:100:5: note: in
instantiation of function template specialization
'boost::mpl::aux::for_each_impl<false>::execute