Boost logo

Boost :

Subject: [boost] [Boost.Convert] Specify input using iterators
From: Marius Dobrea (mldobrea_at_[hidden])
Date: 2014-11-26 17:36:56

Hi Vladimir,

While reading the Boost.Convert documentation last night there were some
questions which came to my mind:
Have you considered using iterators (or ranges) to specify input? Would
that be in the scope of your library?

Also I note that the strtol() function returns the position of the first
invalid character (endptr below):
long int strtol (const char* str, char** endptr, int base);
Could convert() provide the position where the conversion stopped? This
would allow single pass parsing of some input data.
Would a Converter callable with the following signature be useful?

template<typename TypeOut, typename InputIterator>
class Result
     enum Errc { numeric_overflow, empty_range, invalid_character, ...};
     // std::expected like function signatures here
     TypeOut value;
     int errors;
     InputIterator pos;

template<typename TypeOut, typename InputIterator>
void operator()(InputIterator begin, InputIterator end, Result<TypeOut,
InputIterator>& result) const;

Please let me know your thoughts.

Marius Dobrea

Boost list run by bdawes at, gregod at, cpdaniel at, john at