Ignore:
Timestamp:
Dec 3, 2011, 1:30:12 AM (11 years ago)
Author:
Peter
Message:

merge release 0.8 into trunk

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/yat/utility/utility.h

    r2581 r2673  
    3535#include "Exception.h"
    3636
     37#include <algorithm>
     38#include <cctype>
    3739#include <cmath>
     40#include <functional>
    3841#include <limits>
     42#include <locale>
    3943#include <istream>
    4044#include <string>
     
    331335
    332336  template<typename T>
    333   void load(std::istream& is, std::vector<T>& vec, char sep='\0')
     337  void load(std::istream& is, std::vector<T>& vec, char sep)
    334338  {
    335339    detail::VectorPusher<T> pusher;
     
    352356  bool convert(const std::string& s, T& result)
    353357  {
     358    if (!std::numeric_limits<T>::is_signed) {
     359      // first non-whitespace character
     360      std::string::const_iterator iter = s.begin();
     361      while (iter!=s.end() && std::isspace(*iter))
     362        ++iter;
     363      // unsigned int cannot start with a '-' and with some compilers
     364      // operation ss >> result won't fail so catch it like this instead.
     365      if (iter==s.end() || *iter=='-')
     366        return false;
     367    }
    354368    std::istringstream ss(s);
    355369    ss >> result;
Note: See TracChangeset for help on using the changeset viewer.