]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/lexicalcast.h
Make lexical conversions from and to long long available everywhere
[libs/core.git] / source / strings / lexicalcast.h
index 6fe3cb366b24015ea215c127913db9f43ac42276..12b5d08a1c9e3689f8ada501bc63a33931c9052d 100644 (file)
@@ -16,7 +16,6 @@ class lexical_error: public std::runtime_error
 {
 public:
        lexical_error(const std::string &w): runtime_error(w) { }
-       virtual ~lexical_error() throw() { }
 };
 
 
@@ -27,7 +26,6 @@ class format_mismatch: public lexical_error
 {
 public:
        format_mismatch(const std::string &w): lexical_error(w) { }
-       virtual ~format_mismatch() throw() { }
 };
 
 
@@ -38,11 +36,11 @@ class LexicalConverter
 {
 private:
        Fmt fmt;
-       bool filled;
+       bool filled = false;
        std::string buf;
 
 public:
-       LexicalConverter(const Fmt &f): fmt(f), filled(false) { }
+       LexicalConverter(const Fmt &f): fmt(f) { }
        LexicalConverter(const std::string &s, const Fmt &f): fmt(f), filled(true), buf(s) { }
 
        const Fmt &get_fmt() const { return fmt; }
@@ -60,10 +58,8 @@ void operator<<(LexicalConverter &, unsigned char);
 void operator<<(LexicalConverter &, unsigned short);
 void operator<<(LexicalConverter &, unsigned);
 void operator<<(LexicalConverter &, unsigned long);
-#ifdef __GNUC__
 void operator<<(LexicalConverter &, long long);
 void operator<<(LexicalConverter &, unsigned long long);
-#endif
 void operator<<(LexicalConverter &, bool);
 void operator<<(LexicalConverter &, float);
 void operator<<(LexicalConverter &, double);
@@ -81,10 +77,8 @@ void operator>>(const LexicalConverter &, unsigned char &);
 void operator>>(const LexicalConverter &, unsigned short &);
 void operator>>(const LexicalConverter &, unsigned int &);
 void operator>>(const LexicalConverter &, unsigned long &);
-#ifdef __GNUC__
 void operator>>(const LexicalConverter &, long long &);
 void operator>>(const LexicalConverter &, unsigned long long &);
-#endif
 void operator>>(const LexicalConverter &, bool &);
 void operator>>(const LexicalConverter &, float &);
 void operator>>(const LexicalConverter &, double &);
@@ -97,7 +91,7 @@ struct CheckFormattedOutput: Sfinae
 {
        static std::ostream &s;
        template<typename T>
-       static Yes f(int (*)[sizeof(s<<T())]);
+       static Yes f(int (*)[sizeof(s<<reinterpret_cast<const T &>(s))]);
        using Sfinae::f;
 };
 
@@ -114,7 +108,7 @@ template<typename T> struct HasFormattedInput: Sfinae::Evaluate<CheckFormattedIn
 
 
 template<typename T>
-typename EnableIf<HasFormattedOutput<T>::value, void>::Yes
+typename std::enable_if<HasFormattedOutput<T>::value>::type
 operator<<(LexicalConverter &c, const T &v)
 {
        std::ostringstream ss;
@@ -123,7 +117,7 @@ operator<<(LexicalConverter &c, const T &v)
 }
 
 template<typename T>
-typename EnableIf<HasFormattedInput<T>::value, void>::Yes
+typename std::enable_if<HasFormattedInput<T>::value>::type
 operator>>(const LexicalConverter &c, T &v)
 {
        std::istringstream ss(c.get());