hi Felipe! On 11/12/2012 06:11 PM, Felipe Magno de Almeida wrote:
Hello,
I'm trying to remove_if a few elements from a fusion sequence. But it is instantiating my predicate with the placeholder from MPL later on. Including with as_vector.
The following code generates the error code I'm pasting by the end of the message. I'm using GCC 4.7.2 and Linux x86_64. If I wrap meta_func<mpl::_1> in a mpl::lambda<>::type then the errors following the first error messages is what I get. I'm not sure if I'm doing something wrong here. If anyone could please shed some light, I would really appreciate it.
#include <boost/fusion/include/as_vector.hpp> #include <boost/fusion/include/remove_if.hpp>
namespace mpl = boost::mpl; namespace fusion = boost::fusion;
struct element { typedef mpl::false_ type; };
template <typename T> struct meta_func { typedef typename T::type type; };
int main() { fusion::vector<element, element> e; fusion::as_vector(fusion::remove_if<meta_func<mpl::_1> >(e)); }
a simple solution would be to make meta_func of the form: template<typename T> struct meta_func { typedef mpl::true_ type ; }; template<> struct meta_func<element> { typedef mpl::false_ type ; }; but I'm not sure if it's the way you intend it, since remove_if will remove items when the predicate evaluates to true, so maybe swap the logic? hope it helps ;) cheers Philipp