Merge.
[libsub.git] / src / raw_convert.h
index 3afb8f787e704a24c7624b42085bd174cedbe269..5d115acea317e1d9c913974c0136ed01c6cfbfc8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -20,7 +20,8 @@
 #ifndef LIBSUB_RAW_CONVERT_H
 #define LIBSUB_RAW_CONVERT_H
 
-#include <locked_sstream.h>
+#include "util.h"
+#include <boost/static_assert.hpp>
 #include <iomanip>
 
 namespace sub {
@@ -30,17 +31,27 @@ namespace sub {
  */
 template <typename P, typename Q>
 P
-raw_convert (Q v, int precision = 16)
+raw_convert (Q, int precision = 16)
 {
-       locked_stringstream s;
-       s.imbue (std::locale::classic ());
-       s << std::setprecision (precision);
-       s << v;
-       P r;
-       s >> r;
-       return r;
+       /* We can't write a generic version of raw_convert; all required
+          versions must be specialised.
+       */
+       BOOST_STATIC_ASSERT (sizeof (Q) == 0);
+       LIBSUB_UNUSED (precision);
 }
 
+template <>
+int
+raw_convert (std::string v, int);
+
+template <>
+float
+raw_convert (std::string v, int);
+
+template <>
+std::string
+raw_convert (unsigned long v, int);
+
 };
 
 #endif