Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: How to conv...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 11 of 13 Topic 9564 of 9807
Post > Topic >>

Re: How to convert a pointer to member function type to a const member one

by dizzy <dizzy@[EMAIL PROTECTED] > May 7, 2008 at 11:04 AM

Hi

mcostalba wrote:

<snip>
>          template<class U> static
>          yes_type detect(helper<&U::operator()>*);
> 
>          template<class U> static
>          yes_type detect(helper_const<&U::operator()>*);

Not sure if the previously discussed solutions does sup****t it but this
version at least seems to me broken in regard to overloaded operator().
Supose you have a static_visitor functor (a functor with many overloaded
operator()(T&) each taking a different T, usually used with a static
visitor aproach). It would be nice if is_compatible<> would determine or
not if there is a suitable overload for the signature you want. The
expression "&U::operator()" would give an amibuity error in case of
overloading (which is usually solved either wraping it with a static_cast
to the exact function type wanted from the overload set or used as
initialization expression for a pointer/reference to function variable).
So
a solution might be "helper<static_cast<ptm>(&U::operator())>" and
something similar for the const version.

I'm also a little puzzled that "&U::operator()" does not give compile
error
in case of not giving a functor to is_compatible<> because I don't think
SFINAE helps here, you have an invalid "value expression" not an
invalid "type expression", but quite possible I misunderstand this.

-- 
Dizzy


      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 13 Posts in Topic:
How to convert a pointer to member function type to a const memb
mcostalba <mcostalba@[  2008-04-30 10:38:30 
Re: How to convert a pointer to member function type to a const
nickf3 <nickf3@[EMAIL   2008-04-30 17:04:17 
Re: How to convert a pointer to member function type to a const
smolensky@[EMAIL PROTECTE  2008-04-30 21:54:58 
Re: How to convert a pointer to member function type to a const
"Devdatt Lad" &  2008-04-30 21:54:37 
Re: How to convert a pointer to member function type to a const
Greg Herlihy <greghe@[  2008-04-30 22:17:24 
Re: How to convert a pointer to member function type to a const
mcostalba <mcostalba@[  2008-05-01 13:43:23 
Re: How to convert a pointer to member function type to a const
"Roman.Perepelitsa@[  2008-05-05 07:09:51 
Re: How to convert a pointer to member function type to a const
mcostalba <mcostalba@[  2008-05-06 00:57:14 
Re: How to convert a pointer to member function type to a const
"Roman.Perepelitsa@[  2008-05-06 08:21:31 
Re: How to convert a pointer to member function type to a const
mcostalba <mcostalba@[  2008-05-06 12:47:31 
Re: How to convert a pointer to member function type to a const
dizzy <dizzy@[EMAIL PR  2008-05-07 11:04:35 
Re: How to convert a pointer to member function type to a const
"Roman.Perepelitsa@[  2008-05-07 11:04:05 
Re: How to convert a pointer to member function type to a const
mcostalba <mcostalba@[  2008-05-07 18:33:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 20:09:27 CDT 2008.