Boost logo

Boost Users :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2005-09-14 23:27:42


On 9/14/05, Bruno Martínez <br1_at_[hidden]> wrote:
> On Mon, 12 Sep 2005 23:31:52 -0300, Bruno Martínez <br1_at_[hidden]>
> wrote:
>
> > Hi.
> >
> > When using pointers to functions with bind, the particular function
> > doesn't play a part in the return value's type of bind. That is
> >
> > void func1();
> > void func2();
> >
> > typeid(boost::bind(&func1)) == typeid(boost::bind(&func1)) // this is
> > true
>
> I've made some progress. What I have now looks like:
>
> template <class T, T&>
> struct nontypeadapt;
>
> template<class Ret, Ret (&func)()>
> struct nontypeadapt <Ret(), func> {
> typedef Ret result_type;
> Ret operator() () { return func(); }
> };
>
> then
>
> typeid(boost::bind(nontypeadapt<void(), func1>())) !=
> typeid(boost::bind(nontypeadapt<void(), func2>()))
>
> However, the signature has to be given at the call site, it's repetitive
> to define all specializations of nontypeadapt, and it brings more
> forwarding problems of it's own. Any ideas?

I think you can only pass functions with external linkage as
parameters to templates, which I think it makes it unusable...

>
> Bruno
>

-- 
   Felipe Magno de Almeida
Developer from synergy and Computer Science student from State
University of Campinas(UNICAMP).
Unicamp: http://www.ic.unicamp.br
Synergy: http://www.synergy.com.br
"There is no dark side of the moon really. Matter of fact it's all dark."

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net