From: Rosen Penev Date: Sat, 6 Jun 2020 18:33:55 +0000 (-0700) Subject: use std::string_view when available X-Git-Tag: dnsdist-1.5.0-rc3~20^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=405bdec807a7b530173ebf018843c4552dfa20c9;p=thirdparty%2Fpdns.git use std::string_view when available 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 --- diff --git a/ext/lmdb-safe/lmdb-safe.hh b/ext/lmdb-safe/lmdb-safe.hh index 056a6cd823..16d150fa7d 100644 --- a/ext/lmdb-safe/lmdb-safe.hh +++ b/ext/lmdb-safe/lmdb-safe.hh @@ -12,8 +12,9 @@ #include #include -// 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 #if BOOST_VERSION >= 106100 #include @@ -22,8 +23,6 @@ using boost::string_view; #include using string_view = boost::string_ref; #endif -#else // C++17 -using std::string_view; #endif diff --git a/pdns/dnsdistdist/views.hh b/pdns/dnsdistdist/views.hh index 1d3dfb4758..7e56c1590d 100644 --- a/pdns/dnsdistdist/views.hh +++ b/pdns/dnsdistdist/views.hh @@ -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 #if BOOST_VERSION >= 106100 #include @@ -32,6 +33,4 @@ using boost::string_view; #include using string_view = boost::string_ref; #endif -#else // C++17 -using std::string_view; #endif