From: g0dil Date: Wed, 27 May 2009 15:35:25 +0000 (+0000) Subject: Utils: (membind) Fix weird casting error when binding base-class members X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=d498c7507e2eaa191e859ae525df97dc257e0d7a;p=senf.git Utils: (membind) Fix weird casting error when binding base-class members git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1215 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/TimerSource.cc b/Scheduler/TimerSource.cc index fe6b7d1..35e6a5a 100644 --- a/Scheduler/TimerSource.cc +++ b/Scheduler/TimerSource.cc @@ -261,7 +261,7 @@ prefix_ void senf::scheduler::detail::TimerFDTimerSource::reschedule() timer.it_value.tv_nsec = ClockService::in_nanoseconds( timeout_ - ClockService::seconds(timer.it_value.tv_sec)); } - if (timerfd_settime(timerfd_, TIMER_ABSTIME, &timer, 0)<0) + if (timerfd_settime(timerfd_, TFD_TIMER_ABSTIME, &timer, 0)<0) SENF_THROW_SYSTEM_EXCEPTION("timerfd_settime()"); } #endif diff --git a/Utils/Console/Executor.cc b/Utils/Console/Executor.cc index 1a93b6e..3bfa19b 100644 --- a/Utils/Console/Executor.cc +++ b/Utils/Console/Executor.cc @@ -299,9 +299,7 @@ senf::console::Executor::traverseNode(ParseCommandInfo::TokensRange const & path catch (UnknownNodeNameException &) { throw InvalidPathException( senf::stringJoin( - senf::make_transform_range( - boost::make_iterator_range(path.begin(), path.end()), - boost::bind(&Token::value, _1)), + senf::make_transform_range(path, boost::bind(&Token::value, _1)), "/")); } } diff --git a/Utils/impl/membind.hh b/Utils/impl/membind.hh index 5146e4c..8c69a1c 100644 --- a/Utils/impl/membind.hh +++ b/Utils/impl/membind.hh @@ -28,16 +28,22 @@ #include #include -template -boost::function membind(R (T::* fn)(),scOBTYPE ob) +template +boost::function membind(R (T1::* fn)(),T2 scOBTYPE ob) { - return boost::bind(fn,ob); + return boost::bind(fn,static_cast(ob)); } -template -boost::function membind(R (T::* fn)() const,scOBTYPE ob) +template +boost::function membind(R (T1::* fn)() const, T2 const scOBTYPE ob) { - return boost::bind(fn,ob); + return boost::bind(fn,static_cast(ob)); +} + +template +boost::function membind(R (T1::* fn)() const, T2 scOBTYPE ob) +{ + return boost::bind(fn,static_cast(ob)); } // for BOOST_PP_ITERATION() in 2..9 do @@ -49,18 +55,25 @@ boost::function membind(R (T::* fn)() const,scOBTYPE ob) #define scARG(z,n,d) BOOST_PP_CAT(d,n) #define scPARAMS(d) BOOST_PP_ENUM_SHIFTED(BOOST_PP_ITERATION(),scARG,d) -template < typename R, typename T, scPARAMS(typename A) > +template < typename R, typename T1, typename T2, scPARAMS(typename A) > +boost::function +membind(R (T1::* fn)( scPARAMS(A) ), T2 scOBTYPE ob) +{ + return boost::bind(fn, static_cast(ob), scPARAMS(_) ); +} + +template < typename R, typename T1, typename T2, scPARAMS(typename A) > boost::function -membind(R (T::* fn)( scPARAMS(A) ), scOBTYPE ob) +membind(R (T1::* fn)( scPARAMS(A) ) const, T2 const scOBTYPE ob) { - return boost::bind(fn, ob, scPARAMS(_) ); + return boost::bind(fn, static_cast(ob), scPARAMS(_) ); } -template < typename R, typename T, scPARAMS(typename A) > +template < typename R, typename T1, typename T2, scPARAMS(typename A) > boost::function -membind(R (T::* fn)( scPARAMS(A) ) const, scOBTYPE ob) +membind(R (T1::* fn)( scPARAMS(A) ) const, T2 scOBTYPE ob) { - return boost::bind(fn, ob, scPARAMS(_) ); + return boost::bind(fn, static_cast(ob), scPARAMS(_) ); } #undef scPARAMS diff --git a/Utils/membind.hh b/Utils/membind.hh index 83613a8..3b1c4f7 100644 --- a/Utils/membind.hh +++ b/Utils/membind.hh @@ -148,11 +148,11 @@ namespace senf { -#define scOBTYPE T * +#define scOBTYPE * #include "../Utils/impl/membind.hh" #undef scOBTYPE -#define scOBTYPE T & +#define scOBTYPE & #include "../Utils/impl/membind.hh" #undef scOBTYPE