Re: [sigc] How to use sigc::bind<>
- From: Jeff Franks <jcf tpg com au>
- To: Martin Schulze <martin-ml hippogriff de>
- Cc: Murray Cumming Comneon com, libsigc-list gnome org
- Subject: Re: [sigc] How to use sigc::bind<>
- Date: Mon, 10 Nov 2003 18:03:31 +1100
Martin Schulze wrote:
Unfortunately, C++ doesn't allow us to specify default template
arguments for functions. Therefore, the number always needs to be
specified. Or does somebody know a trick to make the number optional?
But it lets you overload template functions: This works. I added the
following three function template to <sigc++/adaptors/bind.h> as a test.
I quickly tested each one with the example I sent you previously - and
they all works Ok.
template <class T_bound1, class T_functor>
template <class T_bound1, class T_functor>
inline bind_functor<0, typename unwrap_reference<T_bound1>::type, T_functor>
bind(const T_functor& _A_func, T_bound1 _A_b1)
{
return bind_functor<0, typename unwrap_reference<T_bound1>::type,
T_functor>
(_A_func, _A_b1);
}
template <class T_bound1, class T_bound2, class T_functor>
inline bind_functor<0, typename unwrap_reference<T_bound1>::type,
bind_functor<0, typename unwrap_reference<T_bound2>::type,
T_functor> >
bind(const T_functor& _A_functor, T_bound1 _A_b1, T_bound2 _A_b2)
{
return bind_functor<0, typename unwrap_reference<T_bound1>::type,
bind_functor<0, typename unwrap_reference<T_bound2>::type,
T_functor> >
(bind<0>(_A_functor, _A_b2), _A_b1);
}
template <class T_bound1, class T_bound2, class T_bound3, class T_functor>
inline bind_functor<0, typename unwrap_reference<T_bound1>::type,
bind_functor<0, typename unwrap_reference<T_bound2>::type,
bind_functor<0, typename unwrap_reference<T_bound3>::type,
T_functor> > >
bind(const T_functor& _A_functor, T_bound1 _A_b1, T_bound2
_A_b2,T_bound3 _A_b3)
{
return bind_functor<0, typename unwrap_reference<T_bound1>::type,
bind_functor<0, typename unwrap_reference<T_bound2>::type,
bind_functor<0, typename unwrap_reference<T_bound3>::type,
T_functor> > >
(bind<0>(_A_functor, _A_b2, _A_b3),_A_b1);
}
Regards,
Jeff Franks.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]