summaryrefslogtreecommitdiff
path: root/src/raw_convert.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-03-12 16:24:46 +0000
committerCarl Hetherington <cth@carlh.net>2019-03-12 16:24:46 +0000
commit5038e68ad9eb66e007211c8f1b707612a0c01e29 (patch)
tree70d5aa5d3f414defc3d3cd0b34de0725bf8760a9 /src/raw_convert.h
parenta8b629085c404d7a947ed242fbf64d8e0e91edcd (diff)
Remove sstream dependency.
Diffstat (limited to 'src/raw_convert.h')
-rw-r--r--src/raw_convert.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/raw_convert.h b/src/raw_convert.h
index 3afb8f7..c392500 100644
--- a/src/raw_convert.h
+++ b/src/raw_convert.h
@@ -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
@@ -32,15 +32,24 @@ template <typename P, typename Q>
P
raw_convert (Q v, 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);
}
+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