Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2006-01-12 08:17:31


Hi Yuval,

--- Yuval Ronen <ronen_yuval_at_[hidden]> wrote:
> But if you do supply the I/O operators, then you don't really
> need the string operations because you get those for free
> using lexical_cast, don't you? Wouldn't you want to save
> writing code that is already present in lexical_cast?

Particularly for construction, I think it is worth allowing
direct conversion from a string, even if it is just syntactic
sugar. Writing:

  asio::ipv4::endpoint ep(1234, "127.0.0.1");

is a bit clearer than:

  asio::ipv4::endpoint ep(1234,
      boost::lexical_cast<asio::ipv4::address>("127.0.0.1"));

and it is such a common requirement that it's worth supporting
in the library.

> I don't think there is any such assumption in what I said. You
> should be saying to the user: "you can assign an ip::address
> from X, Y, and Z", and that's all he needs to know. There's a
> difference between this and "there is an assignment operator
> from X, Y and Z". The latter is less flexible than the former,
> and for no good reason. Stating the former allows you to
> include or disclude these assignment operators as you see fit,
> without changing the user's interface.

Although it may not crop up much in practice, changing from one
assignment operator to multiple (or vice versa) does change the
behaviour of the interface, and saying that "you can assign an
address from X, Y or Z" doesn't fully document the behaviour.
The first option involves a user-defined conversion for
assignment from non-address types, whereas the second does not.

Cheers,
Chris


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