Boost logo

Boost :

Subject: [boost] [Conversion] Practical applications
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-08-21 12:18:21


Dear Vicente & others,

Would anyone like to share any practical or motivating applications for
the proposed Boost.Conversion library?

It seems to me that there are practical applications for particular
types of conversion, e.g. T-to-string and string-to-T, and numeric
casts, and serialisation. Apart from that, I am having trouble seeing
practical reasons for generic conversion. A motivating case would be
if a generic algorithm required conversion, but in the cases that I can
think of either (a) the generic algorithm takes a functor, so the
caller can pass the currently-required conversion as part of a lambda
expression, or (b) you might need to select one of several possible
conversions between a pair of types, which this library can't do, or
(c) the algorithms are std:: ones which won't work with this library anyway.

Example:

struct person {
   string firstname;
   string surname;
};

vector<person> people; // sorted by firstname

// Try to find everyone with firstname "John":
std::equal_range(people.begin(),people.end(),"John");

That doesn't work. Making it work has always struck me as more
difficult than it should be. Can this library make it easier? If not,
what similar problems can it help with?

Regards, Phil.


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