]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Get rid of our string_view selection process, C++17 has all we need
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 26 Apr 2021 08:14:07 +0000 (10:14 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 26 Apr 2021 08:14:07 +0000 (10:14 +0200)
ext/lmdb-safe/lmdb-safe.hh
pdns/views.hh

index 2a32c67a4e9edf8ddfe08593b0456635fe918e79..6844909e96e127a7c7b9df023a55f690caf79d9b 100644 (file)
 #include <vector>
 #include <algorithm>
 
-#ifdef __cpp_lib_string_view
 using std::string_view;
-#else
-#include <boost/version.hpp>
-#if BOOST_VERSION >= 106100
-#include <boost/utility/string_view.hpp>
-using boost::string_view;
-#elif BOOST_VERSION >= 105300
-#include <boost/utility/string_ref.hpp>
-using string_view = boost::string_ref;
-#else
-using string_view = std::string;
-#endif
-#endif
-
 
 /* open issues:
  *
index bf02435cc77a780a326b96edfcc67920426da972..a9ebedbdd0aa6d9a36bab71a3fc546fc185cd799 100644 (file)
 
 #pragma once
 
-#ifdef __cpp_lib_string_view
 using pdns_string_view = std::string_view;
-#else
-#include <boost/version.hpp>
-#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 <boost/utility/string_view.hpp>
-using pdns_string_view = boost::string_view;
-#elif BOOST_VERSION >= 105300
-#include <boost/utility/string_ref.hpp>
-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