[bind] bug for vc7.1

#include <boost/bind.hpp> using namespace boost; #include <vector> struct base { int i; }; struct test : public base { // if you uncomment here and comment above, it'll work // int i; }; int main() { typedef std::vector<test> vector; vector v; // generates compile-time error on vc7.1 bind<int&>( mem_fn(&test::i), _1) (v.front()); return 0; } Peter, any workarounds, until its' fixed? Best, John -- John Torjo Freelancer -- john@torjo.com -- http://www.torjo.com/logview/ - viewing/filtering logs is just too easy!

On Wed, 05 May 2004 20:14:18 +0200, John Torjo wrote:
struct base { int i; };
struct test : public base { // if you uncomment here and comment above, it'll work // int i; };
int main() { typedef std::vector<test> vector; vector v; // generates compile-time error on vc7.1 bind<int&>( mem_fn(&test::i), _1) (v.front()); return 0; }
it also fails in other compilers, notably Comeau compiler in relaxed and strict mode. Here's error message: "C:\WINGNU\boost_1_31_0\boost/bind.hpp", line 193: error #433: qualifiers dropped in binding reference of type "boost::_bi::bind_t<int &, boost::_mfi::dm<int, base>, boost::_bi::list1<boost::_bi::list_av_1<boost::arg<1>>::B1>>::result_ type" to initializer of type "const int" return unwrap(f, 0)(a[a1_]); ^ detected during: instantiation of "R boost::_bi::list1<A1>::operator()(boost::_bi::type<R>, F, A &) [with A1=boost::_bi::list_av_1<boost::arg<1>>::B1, R=boost::_bi::bind_t<int &, boost::_mfi::dm<int, base>, boost::_bi::list1<boost::_bi::list_av_1<boost::arg<1>>::B 1>>::result_type, F=boost::_mfi::dm<int, base>, A=boost::_bi::list1<std::vector<test, std::allocator<test>>::value_type &>]" at line 33 of "C:\WINGNU\boost_1_31_0\boost/bind/bind_template.hpp" instantiation of "boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F, L>::operator()(A1 &) [with R=int &, F=boost::_mfi::dm<int, base>, L=boost::_bi::list1<boost::_bi::list_av_1<boost::arg<1>>: :B1>, A1=std::vector<test, std::allocator<test>>::value_type]" at line 20 of "T313.cpp" (I hope above lines won't get wrapped) Regards B.

John Torjo wrote:
#include <boost/bind.hpp> using namespace boost; #include <vector>
struct base { int i; };
struct test : public base { // if you uncomment here and comment above, it'll work // int i; };
int main() { typedef std::vector<test> vector; vector v; // generates compile-time error on vc7.1 bind<int&>( mem_fn(&test::i), _1) (v.front()); return 0; }
Yes, this is an unfortunate side effect of the current mem_fn implementation that relies on overloading tricks instead of enable_if + is_base_of for portability reasons.
Peter, any workarounds, until its' fixed?
Please use int test::* pm = &test::i; bind<int&>( mem_fn(pm), _1) (v.front()); if possible.

Peter, any workarounds, until its' fixed?
Please use
int test::* pm = &test::i; bind<int&>( mem_fn(pm), _1) (v.front());
if possible.
got it, thanks. will try it. -- John Torjo Freelancer -- john@torjo.com -- http://www.torjo.com/logview/ - viewing/filtering logs is just too easy!
participants (3)
-
Bronek Kozicki
-
John Torjo
-
Peter Dimov