]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
LuaWrapper: Fix C++11 compatibility 16622/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 11 Dec 2025 10:29:33 +0000 (11:29 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 11 Dec 2025 10:29:33 +0000 (11:29 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
ext/luawrapper/include/LuaContext.hpp

index 97530a52efaf9e4e906d6fd5f17e0a7bfa14934e..90246dfef14795a840fdb80d3493560d34cee3b6 100644 (file)
@@ -38,7 +38,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <list>
 #include <map>
 #include <memory>
-#include <optional>
 #include <random>
 #include <set>
 #include <stdexcept>
@@ -47,7 +46,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <tuple>
 #include <type_traits>
 #include <unordered_map>
-#include <variant>
 #include <boost/any.hpp>
 #include <boost/format.hpp>
 #include <boost/mpl/distance.hpp>
@@ -57,6 +55,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <boost/type_traits.hpp>
 #include <lua.hpp>
 
+#if __cplusplus >= 201703L
+#include <variant>
+#include <optional>
+#endif /* C++17 */
+
 // Set the older gcc define for tsan if clang or modern gcc tell us we have tsan.
 #if defined(__has_feature)
 #if __has_feature(thread_sanitizer)
@@ -2002,8 +2005,10 @@ struct LuaContext::FunctionArgumentsCounter<> {
 // implementation of IsOptional
 template<typename T>
 struct LuaContext::IsOptional<boost::optional<T>> : public std::true_type {};
+#if __cplusplus >= 201703L
 template<typename T>
 struct LuaContext::IsOptional<std::optional<T>> : public std::true_type {};
+#endif /* C++ 17 */
 
 // implementation of LuaFunctionCaller
 template<typename TFunctionType>
@@ -2557,6 +2562,7 @@ private:
     };
 };
 
+#if __cplusplus >= 201703L
 // std::variant
 template<typename... TTypes>
 struct LuaContext::Pusher<std::variant<TTypes...>>
@@ -2573,6 +2579,7 @@ struct LuaContext::Pusher<std::variant<TTypes...>>
         return obj;
     }
 };
+#endif /* C++17 */
 
 // boost::optional
 template<typename TType>
@@ -2593,6 +2600,7 @@ struct LuaContext::Pusher<boost::optional<TType>> {
     }
 };
 
+#if __cplusplus >= 201703L
 // std::optional
 template<typename TType>
 struct LuaContext::Pusher<std::optional<TType>> {
@@ -2611,6 +2619,7 @@ struct LuaContext::Pusher<std::optional<TType>> {
         }
     }
 };
+#endif /* C++17 */
 
 // tuple
 template<typename... TTypes>
@@ -2961,6 +2970,7 @@ struct LuaContext::Reader<boost::optional<TType>>
     }
 };
 
+#if __cplusplus >= 201703L
 // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
 template<typename TType>
 struct LuaContext::Reader<std::optional<TType>>
@@ -2978,6 +2988,7 @@ struct LuaContext::Reader<std::optional<TType>>
     }
 };
 // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
+#endif /* C++ 17 */
 
 // boost::variant
 template<typename... TTypes>
@@ -3026,6 +3037,7 @@ public:
     }
 };
 
+#if __cplusplus >= 201703L
 // std::variant
 template<typename... TTypes>
 struct LuaContext::Reader<std::variant<TTypes...>>
@@ -3059,6 +3071,7 @@ public:
         return variantRead(state, index);
     }
 };
+#endif /* C++ 17 */
 
 // reading a tuple
 // tuple have an additional argument for their functions, that is the maximum size to read