From: Remi Gacogne Date: Mon, 26 Apr 2021 08:14:07 +0000 (+0200) Subject: Get rid of our string_view selection process, C++17 has all we need X-Git-Tag: dnsdist-1.6.0-rc2~5^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ddbbc3e15342c988beca76455966e054dea4ae4;p=thirdparty%2Fpdns.git Get rid of our string_view selection process, C++17 has all we need --- diff --git a/ext/lmdb-safe/lmdb-safe.hh b/ext/lmdb-safe/lmdb-safe.hh index 2a32c67a4e..6844909e96 100644 --- a/ext/lmdb-safe/lmdb-safe.hh +++ b/ext/lmdb-safe/lmdb-safe.hh @@ -12,21 +12,7 @@ #include #include -#ifdef __cpp_lib_string_view using std::string_view; -#else -#include -#if BOOST_VERSION >= 106100 -#include -using boost::string_view; -#elif BOOST_VERSION >= 105300 -#include -using string_view = boost::string_ref; -#else -using string_view = std::string; -#endif -#endif - /* open issues: * diff --git a/pdns/views.hh b/pdns/views.hh index bf02435cc7..a9ebedbdd0 100644 --- a/pdns/views.hh +++ b/pdns/views.hh @@ -22,59 +22,4 @@ #pragma once -#ifdef __cpp_lib_string_view using pdns_string_view = std::string_view; -#else -#include -#if BOOST_VERSION >= 106400 -// string_view already exists in 1.61.0 but string_view::at() is not usable with modern compilers, see: -// https://github.com/boostorg/utility/pull/26 -#include -using pdns_string_view = boost::string_view; -#elif BOOST_VERSION >= 105300 -#include -using pdns_string_view = boost::string_ref; -#else - -/* this class implements a very restricted view, since nothing else is available - and doing a full allocation + copy is just dumb */ -class pdns_string_view -{ -public: - pdns_string_view() noexcept - { - } - - pdns_string_view(const std::string& str) noexcept: d_ptr{str.data()}, d_size(str.size()) - { - } - - pdns_string_view(const char* str, size_t len) noexcept: d_ptr{str}, d_size(len) - { - } - - size_t size() const noexcept - { - return d_size; - } - - const char& at(size_t pos) const - { - if (pos >= d_size) { - throw std::out_of_range("pdns_string_view::at() " + std::to_string(pos) + " >= " + std::to_string(d_size)); - } - return *(d_ptr + pos); - } - - const char* data() const noexcept - { - return d_ptr; - } - -private: - const char* d_ptr{nullptr}; - const size_t d_size{0}; -}; - -#endif -#endif