Re: Conversion policies

David Abrahams <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Message-ID <[email protected]>
Daniel Wallin <[email protected]> writes:

> At 17:20 2003-08-22, David Abrahams wrote:
>
>>2. If this is just an issue of user-customization, I am learning to
>>    prefer not distorting interfaces for broken compilers.  I'd rather
>>    ask those users to apply BOOST_TT_BROKEN_COMPILER_SPEC in order to
>>    produce the neccessary specializations for us to work in one
>>    uniform way.  I know that doesn't *directly* address partial
>>    ordering, but I think you can usually transform all partial
>>    ordering problems into partial specialization problems, can't you?
>
> Yes, in this particular case we could just use a template parameter
> to the converter to deduce the type, given that we don't care about
> non conforming compilers.
>
> template<int N>
> struct my_policy : converter_generator_tag<N>
> {
>     template<class T>
>     struct generate_converter

This should be called "apply" so that my_policy<N> is a metafunction
class.

>     {
>        typedef my_converter<T> type;
>     };
> };
>
> One important thing here is that we can't have any additional layers in
> conversion process; the result from the converter must go directly to
> the wrapped function. If it isn't obvious this is because we want to be
> able to return temporaries when the function expects a const&.
> This is also why it can be useful to deduce the T from const T&
> in the converter function.

Well, there *is* another way: you can use in-place construction in the
converter object and always return a T const& instead of a T.  I
believe that's exactly what happens in Boost.Python.

> How would we use the BOOST_TT_BROKEN_COMPILER_SPEC macro
> to provide specializations?

We'd tell the user to write 

     BOOST_TT_BROKEN_COMPILER_SPEC(X)

for any type X for which we need to be able to get
remove_reference<X>::type

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.