Re: [Boost-bugs] [Boost C++ Libraries] #8261: lexical_cast<unsigned> returns unexpected result when using with split_iterator<std::wstring::iterator>

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8261: lexical_cast<unsigned> returns unexpected result when using with split_iterator<std::wstring::iterator>
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-01 21:28:34


#8261: lexical_cast<unsigned> returns unexpected result when using with
split_iterator<std::wstring::iterator>
-------------------------------+--------------------------
  Reporter: s.a.moreno.a.s@… | Owner: apolukhin
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: lexical_cast
   Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+--------------------------

Comment (by Troy Korjuslommi <troykor@…>):

 I didn't get a failure on any of the tests on 1_55_0.
 Must a dev branch new test or something.

 My understanding of the problem is as follows.
 The eventual problem is that the code interprets wchar_t* as char*.
 The reason this happens is that the traits template says the char type for
 CharT is char, not wchar_t. The reason it gets it wrong is that it doesn't
 have any checks for iterator_range types, so it just fumbles.
 It catches those iterator_range types which have a parameter char or
 wchar_t, but iterator_range<iterator/const_iterator> types have one more
 level of embedded types, so it misses those.

 One could add those checks, but that would just add complexity without any
 real benefit. A specialization for iterator_range would just get added
 somewhere else anyway. It is much simpler and safer to catch all
 iterator_range types in their own lexical_cast function.
 If something breaks, then write more special cases.
 I am attaching another patch which adds another level of indirection, so
 specializations can be written as needed.

 I know this is slightly different take on what you mentioned. I do see
 your point too with the stream types. I ended up taking a different route.
 Please give it some thought.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8261#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC