]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
use std::string_view when available 9207/head
authorRosen Penev <rosenp@gmail.com>
Sat, 6 Jun 2020 18:33:55 +0000 (11:33 -0700)
committerRosen Penev <rosenp@gmail.com>
Sat, 6 Jun 2020 18:33:55 +0000 (11:33 -0700)
There's a standard C++ macro to check for its existence.

libstdc++ from GCC makes it available under C++17 and up. libcxx from
LLVM makes it available everywhere.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
ext/lmdb-safe/lmdb-safe.hh
pdns/dnsdistdist/views.hh

index 056a6cd823dfb208eab7dae21619e5f781e94e48..16d150fa7d6112e4f1d276f28da6a1d9acd8e4d3 100644 (file)
@@ -12,8 +12,9 @@
 #include <vector>
 #include <algorithm>
 
-// apple compiler somehow has string_view even in c++11!
-#if __cplusplus < 201703L && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#ifdef __cpp_lib_string_view
+using std::string_view;
+#else
 #include <boost/version.hpp>
 #if BOOST_VERSION >= 106100
 #include <boost/utility/string_view.hpp>
@@ -22,8 +23,6 @@ using boost::string_view;
 #include <boost/utility/string_ref.hpp>
 using string_view = boost::string_ref;
 #endif
-#else // C++17
-using std::string_view;
 #endif
 
 
index 1d3dfb4758d18d8fa505cbb586dde9923f99dd14..7e56c1590daa566f48f5f6f398417f6cfd060188 100644 (file)
@@ -22,8 +22,9 @@
 
 #pragma once
 
-// apple compiler somehow has string_view even in c++11!
-#if __cplusplus < 201703L && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#ifdef __cpp_lib_string_view
+using std::string_view;
+#else
 #include <boost/version.hpp>
 #if BOOST_VERSION >= 106100
 #include <boost/utility/string_view.hpp>
@@ -32,6 +33,4 @@ using boost::string_view;
 #include <boost/utility/string_ref.hpp>
 using string_view = boost::string_ref;
 #endif
-#else // C++17
-using std::string_view;
 #endif