ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] call_traits
by Graeme Prentice other posts by this author
Sep 29 2005 12:09PM messages near this date
[boost] call_traits | Re: [boost] [1.33.1][iostreams] Timetable and patches
SOURCE 

>  -----Original Message-----
>  From: boost-bounces@[...].org 
>  [mailto:boost-bounces@[...].org] On Behalf Of Jason Hise
>  Sent: Sunday, 25 September 2005 2:11 p.m.
>  To: boost@[...].org
>  Subject: [boost] call_traits
>  
>  
>  Why doesn't the following compile?  I get the error "foo: 
>  function does 
>  not take 1 arguments" on VC8.
>  
>  #include <boost/call_traits.hpp>
>  
>  template < typename P1 >
>  void foo ( typename ::boost::call_traits < P1 >::param_type p1 )
>  {
>  }
>  
>  int main (  )
>  {
>      foo ( 42 ); // error here
>      return 0;
>  }



This is the infamous non-deduced context.  A nested name specifier
(call_traits) is a non-deduced context so P1 cannot be deduced.  You have to
write foo<int> (42).  This is like an invisible cast, so you have to remember
to change all the explicit type specifiers if you change the type of an
argument being passed in such a function.


>  
>  (Background info: I would like to use this technique to generate 
>  optimized forwarding functions that do not know anything about the 
>  function being forwarded to.  Overloads taking any number of params 
>  would be generated with the boost preprocessor library.)
>  
>  -Jason


It might be better to write specializations for foo rather than specify the
types at the point of call.

Graeme


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Jason Hise
Graeme Prentice

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved