1 <?xml version=
"1.0" encoding=
"utf-8" ?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
6 <meta name=
"generator" content=
"Docutils 0.3.10: http://docutils.sourceforge.net/" />
7 <title>Boost Pointer Container Library
</title>
8 <style type=
"text/css">
11 :Author: David Goodger
12 :Contact: goodger@users.sourceforge.net
15 :Copyright: This stylesheet has been placed in the public domain.
17 Default cascading style sheet for the HTML output of Docutils.
19 See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
20 customize this style sheet.
23 /*
"! important" is used here to override other ``margin-top`` and
24 ``margin-bottom`` styles that are later in the stylesheet or
25 more specific. See http://www.w3.org/TR/CSS1#the-cascade */
27 margin-top:
0 ! important }
29 .last, .with-subtitle {
30 margin-bottom:
0 ! important }
36 text-decoration: none ;
43 margin-bottom:
0.5em }
45 /* Uncomment (and remove this text!) to get bold-faced definition list terms
53 div.abstract p.topic-title {
57 div.admonition, div.attention, div.caution, div.danger, div.error,
58 div.hint, div.important, div.note, div.tip, div.warning {
60 border: medium outset ;
63 div.admonition p.admonition-title, div.hint p.admonition-title,
64 div.important p.admonition-title, div.note p.admonition-title,
65 div.tip p.admonition-title {
67 font-family: sans-serif }
69 div.attention p.admonition-title, div.caution p.admonition-title,
70 div.danger p.admonition-title, div.error p.admonition-title,
71 div.warning p.admonition-title {
74 font-family: sans-serif }
76 /* Uncomment (and remove this text!) to get reduced vertical space in
78 div.compound .compound-first, div.compound .compound-middle {
79 margin-bottom:
0.5em }
81 div.compound .compound-last, div.compound .compound-middle {
90 div.dedication p.topic-title {
97 div.footer, div.header {
106 div.line-block div.line-block {
113 border: medium outset ;
115 background-color: #ffffee ;
120 div.sidebar p.rubric {
121 font-family: sans-serif ;
124 div.system-messages {
127 div.system-messages h1 {
131 border: medium outset ;
134 div.system-message p.system-message-title {
141 h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
142 h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
163 ol.simple, ul.simple {
167 list-style: decimal }
170 list-style: lower-alpha }
173 list-style: upper-alpha }
176 list-style: lower-roman }
179 list-style: upper-roman }
193 white-space: nowrap }
202 font-family: sans-serif ;
207 font-family: sans-serif ;
223 pre.literal-block, pre.doctest-block {
226 background-color: #eeeeee }
229 font-family: sans-serif ;
230 font-style: oblique }
232 span.classifier-delimiter {
233 font-family: sans-serif ;
237 font-family: sans-serif }
240 white-space: nowrap }
248 span.section-subtitle {
249 /* font-size relative to parent (h1..h6 element) */
253 border-left: solid thin gray }
260 margin-bottom:
0.5em }
263 border-left: solid thin black }
265 table.docutils td, table.docutils th,
266 table.docinfo td, table.docinfo th {
267 padding-left:
0.5em ;
268 padding-right:
0.5em ;
269 vertical-align: top }
271 table.docutils th.field-name, table.docinfo th.docinfo-name {
274 white-space: nowrap ;
277 h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
278 h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
282 background-color: #eeeeee }
285 list-style-type: none }
290 <div class=
"document" id=
"boost-pointer-container-library">
291 <h1 class=
"title"><img alt=
"Boost" src=
"boost.png" /> Pointer Container Library
</h1>
292 <h2 class=
"subtitle" id=
"indirected-functions">Indirected functions
</h2>
293 <p>It is quite common that we have two pointers and what to compare the
294 pointed to objects. Also, we have usually already defined how
295 to compare the objects. So to avoid some tedious boiler-plate code
296 this library defines predicates that apply an indirection before comparing.
</p>
297 <p>When the container uses
<tt class=
"docutils literal"><span class=
"pre">void*
</span></tt> internally, we can use the
298 class
<tt class=
"docutils literal"><span class=
"pre">void_ptr_indirect_fun
</span></tt>; otherwise we use the class
299 <tt class=
"docutils literal"><span class=
"pre">indirect_fun
</span></tt>.
</p>
300 <p><strong>Example:
</strong></p>
301 <pre class=
"literal-block">
302 std::string* bar = new std::string(
"bar
");
303 std::string* foo = new std::string(
"foo
");
304 BOOST_ASSERT( indirect_fun
< std::less
<std::string
> >()( bar, foo ) == true );
305 BOOST_ASSERT( make_indirect_fun( std::less
<std::string
>() )( foo, bar ) == false );
309 void_ptr_indirect_fun
< std::less
<std::string
>, std::string
> cast_fun;
310 BOOST_CHECK( cast_fun( vptr1, vptr2 ) == true );
312 <p><strong>See also:
</strong></p>
314 <li><a class=
"reference" href=
"http://www.boost.org/libs/utility/utility.htm#result_of">result_of
</a></li>
315 <li><a class=
"reference" href=
"http://www.boost.org/libs/iterator/doc/pointee.html">pointee
</a></li>
316 <li><a class=
"reference" href=
"ptr_set.html">ptr_set
</a></li>
317 <li><a class=
"reference" href=
"ptr_multiset.html">ptr_multiset
</a></li>
319 <p><strong>Navigate
</strong></p>
321 <li><a class=
"reference" href=
"ptr_container.html">home
</a></li>
322 <li><a class=
"reference" href=
"reference.html">reference
</a></li>
324 <p><strong>Remarks:
</strong></p>
325 <p>The class
<tt class=
"docutils literal"><span class=
"pre">indirect_fun
</span></tt> will work with smart pointers such as
<a class=
"reference" href=
"http://www.boost.org/libs/smart_ptr/shared_ptr.htm">boost::shared_ptr
<T
></a>
326 because of the type traits
<tt class=
"docutils literal"><span class=
"pre">pointee
<T
>::type
</span></tt> from the header
<tt class=
"docutils literal"><span class=
"pre"><boost/pointee.hpp
></span></tt>.
</p>
327 <p><strong>Synopsis:
</strong></p>
328 <p>Since the definition of the predicates is somewhat trivial, only the
329 first operation is expanded inline.
</p>
330 <pre class=
"literal-block">
334 template
< class Fun
>
337 indirect_fun() : fun(Fun())
340 indirect_fun( Fun f ) : fun(f)
343 template
< class T
>
344 typename result_of
< Fun( typename pointee
<T
>::type )
>::type
345 operator()( const T
& r ) const
350 template
< class T, class U
>
351 typename result_of
< Fun( typename pointee
<T
>::type,
352 typename pointee
<U
>::type )
>::type
353 operator()( const T
& r, const U
& r2 ) const
355 return fun( *r, *r2 );
362 template
< class Fun
>
363 inline indirect_fun
<Fun
> make_indirect_fun( Fun f )
365 return indirect_fun
<Fun
>( f );
370 template
< class Fun, class Arg1, class Arg2 = Arg1
>
371 struct void_ptr_indirect_fun
373 void_ptr_indirect_fun() : fun(Fun())
376 void_ptr_indirect_fun( Fun f ) : fun(f)
379 typename result_of
< Fun( Arg1 )
>::type
380 operator()( const void* r ) const
382 return fun( * static_cast
<const Arg1*
>( r ) );
385 typename result_of
< Fun( Arg1, Arg2 )
>::type
386 operator()( const void* l, const void* r ) const
388 return fun( * static_cast
<const Arg1*
>( l ), * static_cast
<const Arg2*
>( r ) );
395 template
< class Fun, class Arg
>
396 inline void_ptr_indirect_fun
<Fun,Arg
>
397 make_void_ptr_indirect_fun( Fun f )
399 return void_ptr_indirect_fun
<Fun,Arg
>( f );
402 } // namespace 'boost'
404 <hr><table class=
"docutils field-list" frame=
"void" rules=
"none">
405 <col class=
"field-name" />
406 <col class=
"field-body" />
408 <tr class=
"field"><th class=
"field-name">Copyright:
</th><td class=
"field-body">Thorsten Ottosen
2004-
2006. Use, modification and distribution is subject to the Boost Software License, Version
1.0 (see
<a class=
"reference" href=
"http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt
</a>).
</td>