Changeset 2426


Ignore:
Timestamp:
Feb 13, 2011, 6:06:44 PM (11 years ago)
Author:
Peter
Message:

closes #656: convert from numeric to string

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/utility.cc

    r2370 r2426  
    44  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
    55  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009, 2010 Peter Johansson
     6  Copyright (C) 2009, 2010, 2011 Peter Johansson
    77
    88  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    144144  utility::convert<double>("inf");
    145145  utility::convert<double>("NaN");
     146
     147  suite.add(utility::convert(1.23)=="1.23");
     148  suite.add(utility::convert(1)=="1");
    146149
    147150  if (!suite.add(utility::is<double>("-inf")))
  • trunk/yat/utility/utility.h

    r2386 r2426  
    6262                     OutputIterator result);
    6363
     64  /**
     65     \brief convert T to a string
     66
     67     T is supposed to be a numerical type.
     68
     69     \since new in yat 0.8
     70   */
     71  template<typename T>
     72  std::string convert(T input);
    6473
    6574  /**
     
    259268
    260269  // template implementations
     270  template<typename T>
     271  std::string convert(T input)
     272  {
     273    std::ostringstream ss;
     274    ss << input;
     275    return ss.str();
     276  }
     277
     278
    261279  template<typename T>
    262280  T convert(const std::string& s)
Note: See TracChangeset for help on using the changeset viewer.