From 5470c5fa320fa492488db457d4846f00dfeb4d17 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 12 Feb 2023 19:25:39 +0200 Subject: [PATCH] Resolve C++20 issue with fn == bind(...). Fixes #45. --- include/boost/function.hpp | 2 ++ include/boost/function/detail/epilogue.hpp | 39 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 include/boost/function/detail/epilogue.hpp diff --git a/include/boost/function.hpp b/include/boost/function.hpp index ef907e0..f6ee882 100644 --- a/include/boost/function.hpp +++ b/include/boost/function.hpp @@ -71,4 +71,6 @@ # undef BOOST_PP_ITERATION_PARAMS_1 #endif +#include + #endif // !defined(BOOST_FUNCTION_MAX_ARGS_DEFINED) || (BOOST_FUNCTION_MAX_ARGS_DEFINED != BOOST_FUNCTION_MAX_ARGS) diff --git a/include/boost/function/detail/epilogue.hpp b/include/boost/function/detail/epilogue.hpp new file mode 100644 index 0000000..908788b --- /dev/null +++ b/include/boost/function/detail/epilogue.hpp @@ -0,0 +1,39 @@ +// Boost.Function library + +#ifndef BOOST_FUNCTION_EPILOGUE_HPP +#define BOOST_FUNCTION_EPILOGUE_HPP + +// Copyright 2023 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +// Resolve C++20 issue with fn == bind(...) +// https://github.com/boostorg/function/issues/45 + +#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) + +namespace boost +{ + +namespace _bi +{ + +template class bind_t; + +} // namespace _bi + +template bool operator==( function const& f, _bi::bind_t const& b ) +{ + return f.contains( b ); +} + +template bool operator!=( function const& f, _bi::bind_t const& b ) +{ + return !f.contains( b ); +} + +} // namespace boost + +#endif // #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) + +#endif // #ifndef BOOST_FUNCTION_EPILOGUE_HPP