Boost logo

Boost Users :

Subject: Re: [Boost-users] [Ranges] make_view: when will it be part of a release?
From: Max (loadcom_at_[hidden])
Date: 2009-01-11 20:09:50


> I recently had the need to produce from a vector<uint> a string
> representation (like for IPs) like "23.1.4.742.234.0".
>
> I thought that if only those were uints were strings I could
> boost::join them together.
>
> After a bit of searching the internet I found: make_view... very helpful,
as
> indeed operating on iterators and containers only is a bit restrictive.
>
> So, first, I'd like to express my thanks for providing such
> helpful libraries (I love it how Boost.Bind and ASIO fit together, e.g.!).
> Great job everyone!
>
> Is there a better way to get to the string
> representation hinted to above? What I did is:
>
> #include <boost/view.hpp> // not yet part of Boost 1.37
>
> // Helper to convert an uint to a std::string
> struct Stringer
> {
> std::string operator() (unsigned u) const
> {
> return boost::lexical_cast<std::string>(u);
> }
> };
>
> boost::function<std::string(unsigned)> stringer = Stringer();
> // way better than writing the loop by hand!
> std::string s = boost::join(boost::make_view(data_, stringer), ".");
> // Does not compile with gcc 4.2.1
> // std::string s = boost::join(boost::make_view(data_, Stringer()),
".");
>
> Is there some existing class that makes my helper class Stringer
> unnecessary? (Can I use lexical_cast here w/o a helper class?)
> Is it possible to avoid putting the functor into a local Boost.Function
> variable?

The Lambda lib is powerful in creating in-place unnamed function object,
isn't it? Have you ever considered it?

> When will range_ex and make_view() be part of a Boost release? 1.38?
> (Please?)

I also have interest to know the answer.

B/Rgds
Max


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net