Compare commits

..

1 Commits

Author SHA1 Message Date
Beman Dawes
1033171b18 Release 1.41.0
[SVN r57747]
2009-11-18 14:58:26 +00:00
8 changed files with 31 additions and 273 deletions

View File

@@ -61,7 +61,6 @@
bind&lt;R&gt;(f, ...)</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_nonstd">Binding a nonstandard function</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_overloaded">Binding an overloaded function</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_modeling_stl_function_object_concepts">Modeling STL function object concepts</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_const_arg"><b>const</b> in signatures</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
boost::bind;</A></h4>
@@ -586,48 +585,6 @@ int main()
boost::bind( get, _1 );
}
</pre>
<h3><a name="err_modeling_stl_function_object_concepts">Modeling STL function object concepts</a></h3>
<p>The function objects that are produced by <b>boost::bind</b> do not model the
STL <a href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary Function</a> or
<a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> concepts,
even when the function objects are unary or binary operations, because the function object
types are missing public typedefs <tt>result_type</tt> and <tt>argument_type</tt> or
<tt>first_argument_type</tt> and <tt>second_argument_type</tt>. In cases where these
typedefs are desirable, however, the utility function <tt>make_adaptable</tt>
can be used to adapt unary and binary function objects to these concepts. This allows
unary and binary function objects resulting from <b>boost::bind</b> to be combined with
STL templates such as <a href="http://msdn.microsoft.com/en-us/library/se0409db%28v=VS.90%29.aspx"><tt>std::unary_negate</tt></a>
and <a href="http://msdn.microsoft.com/en-us/library/833073z4%28v=VS.90%29.aspx"><tt>std::binary_negate</tt></a>.</p>
<p>The <tt>make_adaptable</tt> function is defined in &lt;<a href="../../boost/bind/make_adaptable.hpp">boost/bind/make_adaptable.hpp</a>&gt;,
which must be included explicitly in addition to &lt;boost/bind.hpp&gt;:</p>
<pre>
#include &lt;boost/bind/make_adaptable.hpp&gt;
template &lt;class R, class F&gt; <i>unspecified-type</i> make_adaptable(F f);
template&lt;class R, class A1, class F&gt; <i>unspecified-unary-functional-type</i> make_adaptable(F f);
template&lt;class R, class A1, class A2, class F&gt; <i>unspecified-binary-functional-type</i> make_adaptable(F f);
template&lt;class R, class A1, class A2, class A3, class F&gt; <i>unspecified-ternary-functional-type</i> make_adaptable(F f);
template&lt;class R, class A1, class A2, class A3, class A4, class F&gt; <i>unspecified-4-ary-functional-type</i> make_adaptable(F f);
</pre>
<p>This example shows how to use <tt>make_adaptable</tt> to make a predicate for "is not a space":</p>
<pre>typedef char char_t;
std::locale loc("");
const std::ctype&lt;char_t&gt;&amp; ct = std::use_facet&lt;std::ctype&lt;char_t&gt; &gt;(loc);
auto isntspace = std::not1( boost::make_adaptable&lt;bool, char_t&gt;( boost::bind(&amp;std::ctype&lt;char_t&gt;::is, &amp;ct, std::ctype_base::space, _1) ) );
</pre>
<p>In this example, <b>boost::bind</b> creates the "is a space" (unary) predicate.
It is then passed to <tt>make_adaptable</tt> so that a function object modeling
the Unary Function concept can be created, serving as the argument to
<a href="http://msdn.microsoft.com/en-us/library/syyszzf8%28v=VS.90%29.aspx"><tt>std::not1</tt></a>.</p>
<h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
<p>Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the
top-level <b>const</b> in function signatures:

View File

@@ -9,6 +9,5 @@ import boostbook : boostbook ;
boostbook ref-doc : ref.xml
:
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
<xsl:param>boost.root=../../../..
;

View File

@@ -207,13 +207,6 @@ public:
}
};
#ifdef BOOST_MSVC
// MSVC is bright enough to realise that the parameter rhs
// in operator==may be unused for some template argument types:
#pragma warning(push)
#pragma warning(disable:4100)
#endif
template< class A1 > class list1: private storage1< A1 >
{
private:
@@ -853,10 +846,6 @@ public:
}
};
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
// bind_t
#ifndef BOOST_NO_VOID_RETURNS
@@ -1640,7 +1629,7 @@ template<class F, class A1, class A2, class A3, class A4, class A5, class A6, cl
// data member pointers
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|| ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) ) )
|| ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, <= 0x610 ) )
template<class R, class T, class A1>
_bi::bind_t< R, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
@@ -1665,14 +1654,7 @@ template< class M, class T > struct add_cref< M T::*, 0 >
template< class M, class T > struct add_cref< M T::*, 1 >
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4180)
#endif
typedef M const & type;
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
};
template< class R, class T > struct add_cref< R (T::*) (), 1 >
@@ -1680,7 +1662,7 @@ template< class R, class T > struct add_cref< R (T::*) (), 1 >
typedef void type;
};
#if !defined(__IBMCPP__) || __IBMCPP_FUNC_CV_TMPL_ARG_DEDUCTION
#if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) )
template< class R, class T > struct add_cref< R (T::*) () const, 1 >
{

View File

@@ -51,16 +51,14 @@ public:
template<class U> R operator()(U & u) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p);
BOOST_MEM_FN_RETURN call(u, &u);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p);
BOOST_MEM_FN_RETURN call(u, &u);
}
#endif
@@ -111,8 +109,7 @@ public:
template<class U> R operator()(U const & u) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p);
BOOST_MEM_FN_RETURN call(u, &u);
}
R operator()(T const & t) const
@@ -167,16 +164,14 @@ public:
template<class U> R operator()(U & u, A1 a1) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1);
BOOST_MEM_FN_RETURN call(u, &u, a1);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1);
BOOST_MEM_FN_RETURN call(u, &u, a1);
}
#endif
@@ -228,8 +223,7 @@ public:
template<class U> R operator()(U const & u, A1 a1) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1);
BOOST_MEM_FN_RETURN call(u, &u, a1);
}
R operator()(T const & t, A1 a1) const
@@ -282,16 +276,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
}
#endif
@@ -341,8 +333,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
}
R operator()(T const & t, A1 a1, A2 a2) const
@@ -395,16 +386,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
}
#endif
@@ -454,8 +443,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3) const
@@ -508,16 +496,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
}
#endif
@@ -567,8 +553,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const
@@ -621,16 +606,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
}
#endif
@@ -680,8 +663,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
@@ -734,16 +716,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
}
#endif
@@ -793,8 +773,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
@@ -847,16 +826,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
}
#endif
@@ -906,8 +883,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
@@ -960,16 +936,14 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
}
#endif
@@ -1024,8 +998,7 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const

View File

@@ -25,7 +25,7 @@
namespace
{
#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ < 4)
#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 400)
static inline boost::arg<1> _1() { return boost::arg<1>(); }
static inline boost::arg<2> _2() { return boost::arg<2>(); }
@@ -38,7 +38,7 @@ static inline boost::arg<8> _8() { return boost::arg<8>(); }
static inline boost::arg<9> _9() { return boost::arg<9>(); }
#elif defined(BOOST_MSVC) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__) || \
defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ == 400)
static boost::arg<1> _1;
static boost::arg<2> _2;

View File

@@ -43,5 +43,4 @@ test-suite "bind"
[ run bind_ref_test.cpp ]
[ run bind_eq3_test.cpp ]
[ run protect_test.cpp ]
[ run mem_fn_unary_addr_test.cpp ]
;

View File

@@ -5,7 +5,6 @@
# pragma warning(disable: 4710) // function not inlined
# pragma warning(disable: 4711) // function selected for automatic inline expansion
# pragma warning(disable: 4514) // unreferenced inline removed
# pragma warning(disable: 4100) // unreferenced formal parameter (it is referenced!)
#endif
// Copyright (c) 2006 Douglas Gregor <doug.gregor@gmail.com>

View File

@@ -1,151 +0,0 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// mem_fn_unary_addr_test.cpp - poisoned operator& test
//
// Copyright (c) 2009 Peter Dimov
//
// Distributed under 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
//
#include <boost/mem_fn.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
unsigned int hash = 0;
struct X
{
int f0() { f1(17); return 0; }
int g0() const { g1(17); return 0; }
int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
int f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
};
template<class T> class Y
{
private:
T * pt_;
void operator& ();
void operator& () const;
public:
explicit Y( T * pt ): pt_( pt )
{
}
T * get() const
{
return pt_;
}
};
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) )
namespace boost
{
#endif
template<class T> T * get_pointer( Y< T > const & y )
{
return y.get();
}
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) )
} // namespace boost
#endif
int detect_errors(bool x)
{
if( x )
{
std::cerr << "no errors detected.\n";
return 0;
}
else
{
std::cerr << "test failed.\n";
return 1;
}
}
int main()
{
using boost::mem_fn;
X x;
Y<X> px( &x );
Y<X const> pcx( &x );
mem_fn(&X::f0)( px );
mem_fn(&X::g0)( pcx );
mem_fn(&X::f1)( px, 1 );
mem_fn(&X::g1)( pcx, 1 );
mem_fn(&X::f2)( px, 1, 2 );
mem_fn(&X::g2)( pcx, 1, 2 );
mem_fn(&X::f3)( px, 1, 2, 3 );
mem_fn(&X::g3)( pcx, 1, 2, 3 );
mem_fn(&X::f4)( px, 1, 2, 3, 4 );
mem_fn(&X::g4)( pcx, 1, 2, 3, 4 );
mem_fn(&X::f5)( px, 1, 2, 3, 4, 5 );
mem_fn(&X::g5)( pcx, 1, 2, 3, 4, 5 );
mem_fn(&X::f6)( px, 1, 2, 3, 4, 5, 6 );
mem_fn(&X::g6)( pcx, 1, 2, 3, 4, 5, 6 );
mem_fn(&X::f7)( px, 1, 2, 3, 4, 5, 6, 7 );
mem_fn(&X::g7)( pcx, 1, 2, 3, 4, 5, 6, 7 );
mem_fn(&X::f8)( px, 1, 2, 3, 4, 5, 6, 7, 8 );
mem_fn(&X::g8)( pcx, 1, 2, 3, 4, 5, 6, 7, 8 );
return detect_errors( hash == 2155 );
}