Boost logo

Boost Users :

Subject: Re: [Boost-users] Cannot cast from std::string to seastar::sstring.
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2018-09-17 08:39:43


On 17 September 2018 at 05:48, José Guilherme Vanz via Boost-users <
boost-users_at_[hidden]> wrote:

> Hi guys,
>
> I'm investigating a bug <https://github.com/scylladb/scylla/issues/2905>
> in the Seastar/lexical_cast and I got stuck. Let me introduce what's
> going on and the further investigation that I did.
> The Seastar framework uses the boost program options to parse the command
> line arguments. But when the user try to pass a command line argument of
> seastar::sstring (Seastar string type) with a white space, the lib tells
> us that is invalid value.
>
> Turns out the boost program options call lexical_cast to cast from
> std::string to seastar::sstring. This cast is failing. The lexical_cast
> uses a stream to extract the value from the source, but the operator>>
> stops in the white space. Making the second validation in the same line
> <https://github.com/boostorg/lexical_cast/blob/boost-1.66.0/include/boost/lexical_cast/detail/converter_lexical_streams.hpp#L600>
> false. Note, there is a call
> <https://github.com/boostorg/lexical_cast/blob/boost-1.66.0/include/boost/lexical_cast/detail/converter_lexical_streams.hpp#L597>
> to unsetf to ensure that the white space will be skipped:
> stream.unsetf(std::ios::skipws);.
>
> What's am I trying to do is figure out where the problems live? Is there
> a bug in boost or is a sstring implemantion problem? Am I missing something?
>

Overload validate, cf the documentation
https://www.boost.org/doc/libs/1_68_0/doc/html/program_options/howto.html#id-1.3.31.6.7



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