From b1f05e7268a662fa904e6c81ff5bfee67644b10f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 13 Mar 2005 17:25:42 +0000 Subject: [PATCH] bind_t now implements function_equal instead of operator== [SVN r27630] --- include/boost/bind.hpp | 46 ++++++++++++++++++++++++++++++++++++++---- test/bind_eq_test.cpp | 24 +++++++++++++++++----- 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index af91ddb..0a72571 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -12,6 +12,7 @@ // // Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. // Copyright (c) 2001 David Abrahams +// Copyright (c) 2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -919,18 +920,55 @@ public: #endif -// bind_t::operator== +// function_equal -template bool operator==(bind_t const & a, bind_t const & b) +#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// put overloads in _bi, rely on ADL + +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template bool function_equal( bind_t const & a, bind_t const & b ) { return a.compare(b); } -template bool operator!=(bind_t const & a, bind_t const & b) +# else + +template bool function_equal_impl( bind_t const & a, bind_t const & b, int ) { - return !a.compare(b); + return a.compare(b); } +# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +#else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// put overloads in boost + +} // namespace _bi + +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template bool function_equal( _bi::bind_t const & a, _bi::bind_t const & b ) +{ + return a.compare(b); +} + +# else + +template bool function_equal_impl( _bi::bind_t const & a, _bi::bind_t const & b, int ) +{ + return a.compare(b); +} + +# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +namespace _bi +{ + +#endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + // add_value #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) diff --git a/test/bind_eq_test.cpp b/test/bind_eq_test.cpp index 6950381..742ac73 100644 --- a/test/bind_eq_test.cpp +++ b/test/bind_eq_test.cpp @@ -10,7 +10,7 @@ // // bind_eq_test.cpp - boost::bind equality operator // -// Copyright (c) 2004 Peter Dimov +// Copyright (c) 2004, 2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -20,6 +20,10 @@ #include #include +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +# include +#endif + #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) #pragma warning(push, 3) #endif @@ -142,14 +146,24 @@ void fv_9(X, X, X, X, X, X, X, X, X) template void test_eq(F f1, F f2) { - BOOST_TEST(f1 == f2); - BOOST_TEST(!(f1 != f2)); +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + + using boost::function_equal; + +#endif + + BOOST_TEST( function_equal( f1, f2 ) ); } template void test_ne(F f1, F f2) { - BOOST_TEST(f1 != f2); - BOOST_TEST(!(f1 == f2)); +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + + using boost::function_equal; + +#endif + + BOOST_TEST( !function_equal( f1, f2 ) ); } // 0