Boost logo

Boost Users :

Subject: [Boost-users] [lambda] lambda member access
From: Micha³ Nowotka (mmmnow_at_[hidden])
Date: 2009-01-29 13:49:16


In function:

void clean_data (MyMap& map)
{
        remove_if(map.begin(), map.end(), (&lambda::_1 )->*(&pair< X* const,
double >::second) <= m_epsilon);
}

where:

typedef std::map<const X*,double> MyMap;

I get error:

c:\program files\microsoft visual studio
9.0\vc\include\algorithm(1240) : error C2582: 'operator =' function is
unavailable in 'std::pair<_Ty1,_Ty2>'
        with
        [
            _Ty1=const hapl::Haplotype *const ,
            _Ty2=double
        ]
        c:\program files\microsoft visual studio
9.0\vc\include\algorithm(4949) : see reference to function template
instantiation '_OutIt
std::_Remove_copy_if<std::_Tree<_Traits>::iterator,_OutIt,_Pr>(_InIt,_InIt,_OutIt,_Pr,std::_Range_checked_iterator_tag)'
being compiled
        with
        [
            _OutIt=std::_Tree<std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>>::iterator,
            _Traits=std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>,
            _Pr=boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::lessorequal_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2,boost::lambda::other_action<boost::lambda::member_pointer_action>>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,double
std::pair<hapl::Haplotype *const ,double>::* const
,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,const
double,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,
            _InIt=std::_Tree<std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>>::iterator
        ]
        c:\program files\microsoft visual studio
9.0\vc\include\algorithm(1309) : see reference to function template
instantiation '_OutIt
stdext::unchecked_remove_copy_if<std::_Tree<_Traits>::iterator,_FwdIt,_Pr>(_InIt,_InIt,_OutIt,_Pr)'
being compiled
        with
        [
            _OutIt=std::_Tree<std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>>::iterator,
            _Traits=std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>,
            _FwdIt=std::_Tree<std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>>::iterator,
            _Pr=boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::lessorequal_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2,boost::lambda::other_action<boost::lambda::member_pointer_action>>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,double
std::pair<hapl::Haplotype *const ,double>::* const
,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,const
double,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,
            _InIt=std::_Tree<std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>>::iterator
        ]
        c:\users\kott\documents\visual studio
2008\projects\mbi\implementation\src\main.cpp(631) : see reference to
function template instantiation '_FwdIt
std::remove_if<std::_Tree<_Traits>::iterator,boost::lambda::lambda_functor<T>>(_FwdIt,_FwdIt,_Pr)'
being compiled
        with
        [
            _FwdIt=std::_Tree<std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>>::iterator,
            _Traits=std::_Tmap_traits<const hapl::Haplotype
*,double,std::less<const hapl::Haplotype
*>,std::allocator<std::pair<const hapl::Haplotype *const
,double>>,false>,
            T=boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::lessorequal_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2,boost::lambda::other_action<boost::lambda::member_pointer_action>>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,double
std::pair<hapl::Haplotype *const ,double>::* const
,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,const
double,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>,
            _Pr=boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::lessorequal_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2,boost::lambda::other_action<boost::lambda::member_pointer_action>>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,double
std::pair<hapl::Haplotype *const ,double>::* const
,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,const
double,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>
        ]

I don't get it because i found somewhere
(http://www.lukaszczerwinski.pl/boost_lambda_member_access.html)
similar example that (should) work fine:

std::map< std::string , int > someMap;

using boost::lambda::_1;

std::for_each(
    someMap.begin(),
    someMap.end(),
    std::cout
        << ( & _1 ) ->* ( & std::pair< std::string const, int >::first )
        << std::endl
);

--
Micha³ Nowotka

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