|
Boost Users : |
From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2006-02-22 16:58:50
Thanks. I have problems compiling it.
../Test.cpp:74: error: invalid initialization of non-const reference
of type 'std::_Rb_tree_iterator<std::pair<const std::pair<int, int>,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
> >&' from a temporary of type 'std::_Rb_tree_iterator<std::pair<const
std::pair<int, int>, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >'
../Test.cpp:71: warning: unused variable 'itr'
Here is my code:
main() {
typedef pair<int, int> intPair;
typedef map < intPair, string> pairMapString;
int x = 3;
pairMapString myMap;
pairMapString::iterator& itr = find_if(myMap.begin(),
myMap.end(),
bind(&intPair::first,
bind(&pairMapString::value_type::first, _1)) == x);
}
On 2/22/06, Kevin Heifner <heifner_k_at_[hidden]> wrote:
> Meryl Silverburgh wrote:
> > I have a map with key is a pair:
> > typedef map < pair<int, int>, string> pairMapString;
> >
> > pair<int, int> key(1,3);
> > map[key] = "one";
> >
> > How can I create a binary function using boost lamba which check the
> > first value of the pair of the key of the map?
> >
> > void add(pairMapString;& myMap, int x) {
> >
> > iterator& itr = find_if(myMap.begin(), myMap.end(),
> > bind(equal_to < int >(),
> > bind(&BlockDataPairMap::value_type::first::value_type::first, _1 ) ,
> > x) );
>
> using namespace std;
> using namespace boost::lambda;
>
> typedef pair<int, int> intPair;
> typedef map < intPair, string> pairMapString;
>
> void add(pairMapString& myMap, int x) {
> pairMapString::iterator& itr = find_if(myMap.begin(),
> myMap.end(),
> bind(&intPair::first,
> bind(&pairMapString::value_type::first, _1)) == x);
> }
>
> KevinH
> --
> Kevin Heifner heifner @ ociweb.com http://heifner.blogspot.com
> Object Computing, Inc. (OCI) www.ociweb.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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