|
Re: Using function_traits: msg#00320lib.boost.user
> 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> |
|---|---|---|
| Previous by Date: | RE: MSVC++, bind and namespaces: 00320, Antoine Boivin Filion |
|---|---|
| Next by Date: | RE: Date_Time library question...: 00320, Jeff Garland |
| Previous by Thread: | Using function_traitsi: 00320, Marshall Clow |
| Next by Thread: | RE: ublas::matrix sharing storage with ublas::vecto r: 00320, Scott Sinclair |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |