Re: Conversion policies
David Abrahams <[email protected]>
| Newsgroups | gmane.comp.lib.boost.langbinding |
|---|---|
| Message-ID | <[email protected]> |
Daniel Wallin <[email protected]> writes: > At 16:00 2003-08-08, David Abrahams wrote: >>Daniel Wallin <[email protected]> writes: >> >> > Ok I've given this some thought. The issue is that we need to keep the >> > converter >> > object instances on the stack of the invoker function, to be able to have >> > storage between check() and to_cxx(). This is important for >> lvalue-conversions >> > which can perform the entire conversion in the checking part, and >> stores the >> > pointer. It's likely important for other more advanced policies as >> well, which >> > could need intermediate storage. >> >>Right, OK: >> >>template<class R, class A0, class A1, class Policies> >>ret_type invoke(R(*fn)(A0, A1), const Policies& policies, ArgTuple t) >>{ >> typename Policies::conversions_type converters(policies); >> >> if !( >> converters.check(_1, identity<A0>(), t[0]) >> , converters.check(_2, identity<A1>(), t[1]) >> ) >> return kOverloadFailed; >> >> return converters.from_cxx( >> fn( >> converters.to_cxx(_1, identity<A0>(), t[0]) >> , converters.to_cxx(_2, identity<A1>(), t[1]) >> ) >> ); >>} > > The type of the converter objects is dependent on the types they > operate on, so > it's slightly more complicated: > > typename Policies::template conversions_type< > mpl::list<A0, A1> > >::type converters; > > Which isn't really more efficient than the first implementation. Less > code in the invoker > functions though. Ah, right. Anyway, it's too early to be optimizing compilation speed here. I'm convinced ;-> -- Dave Abrahams Boost Consulting www.boost-consulting.com ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01