]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
yahttp: Better detection of whether C++11 features are available 12589/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 24 Feb 2023 16:35:53 +0000 (17:35 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 24 Feb 2023 16:35:53 +0000 (17:35 +0100)
The previous version relied on having `HAVE_CXX11` defined, which
is not true when you are compiling with C++17, for example, even
though the C++11 features are available (`HAVE_CXX17` is defined
but that does not help).

ext/yahttp/yahttp/reqresp.hpp
ext/yahttp/yahttp/router.cpp
ext/yahttp/yahttp/router.hpp

index 00ba545032bae0fed73a8f2940ff29d2046823e4..4db53bec85a1478f5ebdee563f415506388885fa 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef HAVE_CXX11
+#if __cplusplus >= 201103L
 #include <functional>
 #define HAVE_CPP_FUNC_PTR
 namespace funcptr = std;
@@ -72,7 +72,7 @@ namespace YaHTTP {
       size_t operator()(const HTTPBase *doc __attribute__((unused)), std::ostream& os, bool chunked) const {
         char buf[4096];
         size_t n,k;
-#ifdef HAVE_CXX11
+#if __cplusplus >= 201103L
         std::ifstream ifs(path, std::ifstream::binary);
 #else
         std::ifstream ifs(path.c_str(), std::ifstream::binary);
index 489f8cff1f9658a43558b8f9059509171dacf827..18ea9b6fcffef45a5230c32dd7407c889c4eb65a 100644 (file)
@@ -98,7 +98,7 @@ namespace YaHTTP {
 
   void Router::printRoutes(std::ostream &os) {
     for(TRouteList::iterator i = routes.begin(); i != routes.end(); i++) {
-#ifdef HAVE_CXX11
+#if __cplusplus >= 201103L
       std::streamsize ss = os.width();
       std::ios::fmtflags ff = os.setf(std::ios::left);
       os.width(10);
@@ -122,7 +122,7 @@ namespace YaHTTP {
 
     bool found = false;
     for(TRouteList::iterator i = routes.begin(); !found && i != routes.end(); i++) {
-#ifdef HAVE_CXX11
+#if __cplusplus >= 201103L
       if (std::get<3>(*i) == name) { mask = std::get<1>(*i); method = std::get<0>(*i); found = true; }
 #else
       if (i->get<3>() == name) { mask = i->get<1>(); method = i->get<0>(); found = true; }
index a0dbd1380e6384d1d0573b754f75dc35d3474ebe..205119c7d41ecb86074bc0d0ef0299605fda3b07 100644 (file)
@@ -2,7 +2,7 @@
 /* @file 
  * @brief Defines router class and support structures
  */
-#ifdef HAVE_CXX11
+#if __cplusplus >= 201103L
 #include <functional>
 #include <tuple>
 #define HAVE_CPP_FUNC_PTR