From a9a295e4aa213a0430f0058b3e21299641072f56 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 4 Jan 2023 01:36:20 +0100 Subject: [PATCH] Avoid -Wzero-as-null-pointer-constant warnings. --- include/boost/pfr/core.hpp | 4 ++-- include/boost/pfr/detail/core14_classic.hpp | 16 ++++++++-------- include/boost/pfr/detail/core17_generated.hpp | 4 ++-- include/boost/pfr/detail/unsafe_declval.hpp | 2 +- misc/generate_cpp17.py | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/boost/pfr/core.hpp b/include/boost/pfr/core.hpp index 08837e6..f3585bb 100644 --- a/include/boost/pfr/core.hpp +++ b/include/boost/pfr/core.hpp @@ -66,7 +66,7 @@ constexpr auto get(T&, std::enable_if_t::value>* = nul /// \overload get template -constexpr auto get(T&& val, std::enable_if_t< std::is_rvalue_reference::value>* = 0) noexcept { +constexpr auto get(T&& val, std::enable_if_t< std::is_rvalue_reference::value>* = nullptr) noexcept { return std::move(detail::sequence_tuple::get( detail::tie_as_tuple(val) )); } @@ -159,7 +159,7 @@ constexpr auto structure_tie(T&, std::enable_if_t::val /// \overload structure_tie template -constexpr auto structure_tie(T&&, std::enable_if_t< std::is_rvalue_reference::value>* = 0) noexcept { +constexpr auto structure_tie(T&&, std::enable_if_t< std::is_rvalue_reference::value>* = nullptr) noexcept { static_assert(sizeof(T) && false, "====================> Boost.PFR: Calling boost::pfr::structure_tie on rvalue references is forbidden"); return 0; } diff --git a/include/boost/pfr/detail/core14_classic.hpp b/include/boost/pfr/detail/core14_classic.hpp index 7cd4257..183337c 100644 --- a/include/boost/pfr/detail/core14_classic.hpp +++ b/include/boost/pfr/detail/core14_classic.hpp @@ -118,16 +118,16 @@ template constexpr std::size_t type_to_id(identity) no template constexpr std::size_t type_to_id(identity) noexcept; template constexpr std::size_t type_to_id(identity) noexcept; template constexpr std::size_t type_to_id(identity) noexcept; -template constexpr std::size_t type_to_id(identity, std::enable_if_t::value>* = 0) noexcept; -template constexpr std::size_t type_to_id(identity, std::enable_if_t::value>* = 0) noexcept; -template constexpr std::size_t type_to_id(identity, std::enable_if_t::value>* = 0) noexcept; +template constexpr std::size_t type_to_id(identity, std::enable_if_t::value>* = nullptr) noexcept; +template constexpr std::size_t type_to_id(identity, std::enable_if_t::value>* = nullptr) noexcept; +template constexpr std::size_t type_to_id(identity, std::enable_if_t::value>* = nullptr) noexcept; template constexpr size_array type_to_id(identity, std::enable_if_t::value && !std::is_empty::value && !std::is_union::value>* = 0) noexcept; -template constexpr auto id_to_type(size_t_, if_extension = 0) noexcept; -template constexpr auto id_to_type(size_t_, if_extension = 0) noexcept; -template constexpr auto id_to_type(size_t_, if_extension = 0) noexcept; -template constexpr auto id_to_type(size_t_, if_extension = 0) noexcept; -template constexpr auto id_to_type(size_t_, if_extension = 0) noexcept; +template constexpr auto id_to_type(size_t_, if_extension = nullptr) noexcept; +template constexpr auto id_to_type(size_t_, if_extension = nullptr) noexcept; +template constexpr auto id_to_type(size_t_, if_extension = nullptr) noexcept; +template constexpr auto id_to_type(size_t_, if_extension = nullptr) noexcept; +template constexpr auto id_to_type(size_t_, if_extension = nullptr) noexcept; ///////////////////// Definitions of type_to_id and id_to_type for fundamental types diff --git a/include/boost/pfr/detail/core17_generated.hpp b/include/boost/pfr/detail/core17_generated.hpp index ea9dbfb..560d0d4 100644 --- a/include/boost/pfr/detail/core17_generated.hpp +++ b/include/boost/pfr/detail/core17_generated.hpp @@ -59,14 +59,14 @@ constexpr auto tie_as_tuple(T& /*val*/, size_t_<0>) noexcept { } template -constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = 0) noexcept { +constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = nullptr) noexcept { auto& [a] = const_cast&>(val); // ====================> Boost.PFR: User-provided type is not a SimpleAggregate. return ::boost::pfr::detail::make_tuple_of_references(detail::workaround_cast(a)); } template -constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = 0) noexcept { +constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = nullptr) noexcept { return ::boost::pfr::detail::make_tuple_of_references( val ); } diff --git a/include/boost/pfr/detail/unsafe_declval.hpp b/include/boost/pfr/detail/unsafe_declval.hpp index 62404c5..8afb4fc 100644 --- a/include/boost/pfr/detail/unsafe_declval.hpp +++ b/include/boost/pfr/detail/unsafe_declval.hpp @@ -24,7 +24,7 @@ template constexpr T unsafe_declval() noexcept { report_if_you_see_link_error_with_this_function(); - typename std::remove_reference::type* ptr = 0; + typename std::remove_reference::type* ptr = nullptr; ptr += 42; // suppresses 'null pointer dereference' warnings return static_cast(*ptr); } diff --git a/misc/generate_cpp17.py b/misc/generate_cpp17.py index 5350e07..98c57bc 100644 --- a/misc/generate_cpp17.py +++ b/misc/generate_cpp17.py @@ -76,14 +76,14 @@ constexpr auto tie_as_tuple(T& /*val*/, size_t_<0>) noexcept { } template -constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = 0) noexcept { +constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = nullptr) noexcept { auto& [a] = const_cast&>(val); // ====================> Boost.PFR: User-provided type is not a SimpleAggregate. return ::boost::pfr::detail::make_tuple_of_references(detail::workaround_cast(a)); } template -constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = 0) noexcept { +constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t >::value>* = nullptr) noexcept { return ::boost::pfr::detail::make_tuple_of_references( val ); }