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-02 07:35:14
#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 apolukhin):
Replying to [comment:4 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.
Just out of curiosity downloaded the 1.55. Test is in there:
`boost_1_55_0/libs/conversion/lexical_cast_test.cpp`. With your patches
test `void test_getting_pointer_to_function()` fail to compile. Breaking
existing use cases is unfordable.
> 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.
Your approach can be used with developer branch. `try_lexical_convert`
function does not guarantee unambiguity while getting pointer to function,
so it can be specialized in your way. Fork the
[https://github.com/boostorg/conversion conversion repo], apply your
patch, add tests to ensure that new feature work and make sure that
'''all''' tests pass.
> Iter <wchar_t*, std::basic_string<wchar_t,Traits,Alloc> >
This is not a portable solution (it won't work with SCARY iterators).
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8261#comment:6> 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