Boost logo

Boost :

From: Atry (pop.atry_at_[hidden])
Date: 2007-08-18 07:56:50


shunsuke wrote:
> Atry wrote:
>
>> All string operation are lazy but lexical_cast. If there is a lexical_range,
>> I can write:
>> new http_request("http://" | jointed(host) | jointed(single(':')) |
>> jointed(make_lexical_range<char>(port)) | jointed("/query?id=") |
>> jointed(make_lexical_range<char>(id)));
>>
>> The make_lexical_range will be faster than lexical_cast, and requires no
>> heap allocate.
>>
>
> I'm not sure how to implement such a range adaptor.
>
>
>>> struct static_cast_to_u32 {
>>> typedef uint32_t result_type;
>>> result_type operator()(wchar_t c) const {
>>> return static_cast<result_type>(c);
>>> }
>>> };
>>>
>>> u16_string | transformed(static_cast_to_u32()) | utf8_encoded;
>>>
>
> In fact, that is a cut and paste from
> <boost/regex/pending/unicode_iterator.hpp>,
> so I don't understand it exactly.
> But that assertion seems a good practice.
>
>
> BTW, a null-terminated char pointer is no longer a range.
> See oven::as_c_str, as_literal and as_array.
>
>
> Regards,
>
>
I found that boost::oven::equals not support boost::iterator_range, Here
is the test case.


#define BOOST_AUTO_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/oven/equals.hpp>
#include <boost/oven/single.hpp>
#include <boost/range/iterator_range.hpp>
BOOST_AUTO_TEST_CASE(iterator_range_equals) {
  using namespace boost::oven;
  using namespace boost;
  using namespace std;

  stringstream ss("1");
  BOOST_CHECK(equals(make_iterator_range(istreambuf_iterator<char>(ss), istreambuf_iterator<char>()), single('1')));
}


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