> On Nov. 20, 2015, 3:23 p.m., Benjamin Bannier wrote:
> > 3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp, line 39
> > <https://reviews.apache.org/r/40497/diff/2/?file=1133104#file1133104line39>
> >
> >     Where you planning to output `c` here? Otherwise I suggest replacing 
> > this at least `ss.get()` (and drop the decl above).
> >     
> >     I like H.Sutter's synopsis of `boost::lexical_cast` even better since 
> > it shows clearly the failure sites (modulo the throw for here), see 
> > http://www.gotw.ca/publications/mill19.htm:
> >     
> >         template<typename Target, typename Source>
> >         Target lexical_cast(Source arg)
> >         {
> >           std::stringstream interpreter;
> >           Target result;
> >     
> >           if(!(interpreter << arg) ||
> >              !(interpreter >> result) ||
> >              !(interpreter >> std::ws).eof())
> >             throw bad_lexical_cast();
> >     
> >           return result;
> >         }
> >         
> >     You could do a similar impl just by injection a `<< std::hex`.
> 
> Cong Wang wrote:
>     I replace that ss.get() with ss.eof(). And also I don't understand why 
> checking the return value of operator<< could work, it always return the 
> stream right? The document says we should check ss.fail().

http://en.cppreference.com/w/cpp/io/basic_ios/operator_bool


> On Nov. 20, 2015, 3:23 p.m., Benjamin Bannier wrote:
> > 3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp, line 26
> > <https://reviews.apache.org/r/40497/diff/2/?file=1133106#file1133106line26>
> >
> >     Would be nice to add a couple more positives here, e.g., to catch 
> > `hex_cast` impls like `boost::lexical_cast(s.substr(2)` ;)
> 
> Cong Wang wrote:
>     I added some more positives, but not sure if they are 
> boost::lexical_cast(s.substr(2))...

Hmm, for `0x00` the hex prefix doesn't matter, and just extracting without it 
would give the same answer `0`. How about testing e.g., `0x10` which really 
translates to `16`, but to `10` without the prefix?


- Benjamin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/40497/#review107370
-----------------------------------------------------------


On Nov. 20, 2015, 10:26 p.m., Cong Wang wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/40497/
> -----------------------------------------------------------
> 
> (Updated Nov. 20, 2015, 10:26 p.m.)
> 
> 
> Review request for mesos, Ben Mahler and Ian Downes.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> numify() in libprocess uses boost lexical_cast() to cast numbers, but it can 
> not cast a hex number. This patch adds hex support to numify().
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am 
> 5a0ffc38d4194b9f9c53dc1cf0c90ca7bbae2afd 
>   3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp 
> ddd3dd9e015c583e04d72ac9a9b5a5ed6f1d49d5 
>   3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt 
> 14fb644b38a5cbb8cde74aab39e84305f6ab7041 
>   3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/40497/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Cong Wang
> 
>

Reply via email to