|
Boost : |
Subject: Re: [boost] Boost review of the Convert library is ongoing
From: Arpit (arpitmittal108_at_[hidden])
Date: 2014-05-23 08:05:05
alex <alexhighviz_at_[hidden]> wrote:
>>>>
>>> The benefit is that it defers initialization and thus passes that
>>> responsibility from the generic function to the specific converters.
>>>
>> Let's try staying with mainstream usage examples meaningful for the
>majority of users. I'll
>>unlikely be persuaded by an esoteric academic (even a real but
>>corner-case) example that will have negative impact on the real users.
>>Thoughts?..
>
>The convert contract you are proposing is quite abstract, so I think
>academic arguments are relevant. But your question can be translated to: are
>there real examples of classes that are expensive to construct but cheap to
>move? Moreover, these classes need to be potential candidates for being
>converted to.
>
>The example you have been using is encryption. Consider the following class
>for an encrypted password:
>
>struct encrypted_password
>{
> encrypted_password(const std::string& password)
> {
> // connect to random number device
> // do all kinds of arithmetic to encrypt
> // send email to NSA
> // m_encrypted will have a minimum size of 128.
> }
> encrypted_password (password_encryption&& rhs) : m_encrypted
>(std::move(rhs.m_encrypted))
> { }
>
> bool check_password(const std::string& password){}
>
>private:
> std::string m_encrypted;
>};
>
>Now I can write a converter:
>
>struct password_converter
>{
> void operator()(const std::string& in,
>boost::optional<password_encryption>& out)
> {
> try {
> out = password_encryption(in);
> } catch(...) {
> out = boost::none;
> }
> }
>};
>
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk