![]() |
Home | Libraries | License | Support | People | ALPS Web Site |
alps::lexical_cast_string — a string class with built-in conversion to other types using lexical_cast
// In header: <alps/stringvalue.h> template<typename StringBase = std::string> class lexical_cast_string : public StringBase { public: // types typedef StringBase string_type; // the underlying string class // construct/copy/destruct lexical_cast_string(const string_type & = string_type()); lexical_cast_string(const lexical_cast_string &); lexical_cast_string(const char *); template<typename InputItr> lexical_cast_string(InputItr, InputItr); template<typename T> lexical_cast_string(const T &); // public member functions bool valid() const; template<typename T> T get() const; operator bool() const; };
This class, derived from a std::string or similar implements additional conversion operations and constructors implemented using boost::lexical_cast
lexical_cast_string
public
construct/copy/destructlexical_cast_string(const string_type & s = string_type());constructor from a string
lexical_cast_string(const lexical_cast_string & s);copy-contructor
lexical_cast_string(const char * s);constructor from a C-style string
template<typename InputItr> lexical_cast_string(InputItr first, InputItr last);constructor from a character sequence
template<typename T> lexical_cast_string(const T & x);constructor from arbitrary types implemented using boost::lexical_cast
lexical_cast_string
public member functionsbool valid() const;check whether the string is not empty
template<typename T> T get() const;convert the string to type T using boost::lexical_cast
operator bool() const;convert the string to bool
the strings "true" and "false" are valid ways to specify tryue or false boolean values. Any other value will be converted to bool using boost::lexical_cast
Copyright © 1994, 2002-2005 Matthias Troyer, Synge Todo |