Hi,
This is with RHEL, gcc version 3.4.6. I *think* the boost version is 1.32.0.
-bash-3.00$ gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-8)
-bash-3.00$
The complete mini program I use is:
[code]
#include <map>
#include
#include
class A {
public:
void reset() {}
};
typedef boost::shared_ptr<A> ptr_type;
typedef std::map map_type;
map_type m;
int main()
{
m[1] = ptr_type(new A());
m[2] = ptr_type(new A());
for_each (m.begin(), m.end(),
boost::bind(&A::reset,
boost::bind(&map_type::value_type::second, _1)));
return 0;
}
[/code]
The following is the compiler error received:
[output]
-bash-3.00$ g++ -o tc tc.cpp
/usr/include/boost/bind.hpp: In member function `void
boost::_bi::list1<A1>::operator()(boost::_bi::type<void>, F&, A&, int) [with
F = boost::_mfi::mf0, A = boost::_bi::list1&>, A1 = boost::_bi::bind_t >, boost::_bi::list1 > >]':
/usr/include/boost/bind/bind_template.hpp:32: instantiated from `typename
boost::_bi::result_traits::type boost::_bi::bind_t::operator()(A1&) [with A1 = std::pair, R = void, F =
boost::_mfi::mf0, L =
boost::_bi::list1 >, boost::_bi::list1 > > >]'
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:158:
instantiated from `_Function std::for_each(_InputIterator, _InputIterator,
_Function) [with _InputIterator = std::_Rb_tree_iterator >, _Function = boost::_bi::bind_t, boost::_bi::list1 >,
boost::_bi::list1 > > > >]'
tc.cpp:24: instantiated from here
/usr/include/boost/bind.hpp:228: error: no match for call to
`(boost::_mfi::mf0) (ptr_type)'
/usr/include/boost/bind/mem_fn_template.hpp:44: note: candidates are: R
boost::_mfi::mf0::operator()(T*) const [with R = void, T = A]
/usr/include/boost/bind/mem_fn_template.hpp:49: note: R
boost::_mfi::mf0::operator()(U&) const [with U = ptr_type, R = void, T
= A]
/usr/include/boost/bind/mem_fn_template.hpp:54: note: R
boost::_mfi::mf0::operator()(T&) const [with R = void, T = A]
-bash-3.00$
[/output]
Anyway, since it works on VC7.1 I imagine that it was fixed in some later
version of the library.
Thanks,
--Kevin
On Wed, Mar 4, 2009 at 11:49 AM, Peter Dimov wrote:
Kevin Ludwig:
Hi,
I've recently been making more use of boost::bind, and I coded the
following, which I thought would work:
class A {
public:
void reset () {}
};
typedef std::map map_type;
map_type m;
std::for_each (m.begin(), m.end(),
boost::bind(&A::reset,
boost::bind(&map_type::value_type::second, _1)));
but fails to compile.
This compiles for me with MSVC 7.1. What compiler and Boost version do you
use? What errors do you get?
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
--
Kevin