logo       

Re: Using function_traits: msg#00320

lib.boost.user

Subject: Re: Using function_traits

> I'm trying to use the function traits to extract the return type of a
template parameter,
> but it's not compiling.
>
> Any ideas what's wrong here?

Yes, function_traits takes a function type as parameter, *not* a function
pointer type:

function_traits<int (int, double)> // OK
function_traits<int (*)(int, double)> // not OK.

So throw in a remove_pointer into your code and everything should be well:

> -------- begin simplified code ------
>
template<typename Proc>
class CacheValue {
typedef boost::remove_pointer<Proc>::type np_type;
typedef boost::function_traits<np_type>::R ReturnType;

template<typename Arg1>
ReturnType operator () ( Arg1 arg1 ) { /* do something */ }
};


CacheValue<unsigned long (*) ( unsigned long )> aValue;

> -------- end simplified code ------

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/EbFolB/TM
---------------------------------------------------------------------~->

Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe@xxxxxxxxxxxxxxx>


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise