Compare commits

...

13 Commits

Author SHA1 Message Date
31b04d14bf This commit was manufactured by cvs2svn to create tag
'Version_1_32_0'.

[SVN r26264]
2004-11-19 19:19:18 +00:00
f3250a605b This commit was manufactured by cvs2svn to create branch 'RC_1_32_0'.
[SVN r25797]
2004-10-20 08:26:43 +00:00
c9d7858ff0 Remove tabs in file.
[SVN r24040]
2004-07-25 15:53:20 +00:00
fdbbc2b3ff Doug Gregor->Douglas Gregor
[SVN r24018]
2004-07-25 02:59:30 +00:00
520ee97c82 Doug Gregor -> Douglas Gregor
[SVN r24016]
2004-07-25 02:29:29 +00:00
e4f632e5ca function_template.hpp: Move definition of operator() out-of-line for
any compiler that isn't VC++ 6.0 (Vladimir Prus)


[SVN r23436]
2004-07-11 03:09:35 +00:00
5b4dc38727 boost/function/function_base.hpp:
- Work around a GCC <= 3.3 bug where the return type of a function template
    that cannot possibly match is instantiated when it should not be, causing
    errors in the use of operator==. This results in slightly reduced
    functionality.

libs/function/test/contains_test.cpp:
  - Don't test that which GCC cannot now handle


[SVN r23170]
2004-06-23 16:00:01 +00:00
22fd23b00f function_template.hpp, function_base.hpp:
- Comparison operators are now written in terms of function_base so that
    implicit conversions to function<...> or functionN<...> don't allow
    arbitrary comparisons.


[SVN r23126]
2004-06-20 05:32:28 +00:00
d929aaf814 Update V2 Jamfile
[SVN r23078]
2004-06-10 12:37:31 +00:00
ae11f21513 Try to make IBM VisualAge C++ 6 happy
[SVN r22795]
2004-05-12 00:39:00 +00:00
dc14c35c38 function_base.hpp:
- Fix silly typo where it returned "false" instead of the NULL
    pointer.


[SVN r22760]
2004-05-07 11:43:41 +00:00
1b27dc8f86 Fix some shadow warnings
[SVN r22670]
2004-04-20 00:32:48 +00:00
2c0e633307 Added contains() and function_equal()
[SVN r22483]
2004-03-12 03:38:20 +00:00
35 changed files with 355 additions and 240 deletions

View File

@ -8,13 +8,14 @@
<author>
<firstname>Douglas</firstname>
<surname>Gregor</surname>
<email>gregod@cs.rpi.edu</email>
<email>dgregor -at- cs.indiana.edu</email>
</author>
<copyright>
<year>2001</year>
<year>2002</year>
<year>2003</year>
<year>2004</year>
<holder>Douglas Gregor</holder>
</copyright>

View File

@ -106,6 +106,18 @@
<throws><simpara>Will not throw.</simpara></throws>
</overloaded-method>
<method name="contains" cv="const">
<template>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f">
<paramtype>const Functor&amp;</paramtype>
</parameter>
<returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code></simpara></returns>
</method>
</method-group>
</class>
@ -262,6 +274,18 @@
<throws><simpara>Will not throw.</simpara></throws>
</overloaded-method>
<method name="contains" cv="const">
<template>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f">
<paramtype>const Functor&amp;</paramtype>
</parameter>
<returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code></simpara></returns>
</method>
</method-group>
<method-group name="invocation">
@ -377,8 +401,9 @@
<listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
and <code>*(f.target&lt;Functor&gt;()) ==
g</code>.</simpara></listitem>
and
<code><functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()),
g)</code>.</simpara></listitem>
</itemizedlist>
</simpara></returns>
@ -479,8 +504,7 @@
<listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
and <code>*(f.target&lt;Functor&gt;()) !=
g</code>.</simpara></listitem>
and <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem>
</itemizedlist>
</simpara></returns>
@ -672,6 +696,18 @@
pointer.</simpara></returns>
<throws><simpara>Will not throw.</simpara></throws>
</overloaded-method>
<method name="contains" cv="const">
<template>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f">
<paramtype>const Functor&amp;</paramtype>
</parameter>
<returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code></simpara></returns>
</method>
</method-group>
<method-group name="invocation">
@ -766,8 +802,7 @@
<listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
and <code>*(f.target&lt;Functor&gt;()) ==
g</code>.</simpara></listitem>
and <code><functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem>
</itemizedlist>
</simpara></returns>
@ -850,8 +885,7 @@
<listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
and <code>*(f.target&lt;Functor&gt;()) !=
g</code>.</simpara></listitem>
and <code>!<functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem>
</itemizedlist>
</simpara></returns>
@ -871,4 +905,25 @@
</class>
</namespace>
</header>
<header name="boost/function_equal.hpp">
<namespace name="boost">
<function name="function_equal">
<template>
<template-type-parameter name="F"/>
<template-type-parameter name="G"/>
</template>
<type>bool</type>
<parameter name="f">
<paramtype>const F&amp;</paramtype>
</parameter>
<parameter name="g">
<paramtype>const G&amp;</paramtype>
</parameter>
<purpose><simpara>Compare two function objects for equality.</simpara></purpose>
<returns><simpara><code>f == g</code>.</simpara></returns>
<throws><simpara>Only if <code>f == g</code> throws.</simpara></throws>
</function>
</namespace>
</header>
</library-reference>

View File

@ -1,6 +1,6 @@
// Boost.Function library examples
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library examples
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library examples
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2003. Use, modification and
// Copyright Douglas Gregor 2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -2,7 +2,7 @@
#
# Boost.Function library
#
# Copyright (C) 2001-2003 Doug Gregor (gregod@cs.rpi.edu)
# Copyright (C) 2001-2003 Douglas Gregor (gregod@cs.rpi.edu)
#
# Permission to copy, use, sell and distribute this software is granted
# provided this copyright notice appears in all copies.

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2003. Use, modification and
// Copyright Douglas Gregor 2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@ -28,6 +28,7 @@
#else
# include "boost/mpl/bool.hpp"
#endif
#include <boost/function_equal.hpp>
// Borrowed from Boost.Python library: determines the cases where we
// need to use std::type_info::name to compare instead of operator==.
@ -62,6 +63,12 @@ namespace boost { namespace python { namespace objects {
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
#endif
#define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \
typename ::boost::enable_if_c<(::boost::type_traits::ice_not< \
(::boost::is_integral<Functor>::value)>::value), \
Type>::type
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
namespace boost {
@ -336,7 +343,7 @@ namespace boost {
mpl::bool_<false>)
{
if (const Functor* fp = f.template target<Functor>())
return *fp == g;
return function_equal(*fp, g);
else return false;
}
@ -356,7 +363,7 @@ namespace boost {
mpl::bool_<false>)
{
if (const Functor* fp = f.template target<Functor>())
return *fp != g;
return !function_equal(*fp, g);
else return true;
}
@ -399,7 +406,7 @@ public:
detail::function::any_pointer result =
manager(detail::function::make_any_pointer(&typeid(Functor)),
detail::function::check_functor_type_tag);
if (!result.obj_ptr) return false;
if (!result.obj_ptr) return 0;
else {
typedef typename detail::function::get_function_tag<Functor>::type tag;
return get_functor_pointer<Functor>(tag(), 0);
@ -414,13 +421,46 @@ public:
detail::function::any_pointer result =
manager(detail::function::make_any_pointer(&typeid(Functor)),
detail::function::check_functor_type_tag);
if (!result.obj_ptr) return false;
if (!result.obj_ptr) return 0;
else {
typedef typename detail::function::get_function_tag<Functor>::type tag;
return get_functor_pointer<Functor>(tag(), 0);
}
}
template<typename F>
bool contains(const F& f) const
{
if (const F* fp = this->template target<F>()) {
return function_equal(*fp, f);
} else {
return false;
}
}
#if defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3
// GCC 3.3 and newer cannot copy with the global operator==, due to
// problems with instantiation of function return types before it
// has been verified that the argument types match up.
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(Functor g) const
{
if (const Functor* fp = target<Functor>())
return function_equal(*fp, g);
else return false;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(Functor g) const
{
if (const Functor* fp = target<Functor>())
return !function_equal(*fp, g);
else return true;
}
#endif
public: // should be protected, but GCC 2.95.3 will fail to allow access
detail::function::any_pointer (*manager)(
detail::function::any_pointer,
@ -482,6 +522,116 @@ inline bool operator!=(detail::function::useless_clear_type*,
}
#endif
#ifdef BOOST_NO_SFINAE
// Comparisons between boost::function objects and arbitrary function objects
template<typename Functor>
inline bool operator==(const function_base& f, Functor g)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_equal(f, g, 0, integral());
}
template<typename Functor>
inline bool operator==(Functor g, const function_base& f)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_equal(f, g, 0, integral());
}
template<typename Functor>
inline bool operator!=(const function_base& f, Functor g)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_not_equal(f, g, 0, integral());
}
template<typename Functor>
inline bool operator!=(Functor g, const function_base& f)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_not_equal(f, g, 0, integral());
}
#else
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
// Comparisons between boost::function objects and arbitrary function
// objects. GCC 3.3 and before has an obnoxious bug that prevents this
// from working.
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(const function_base& f, Functor g)
{
if (const Functor* fp = f.template target<Functor>())
return function_equal(*fp, g);
else return false;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(Functor g, const function_base& f)
{
if (const Functor* fp = f.template target<Functor>())
return function_equal(g, *fp);
else return false;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(const function_base& f, Functor g)
{
if (const Functor* fp = f.template target<Functor>())
return !function_equal(*fp, g);
else return true;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(Functor g, const function_base& f)
{
if (const Functor* fp = f.template target<Functor>())
return !function_equal(g, *fp);
else return true;
}
# endif
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(const function_base& f, reference_wrapper<Functor> g)
{
if (const Functor* fp = f.template target<Functor>())
return fp == g.get_pointer();
else return false;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(reference_wrapper<Functor> g, const function_base& f)
{
if (const Functor* fp = f.template target<Functor>())
return g.get_pointer() == fp;
else return false;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(const function_base& f, reference_wrapper<Functor> g)
{
if (const Functor* fp = f.template target<Functor>())
return fp != g.get_pointer();
else return true;
}
template<typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(reference_wrapper<Functor> g, const function_base& f)
{
if (const Functor* fp = f.template target<Functor>())
return g.get_pointer() != fp;
else return true;
}
#endif // Compiler supporting SFINAE
namespace detail {
namespace function {
inline bool has_empty_target(const function_base* f)
@ -504,6 +654,7 @@ namespace detail {
} // end namespace detail
} // end namespace boost
#undef BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL
#undef BOOST_FUNCTION_COMPARE_TYPE_ID
#endif // BOOST_FUNCTION_BASE_HEADER

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@ -307,6 +307,9 @@ namespace boost {
~BOOST_FUNCTION_FUNCTION() { clear(); }
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
// MSVC 6.0 and prior require all definitions to be inline, but
// these definitions can become very costly.
result_type operator()(BOOST_FUNCTION_PARMS) const
{
if (this->empty())
@ -322,6 +325,9 @@ namespace boost {
return result;
#endif // BOOST_NO_VOID_RETURNS
}
#else
result_type operator()(BOOST_FUNCTION_PARMS) const;
#endif
// The distinction between when to use BOOST_FUNCTION_FUNCTION and
// when to use self_type is obnoxious. MSVC cannot handle self_type as
@ -438,9 +444,9 @@ namespace boost {
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
actual_invoker_type;
invoker = &invoker_type::invoke;
invoker = &actual_invoker_type::invoke;
this->manager =
&detail::function::functor_manager<FunctionPtr, Allocator>::manage;
this->functor =
@ -471,16 +477,16 @@ namespace boost {
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
actual_invoker_type;
invoker = &invoker_type::invoke;
invoker = &actual_invoker_type::invoke;
this->manager = &detail::function::functor_manager<
FunctionObj, Allocator>::manage;
#ifndef BOOST_NO_STD_ALLOCATOR
typedef typename Allocator::template rebind<FunctionObj>::other
allocator_type;
typedef typename allocator_type::pointer pointer_type;
allocator_type allocator;
rebound_allocator_type;
typedef typename rebound_allocator_type::pointer pointer_type;
rebound_allocator_type allocator;
pointer_type copy = allocator.allocate(1);
allocator.construct(copy, f);
@ -505,9 +511,9 @@ namespace boost {
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
actual_invoker_type;
invoker = &invoker_type::invoke;
invoker = &actual_invoker_type::invoke;
this->manager = &detail::function::trivial_manager<FunctionObj>::get;
this->functor =
this->manager(
@ -527,8 +533,8 @@ namespace boost {
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
invoker = &invoker_type::invoke;
actual_invoker_type;
invoker = &actual_invoker_type::invoke;
this->manager = &detail::function::trivial_manager<FunctionObj>::get;
this->functor = detail::function::make_any_pointer(this);
}
@ -556,6 +562,32 @@ namespace boost {
f1.swap(f2);
}
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
typename BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS,
Allocator>::result_type
BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS,
Allocator>
::operator()(BOOST_FUNCTION_PARMS) const
{
if (this->empty())
boost::throw_exception(bad_function_call());
internal_result_type result = invoker(this->functor
BOOST_FUNCTION_COMMA
BOOST_FUNCTION_ARGS);
# ifndef BOOST_NO_VOID_RETURNS
return static_cast<result_type>(result);
# else
return result;
# endif // BOOST_NO_VOID_RETURNS
}
#endif
// Poison comparisons between boost::function objects of the same type.
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator>
@ -578,177 +610,6 @@ template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>&);
#ifdef BOOST_NO_SFINAE
// Comparisons between boost::function objects and arbitrary function objects
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
inline bool
operator==(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f,
Functor g)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_equal(f, g, 0, integral());
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
inline bool
operator==(Functor g,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_equal(f, g, 0, integral());
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
inline bool
operator!=(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f,
Functor g)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_not_equal(f, g, 0, integral());
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
inline bool
operator!=(Functor g,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
return detail::function::compare_not_equal(f, g, 0, integral());
}
#else
#define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \
typename enable_if_c<(::boost::type_traits::ice_not< \
(is_integral<Functor>::value)>::value), \
Type>::type
// Comparisons between boost::function objects and arbitrary function objects
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f,
Functor g)
{
if (const Functor* fp = f.template target<Functor>()) return *fp == g;
else return false;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(Functor g,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f)
{
if (const Functor* fp = f.template target<Functor>()) return g == *fp;
else return false;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f,
Functor g)
{
if (const Functor* fp = f.template target<Functor>()) return *fp != g;
else return true;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(Functor g,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f)
{
if (const Functor* fp = f.template target<Functor>()) return g != *fp;
else return true;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f,
reference_wrapper<Functor> g)
{
if (const Functor* fp = f.template target<Functor>())
return fp == g.get_pointer();
else return false;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator==(reference_wrapper<Functor> g,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f)
{
if (const Functor* fp = f.template target<Functor>())
return g.get_pointer() == fp;
else return false;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f,
reference_wrapper<Functor> g)
{
if (const Functor* fp = f.template target<Functor>())
return fp != g.get_pointer();
else return true;
}
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator, typename Functor>
BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
operator!=(reference_wrapper<Functor> g,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>& f)
{
if (const Functor* fp = f.template target<Functor>())
return g.get_pointer() != fp;
else return true;
}
#undef BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL
#endif // Compiler supporting SFINAE
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
#if BOOST_FUNCTION_NUM_ARGS == 0

View File

@ -2,7 +2,7 @@
#
# Boost.Function library
#
# Copyright Doug Gregor 2001-2003. Use, modification and
# Copyright Douglas Gregor 2001-2003. Use, modification and
# distribution is subject to the Boost Software License, Version
# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

View File

@ -0,0 +1,24 @@
// Copyright Douglas Gregor 2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// For more information, see http://www.boost.org
#ifndef BOOST_FUNCTION_EQUAL_HPP
#define BOOST_FUNCTION_EQUAL_HPP
namespace boost {
namespace detail {
template<typename F, typename G>
bool function_equal_impl(const F& f, const G& g, long)
{ return f == g; }
} // end namespace boost::function
template<typename F, typename G>
bool function_equal(const F& f, const G& g)
{ return ::boost::detail::function_equal_impl(f, g, 0); }
} // end namespace boost
#endif // BOOST_FUNCTION_EQUAL_HPP

View File

@ -1,6 +1,6 @@
# Function library
# Copyright Doug Gregor 2001-2003. Use, modification and
# Copyright Douglas Gregor 2001-2003. Use, modification and
# distribution is subject to the Boost Software License, Version
# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
@ -53,6 +53,9 @@ import testing ;
[ run libs/function/test/function_ref_cxx98.cpp : : : : ]
[ run libs/function/test/function_ref_portable.cpp : : : : ]
[ run libs/function/test/contains_test.cpp : : : : ]
;
}

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2004. Use, modification and
// Copyright Douglas Gregor 2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@ -56,34 +56,46 @@ static void equal_test()
f = &forty_two;
BOOST_TEST(f == &forty_two);
BOOST_TEST(&forty_two == f);
BOOST_TEST(f != ReturnInt(17));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two == f);
BOOST_TEST(ReturnInt(17) != f);
#endif
BOOST_TEST(f.contains(&forty_two));
f = ReturnInt(17);
BOOST_TEST(f != &forty_two);
BOOST_TEST(&forty_two != f);
BOOST_TEST(f == ReturnInt(17));
BOOST_TEST(ReturnInt(17) == f);
BOOST_TEST(f != ReturnInt(16));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two != f);
BOOST_TEST(ReturnInt(17) == f);
BOOST_TEST(ReturnInt(16) != f);
#endif
BOOST_TEST(f.contains(ReturnInt(17)));
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
boost::function<int(void)> g;
g = &forty_two;
BOOST_TEST(g == &forty_two);
BOOST_TEST(&forty_two == g);
BOOST_TEST(g != ReturnInt(17));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two == g);
BOOST_TEST(ReturnInt(17) != g);
# endif
g = ReturnInt(17);
BOOST_TEST(g != &forty_two);
BOOST_TEST(&forty_two != g);
BOOST_TEST(g == ReturnInt(17));
BOOST_TEST(ReturnInt(17) == g);
BOOST_TEST(g != ReturnInt(16));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two != g);
BOOST_TEST(ReturnInt(17) == g);
BOOST_TEST(ReturnInt(16) != g);
# endif
#endif
}
@ -97,22 +109,26 @@ static void ref_equal_test()
BOOST_TEST(f == boost::ref(ri));
BOOST_TEST(f == ri);
BOOST_TEST(boost::ref(ri) == f);
BOOST_TEST(ri == f);
BOOST_TEST(!(f != boost::ref(ri)));
BOOST_TEST(!(f != ri));
BOOST_TEST(!(boost::ref(ri) != f));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri == f);
BOOST_TEST(!(ri != f));
#endif
// Values equal, references inequal
ReturnInt ri2(17);
BOOST_TEST(f == ri2);
BOOST_TEST(f != boost::ref(ri2));
BOOST_TEST(ri2 == f);
BOOST_TEST(boost::ref(ri2) != f);
BOOST_TEST(!(f != ri2));
BOOST_TEST(!(f == boost::ref(ri2)));
BOOST_TEST(!(ri2 != f));
BOOST_TEST(!(boost::ref(ri2) == f));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri2 == f);
BOOST_TEST(!(ri2 != f));
#endif
}
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
@ -124,22 +140,26 @@ static void ref_equal_test()
BOOST_TEST(f == boost::ref(ri));
BOOST_TEST(f == ri);
BOOST_TEST(boost::ref(ri) == f);
BOOST_TEST(ri == f);
BOOST_TEST(!(f != boost::ref(ri)));
BOOST_TEST(!(f != ri));
BOOST_TEST(!(boost::ref(ri) != f));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri == f);
BOOST_TEST(!(ri != f));
# endif
// Values equal, references inequal
ReturnInt ri2(17);
BOOST_TEST(f == ri2);
BOOST_TEST(f != boost::ref(ri2));
BOOST_TEST(ri2 == f);
BOOST_TEST(boost::ref(ri2) != f);
BOOST_TEST(!(f != ri2));
BOOST_TEST(!(f == boost::ref(ri2)));
BOOST_TEST(!(ri2 != f));
BOOST_TEST(!(boost::ref(ri2) == f));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri2 == f);
BOOST_TEST(!(ri2 != f));
# endif
}
#endif
}

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2002-2003. Use, modification and
// Copyright Douglas Gregor 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Boost.Function library
// Copyright Doug Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)