[Boost-bugs] [Boost C++ Libraries] #6094: 1 secondALPHA should be an invalid input for a duration.

Subject: [Boost-bugs] [Boost C++ Libraries] #6094: 1 secondALPHA should be an invalid input for a duration.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-03 23:08:07


#6094: 1 secondALPHA should be an invalid input for a duration.
------------------------------+---------------------------------------------
 Reporter: viboes | Owner: viboes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 I expect the following input to be an invalid

 1 seconde

 to fail (in English). But it works without scanning the last 'e'.

 It seems that this is the current practice in the standard

 But this goes against current practice:


 {{{
 #include <sstream>
 #include <iostream>

 int main()
 {
     std::istringstream in("1e+10");
     int s = 10;
     in >> s;
     if (!in.fail())
         std::cout << s << '\n';
     else
         std::cout << "failed\n";
     char c = 0;
     in >> c;
     if (!in.fail())
         std::cout << c << '\n';
     else
         std::cout << "failed\n";
 }
 }}}


 Outputs


 {{{
 1
 e
 }}}

 I think, however that this is a different case, as integers and letters
 could be go together.

 I can understand that after

 1 second

 any non alpha character could be accepted, but not an alphabetic.

 The solution could be simple. Once the unit keyword match, a check on the
 next character (if one) is done to ensure that isalpha(c) is false.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6094>
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:07 UTC