Boost logo

Boost :

Subject: Re: [boost] Convert library -- Andrzej's review
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2014-05-22 21:33:11


On May 21, 2014 7:22:23 PM EDT, Vladimir Batov <Vladimir.Batov_at_[hidden]> wrote:
>
>On 05/20/2014 09:58 PM, Andrzej Krzemienski wrote:
>> 2014-05-20 6:34 GMT+02:00 Vladimir Batov
><Vladimir.Batov_at_[hidden]>:
>>> On 05/18/2014 11:45 PM, Vladimir Batov wrote:
>>>> Vladimir Batov <vb.mail.247 <at> gmail.com> writes:
>>>>
>>>> Andrzej Krzemienski <akrzemi1 <at> gmail.com> writes:
>
>> It is an equivalent of a "monomorphic" lambda. I guess you could
>invent
>> another syntax, that does not require to specify this InType:
>>
>> convert<int>(cnv).value_or(-1);
>>
>> which would render a converter object with parametrized signature:
>>
>> template <typename InType>
>> int operator()(const InType&);
>
>I admit I have no slightest idea what "monomorphic lamda" is :-)

A single argument your lambda.

[snip]

>So far I only found
> boost::convert<std::string>(cnv));
>
>has one limitation over
>
> boost::convert<std::string, int>(cnv));
>
>Namely, the latter can do implicit conversions when the former does
>not.
>That is, for the former to work correctly I have to have a container of
>elements the *correct* type. With the latter I can feed to an algorithm
>a container of elements *convertible* to the explicitly specified
>TypeIn.

That's where a polymorphic lambda comes into play:

template<class T>
std::string
operator()(T);

That function call operator can accept various types, yet produce the expected result.

___
Rob

(Sent from my portable computation engine)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk