summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-09-18 02:02:58 +1000
committer Vas Crabb <vas@vastheman.com>2021-09-18 02:02:58 +1000
commitdf8703523b002a44a9a5038bebb6397dad3bb42a (patch)
treed259e1a05e5bc9465de2ebfc06974721aa22141e /src/lib
parent91a9904a84703d57cd649c9c66a4bea446298b2b (diff)
util/strformat.h: Detect C++ standard > C++17 before doing weird stuff.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/strformat.cpp1
-rw-r--r--src/lib/util/strformat.h26
2 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/util/strformat.cpp b/src/lib/util/strformat.cpp
index e173fb6aadf..cec14635e16 100644
--- a/src/lib/util/strformat.cpp
+++ b/src/lib/util/strformat.cpp
@@ -9,7 +9,6 @@
***************************************************************************/
#include "strformat.h"
-#include "vecstream.h"
#include <iostream>
#include <sstream>
diff --git a/src/lib/util/strformat.h b/src/lib/util/strformat.h
index 4714b9f5e71..e6d2ee0a0fe 100644
--- a/src/lib/util/strformat.h
+++ b/src/lib/util/strformat.h
@@ -597,10 +597,12 @@ private:
str << int(std::make_signed_t<U>(value));
else if constexpr (!std::is_signed_v<U> || std::is_same_v<typename Stream::char_type, U>)
str << std::make_signed_t<U>(value);
- else if constexpr (std::is_invocable_v<decltype([] (auto &x, auto &y) -> decltype(x << y) { return x << y; }), Stream &, U const &>)
- str << value;
- else
+#if __cplusplus > 201703L
+ else if constexpr (!std::is_invocable_v<decltype([] (auto &x, auto &y) -> decltype(x << y) { return x << y; }), Stream &, U const &>)
str << std::make_signed_t<U>(value);
+#endif
+ else
+ str << value;
}
template <typename U>
@@ -610,10 +612,12 @@ private:
str << unsigned(std::make_unsigned_t<U>(value));
else if constexpr (!std::is_unsigned_v<U> || std::is_same_v<typename Stream::char_type, U>)
str << std::make_unsigned_t<U>(value);
- else if constexpr (std::is_invocable_v<decltype([] (auto &x, auto &y) -> decltype(x << y) { return x << y; }), Stream &, U const &>)
- str << value;
- else
+#if __cplusplus > 201703L
+ else if constexpr (!std::is_invocable_v<decltype([] (auto &x, auto &y) -> decltype(x << y) { return x << y; }), Stream &, U const &>)
str << std::make_unsigned_t<U>(value);
+#endif
+ else
+ str << value;
}
public:
@@ -819,14 +823,16 @@ public:
str << reinterpret_cast<void const *>(std::uintptr_t(value));
break;
default:
- if constexpr (std::is_invocable_v<decltype([] (auto &x, auto &y) -> decltype(x << y) { return x << y; }), Stream &, U const &>)
+#if __cplusplus > 201703L
+ if constexpr (!std::is_invocable_v<decltype([] (auto &x, auto &y) -> decltype(x << y) { return x << y; }), Stream &, U const &>)
{
- str << value;
+ assert(false); // stream out operator not declared or declared deleted
+ str << '?';
}
else
+#endif
{
- assert(false); // stream out operator not declared or declared deleted
- str << '?';
+ str << value;
}
}
}