Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-02-19 08:42:59


On Thursday, February 19, 2009 2:57 AM
Vladimir Batov wrote:
>
> namespace boost
> {
> template<class TypeIn, class TypeOut, class Enable =void>
> class convert;

s/convert/converter/

      // leave default value computation to converter
      template <class TypeOut, class TypeIn>
      TypeOut const
      convert(TypeIn _input)
      {
         return converter<TypeIn,TypeOut>(_input);
      }

      template <class TypeOut, class TypeIn>
      TypeOut const
      convert(TypeIn _input, TypeOut const & _default)
      {
         return converter<TypeIn,TypeOut>(_input, _default);
      }
> }
[snip class template declaration]

> int string_to_int = convert<string, int>(str, -1);

   int s2i(convert<int>(str, -1));

> int string_to_int = convert<string, int>(str);

   s2i = convert<int>(str);

> convert<string, int> string_to_int(str, -1);

   converter<string,int> c(str, -1);

> convert<string, int> string_to_int = convert<string, int>(str, -1);

   c = convert<int>(str, -1);

> std::transform(
> integers.begin(),
> integer.end(),
> std::back_inserter(strings),
> convert<string, int>::apply);

s/convert/converter/

> As you can see there is *no* type-deducing. That is, with
> that approach
> we'll have to always indicate 'to' and 'from' types. That
> seems verbose...
> but might be a plus as it takes *any* ambiguity out.

As you can see, there is type deduction. That is, with this approach, we won't need to indicate the source and destination types in all contexts, but can when needed to remove ambiguity.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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