zdravko.monov
10/8/2008 3:56:00 PM
On Oct 8, 2:55 pm, Leandro Melo <ltcm...@gmail.com> wrote:
> On 8 out, 08:04, khalderon <zdravko.mo...@gmail.com> wrote:
>
>
>
> > I have a map and want to invoke an object member function over each
> > element:
>
> > typedef map<string, pair<int, int> > table_t;
> > table_t table;
>
> > class delay_analyzer {
> > void calculate_conn(pair<string, pair<int, int> >&);
>
> > void delay_analyzer::process()
> > {
> > for_each
> > (
> > table.begin(), table.end(),
> > bind1st
> > (
> > mem_fun_ref(&delay_analyzer::calculate_conn, this)
> > )
> > );
>
> > }
> > };
>
> > But my compiler says:
> > msr.cpp: In member function ‘void delay_analyzer::process()’:
> > msr.cpp:108: error: no matching function for call to ‘mem_fun_ref(void
> > (delay_analyzer::*)(std::pair<std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> >, std::pair<int, int>
>
> > >&), delay_analyzer* const)’
>
> > Any ideas what to do?
>
> Hi.
>
> Initially, shouldn't bind1st take two arguments? Then, shouldn't
> mem_fun_ref take only one argument? So, you might have mixed things
> around...
>
> --
> Leandro T. C. Melo
I am afraid this was not the only problem. I get these errors:
/usr/include/c++/4.2/bits/stl_function.h: At global scope:
/usr/include/c++/4.2/bits/stl_function.h: In instantiation of
‘std::binder1st<std::mem_fun1_ref_t<void, delay_analyzer,
std::pair<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::pair<int, int> >&> >’:
msr.cpp:106: instantiated from here
/usr/include/c++/4.2/bits/stl_function.h:405: error: forming reference
to reference type ‘std::pair<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::pair<int, int>
>&’
/usr/include/c++/4.2/bits/stl_function.h:411: error: forming reference
to reference type ‘std::pair<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::pair<int, int>
>&’
/usr/include/c++/4.2/bits/stl_function.h: In function
‘std::binder1st<_Operation> std::bind1st(const _Operation&, const
_Tp&) [with _Operation = std::mem_fun1_ref_t<void, delay_analyzer,
std::pair<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::pair<int, int> >&>, _Tp =
delay_analyzer*]’:
msr.cpp:106: instantiated from here
/usr/include/c++/4.2/bits/stl_function.h:421: error: no matching
function for call to ‘delay_analyzer::delay_analyzer(delay_analyzer*
const&)’
msr.cpp:92: note: candidates are: delay_analyzer::delay_analyzer(const
char*)
msr.cpp:11: note: delay_analyzer::delay_analyzer(const
delay_analyzer&)
/usr/include/c++/4.2/bits/stl_algo.h: In function ‘_Function
std::for_each(_InputIterator, _InputIterator, _Function) [with
_InputIterator = std::_Rb_tree_iterator<std::pair<const
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::pair<int, int> > >, _Function =
std::binder1st<std::mem_fun1_ref_t<void, delay_analyzer,
std::pair<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::pair<int, int> >&> >]’:
msr.cpp:106: instantiated from here
/usr/include/c++/4.2/bits/stl_algo.h:159: error: no match for call to
‘(std::binder1st<std::mem_fun1_ref_t<void, delay_analyzer,
std::pair<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::pair<int, int> >&> >) (std::pair<const
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::pair<int, int> >&)’