reference.xml 46.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
<?xml version="1.0" encoding="utf-8"?>
<!--
   Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
  
   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)
  -->
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
  "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">

<library-reference id="function.reference" last-revision="$Date$">

<section id="function.definitions">
  <title>Definitions</title>
<para>
  <itemizedlist>
    <listitem>
      <para>A function object <computeroutput>f</computeroutput> is
      <emphasis>compatible</emphasis> if for the given set of argument
      types <computeroutput>Arg1</computeroutput>,
      <computeroutput>Arg2</computeroutput>, ...,
      <computeroutput>ArgN</computeroutput> and a
      return type <computeroutput>ResultType</computeroutput>, the
      appropriate following function is well-formed:
<programlisting>
  <emphasis>// if ResultType is not <emphasis role="bold">void</emphasis></emphasis>
  ResultType foo(Arg1 arg1, Arg2 arg2, ..., Arg<emphasis>N</emphasis> arg<emphasis>N</emphasis>)
  {
    <emphasis role="bold">return</emphasis> f(arg1, arg2, ..., arg<emphasis>N</emphasis>);
  }

  <emphasis>// if ResultType is <emphasis role="bold">void</emphasis></emphasis>
  ResultType foo(Arg1 arg1, Arg2 arg2, ..., Arg<emphasis>N</emphasis> arg<emphasis>N</emphasis>)
  {
    f(arg1, arg2, ..., arg<emphasis>N</emphasis>);
  }
</programlisting></para>

      <para> A special provision is made for pointers to member
      functions. Though they are not function objects, Boost.Function
      will adapt them internally to function objects. This requires
      that a pointer to member function of the form <code>R
      (X::*mf)(Arg1, Arg2, ..., ArgN)
      cv-quals</code> be adapted to a
      function object with the following function call operator
      overloads:
<programlisting>
  <emphasis role="bold">template</emphasis>&lt;<emphasis role="bold">typename P</emphasis>&gt;
  R <emphasis role="bold">operator</emphasis>()(<emphasis>cv-quals</emphasis> P&amp; x, Arg1 arg1, Arg2 arg2, ..., Arg<emphasis>N</emphasis> arg<emphasis>N</emphasis>) <emphasis role="bold">const</emphasis>
  {
    <emphasis role="bold">return</emphasis> (*x).*mf(arg1, arg2, ..., arg<emphasis>N</emphasis>);
  }
</programlisting>
</para>
    </listitem>
    <listitem>
      <para>A function object <code>f</code> of
      type <code>F</code> is
      <emphasis>stateless</emphasis> if it is a function pointer or if
      <code><classname>boost::is_stateless</classname>&lt;F&gt;</code>
      is true. The construction of or copy to a Boost.Function object
      from a stateless function object will not cause exceptions to be
      thrown and will not allocate any storage.
      </para>
    </listitem>
  </itemizedlist>
</para>
</section>

<header name="boost/function.hpp">
<namespace name="boost">
  <class name="bad_function_call">
    <inherit access="public"><classname>std::runtime_error</classname></inherit>
    <purpose>An exception type thrown when an instance of a <code>function</code> object is empty when invoked.</purpose>
    <constructor>
      <effects><simpara>Constructs a <code><classname>bad_function_call</classname></code> exception object.</simpara></effects>
    </constructor>
  </class>

  <class name="function_base">
    <purpose>The common base class for all Boost.Function
    objects. Objects of type function_base may not be created
    directly.</purpose>

    <method-group name="capacity">
      <method name="empty" cv="const">
        <type>bool</type>
        <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>
    </method-group>

    <method-group name="target access">
      <overloaded-method name="target">
        <signature>
          <template> 
            <template-type-parameter name="Functor"/>
          </template>
          <type>Functor*</type>
        </signature>
        <signature cv="const">
          <template> 
            <template-type-parameter name="Functor"/>
          </template>
          <type>const Functor*</type>
        </signature>

        <returns><simpara>If <code>this</code> stores a target of type
        <code>Functor</code>, returns the address of the
        target. Otherwise, returns the NULL
        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 name="target_type" cv="const">
        <type>const std::type_info&amp;</type>
        <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Works even with RTTI off.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>
    </method-group>
  </class>

  <class name="functionN">
    <template>
      <template-type-parameter name="R"/>
      <template-type-parameter name="T1"/>
      <template-type-parameter name="T2"/>
      <template-varargs/>
      <template-type-parameter name="TN"/>
    </template>

    <inherit access="public"><classname>function_base</classname></inherit>

    <purpose>A set of generalized function pointers that can be used for callbacks or wrapping function objects.</purpose>

    <description>
      <para>Class template <classname>functionN</classname> is
      actually a family of related classes <classname
      alt="functionN">function0</classname>, <classname
      alt="functionN">function1</classname>, etc., up to some
      implementation-defined maximum. In this context, <code>N</code>
      refers to the number of parameters.</para>
    </description>

    <typedef name="result_type"><type>R</type></typedef>
    <typedef name="argument_type">
      <type>T1</type><purpose>If N == 1</purpose>
    </typedef>
    <typedef name="first_argument_type">
      <type>T1</type>
      <purpose>If N == 2</purpose>
    </typedef>
    <typedef name="second_argument_type">
      <type>T2</type>
      <purpose>If N == 2</purpose>
    </typedef>
    <typedef name="arg1_type"><type>T1</type></typedef>
    <typedef name="arg2_type"><type>T2</type></typedef>
    <typedef name="..."><type/></typedef>
    <typedef name="argN_type"><type>TN</type></typedef>

    <static-constant name="arity">
      <type>int</type>
      <default>N</default>
    </static-constant>

    <struct name="sig">
      <template>
        <template-type-parameter name="Args"/>
      </template>

      <purpose>
        <simpara><libraryname>Lambda</libraryname> library support</simpara>
      </purpose>

      <typedef name="type"><type>result_type</type></typedef>
    </struct>

    <constructor>
      <postconditions><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></postconditions>
      <throws><simpara>Will not throw.</simpara></throws>
    </constructor>

    <constructor>
      <parameter name="f">
        <paramtype>const <classname>functionN</classname>&amp;</paramtype>
      </parameter>
      <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.</simpara></postconditions>
      <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.</simpara></throws>
    </constructor>

    <constructor>
      <parameter name="f">
        <paramtype><classname>functionN</classname>&amp;&amp;</paramtype>
      </parameter>
      <requires><simpara>C++11 compatible compiler.</simpara></requires>
      <postconditions><simpara>Moves the value from <code>f</code> to <code>*this</code>. If the argument has its function object allocated on the heap, its buffer will be assigned to <code>*this</code> leaving argument empty.</simpara></postconditions>
      <throws><simpara>Will not throw unless argument has its function object allocated not on the heap and copying the target of <code>f</code> throws.</simpara></throws>
    </constructor>
    
    <constructor>
      <template>
        <template-type-parameter name="F"/>
      </template>
      <parameter name="f"><paramtype>F</paramtype></parameter>
      <requires><simpara>F is a function object Callable from <code>this</code>.</simpara></requires>
      <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions>
    </constructor>

    <constructor>
      <template>
        <template-type-parameter name="F"/>
        <template-type-parameter name="Allocator"/>
      </template>
      <parameter name="f"><paramtype>F</paramtype></parameter>
      <parameter name="alloc"><paramtype>Allocator</paramtype></parameter>
      <requires><simpara>F is a function object Callable from <code>this</code>, Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw.</simpara></requires>
      <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions>

      <effects><simpara>If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory.</simpara></effects>
    </constructor>

    <destructor>
      <effects><simpara>If <code>!this-&gt;<methodname>empty</methodname>()</code>, destroys the target of this.</simpara></effects>

    </destructor>

    <copy-assignment>
      <parameter name="f">
        <paramtype>const <classname>functionN</classname>&amp;</paramtype>
      </parameter>
      <postconditions><simpara>If copy construction does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></postconditions>
    </copy-assignment>
    
    <copy-assignment>
      <parameter name="f">
        <paramtype><classname>functionN</classname>&amp;&amp;</paramtype>
      </parameter>
      <requires><simpara>C++11 compatible compiler.</simpara></requires>
      <postconditions><simpara>Moves the value from <code>f</code> to <code>*this</code>. If the argument has its function object allocated on the heap, its buffer will be assigned to <code>*this</code> leaving argument empty.</simpara></postconditions>
      <throws><simpara>Will not throw unless argument has its function object allocated not on the heap and copying the target of <code>f</code> throws.</simpara></throws>
    </copy-assignment>

    <method-group name="modifiers">
      <method name="swap">
        <type>void</type>
        <parameter name="f"><paramtype>const <classname>functionN</classname>&amp;</paramtype></parameter>
        <effects><simpara>Interchanges the targets of <code>*this</code> and <code>f</code>.</simpara></effects>
      </method>

      <method name="clear">
        <type>void</type>
        <postconditions><simpara>this-&gt;<methodname>empty</methodname>()</simpara></postconditions>
      </method>
    </method-group>

    <method-group name="capacity">
      <method name="empty" cv="const">
        <type>bool</type>
        <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>

      <method name="conversion-operator" cv="const">
        <type>safe_bool</type>
        <returns><simpara>A <code>safe_bool</code> that evaluates <code>false</code> in a boolean context when <code>this-&gt;<methodname>empty</methodname>()</code>, and <code>true</code> otherwise.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>

      <method name="operator!" cv="const">
        <type>bool</type>
        <returns><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>
    </method-group>

    <method-group name="target access">
      <overloaded-method name="target">
        <signature>
          <template> 
            <template-type-parameter name="Functor"/>
          </template>
          <type>Functor*</type>
        </signature>
        <signature cv="const">
          <template> 
            <template-type-parameter name="Functor"/>
          </template>
          <type>const Functor*</type>
        </signature>

        <returns><simpara>If <code>this</code> stores a target of type
        <code>Functor</code>, returns the address of the
        target. Otherwise, returns the NULL
        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 name="target_type" cv="const">
        <type>const std::type_info&amp;</type>
        <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>

    </method-group>

    <method-group name="invocation">
      <method name="operator()" cv="const">
        <type>result_type</type>
        <parameter name="a1"><paramtype>arg1_type</paramtype></parameter>
        <parameter name="a2"><paramtype>arg2_type</paramtype></parameter>
        <parameter><paramtype>...</paramtype></parameter>
        <parameter name="aN"><paramtype>argN_type</paramtype></parameter>
        <effects><simpara><code>f(a1, a2, ..., aN)</code>, where <code>f</code> is the target of <code>*this</code>.</simpara></effects>
        <returns><simpara>if <code>R</code> is <code>void</code>, nothing is returned; otherwise, the return value of the call to <code>f</code> is returned.</simpara></returns>
        <throws><simpara><code><classname>bad_function_call</classname></code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Otherwise, may through any exception thrown by the target function <code>f</code>.</simpara></throws>
      </method>
    </method-group>

    <free-function-group name="specialized algorithms">
      <function name="swap">
        <template>
          <template-type-parameter name="T1"/>
          <template-type-parameter name="T2"/>
          <template-varargs/>
          <template-type-parameter name="TN"/>
        </template>
        <type>void</type>
        <parameter name="f1"><paramtype><classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
        <parameter name="f2"><paramtype><classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
        <effects><simpara><code>f1.<methodname>swap</methodname>(f2)</code></simpara></effects>
      </function>
    </free-function-group>

    <free-function-group name="comparison operators">
      <overloaded-function name="operator==">
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="U1"/>
            <template-type-parameter name="U2"/>
            <template-varargs/>
            <template-type-parameter name="UN"/>
          </template>
          <type>void</type>
          <parameter name="f1"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
          <parameter name="f2"><paramtype>const <classname>functionN</classname>&lt;U1, U2, ..., UN&gt;&amp;</paramtype></parameter>
        </signature>

        <returns><simpara>True when <code>f</code> stores an object of
        type <code>Functor</code> and one of the following conditions applies:
          <itemizedlist>

            <listitem><simpara><code>g</code> is of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code>f.target&lt;Functor&gt;() == g.<methodname
            alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem>

            <listitem><simpara><code>g</code> is not of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and
            <code><functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()),
            g)</code>.</simpara></listitem>

          </itemizedlist>
          </simpara></returns>

        <notes><simpara><code><classname>functionN</classname></code>
        objects are not
        <conceptname>EqualityComparable</conceptname>.</simpara></notes>

        <rationale><simpara>The <code>safe_bool</code> conversion
        opens a loophole whereby two <code>functionN</code>
        instances can be compared via <code>==</code>, although this
        is not feasible to implement. The undefined <code>void
        operator==</code> closes the loophole and ensures a
        compile-time or link-time error.</simpara></rationale>
      </overloaded-function>

      <overloaded-function name="operator!=">
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="T1"/>
            <template-type-parameter name="T2"/>
            <template-varargs/>
            <template-type-parameter name="TN"/>
            <template-type-parameter name="U1"/>
            <template-type-parameter name="U2"/>
            <template-varargs/>
            <template-type-parameter name="UN"/>
          </template>
          <type>void</type>
          <parameter name="f1"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
          <parameter name="f2"><paramtype>const <classname>functionN</classname>&lt;U1, U2, ..., UN&gt;&amp;</paramtype></parameter>
        </signature>

        <returns><simpara>True when <code>f</code> does not store an
        object of type <code>Functor</code> or it stores an object of
        type <code>Functor</code> and one of the following conditions
        applies:
          <itemizedlist>

            <listitem><simpara><code>g</code> is of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code>f.target&lt;Functor&gt;() != g.<methodname
            alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem>

            <listitem><simpara><code>g</code> is not of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem>

          </itemizedlist>
          </simpara></returns>

        <notes><simpara><code><classname>functionN</classname></code>
        objects are not
        <conceptname>EqualityComparable</conceptname>.</simpara></notes>

        <rationale><simpara>The <code>safe_bool</code> conversion
        opens a loophole whereby two <code>functionN</code>
        instances can be compared via <code>!=</code>, although this
        is not feasible to implement. The undefined <code>void
        operator!=</code> closes the loophole and ensures a
        compile-time or link-time error.</simpara></rationale>
      </overloaded-function>
    </free-function-group>
  </class>

  <class name="function">
    <template>
      <template-type-parameter name="Signature">
        <purpose>Function type R (T1, T2, ..., TN)</purpose>
      </template-type-parameter>
    </template>
    <inherit access="public"><classname>functionN</classname>&lt;R, T1, T2, ..., TN&gt;</inherit>

    <purpose>A generalized function pointer that can be used for
    callbacks or wrapping function objects.</purpose>

    <description>
      <para>Class template <classname>function</classname> is a thin
      wrapper around the numbered class templates <classname
      alt="functionN">function0</classname>, <classname
      alt="functionN">function1</classname>, etc. It accepts a
      function type with N arguments and will will derive from
      <classname>functionN</classname> instantiated with the arguments
      it receives.</para>

      <para>The semantics of all operations in class template
      <classname>function</classname> are equivalent to that of the
      underlying <classname>functionN</classname> object, although
      additional member functions are required to allow proper copy
      construction and copy assignment of function objects.</para>
    </description>

    <typedef name="result_type"><type>R</type></typedef>
    <typedef name="argument_type">
      <type>T1</type><purpose>If N == 1</purpose>
    </typedef>
    <typedef name="first_argument_type">
      <type>T1</type>
      <purpose>If N == 2</purpose>
    </typedef>
    <typedef name="second_argument_type">
      <type>T2</type>
      <purpose>If N == 2</purpose>
    </typedef>
    <typedef name="arg1_type"><type>T1</type></typedef>
    <typedef name="arg2_type"><type>T2</type></typedef>
    <typedef name="..."><type/></typedef>
    <typedef name="argN_type"><type>TN</type></typedef>

    <static-constant name="arity">
      <type>int</type>
      <default>N</default>
    </static-constant>

    <struct name="sig">
      <template>
        <template-type-parameter name="Args"/>
      </template>

      <purpose>
        <simpara><libraryname>Lambda</libraryname> library support</simpara>
      </purpose>

      <typedef name="type"><type>result_type</type></typedef>
    </struct>

    <constructor>
      <postconditions><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></postconditions>
      <throws><simpara>Will not throw.</simpara></throws>
    </constructor>

    <constructor>
      <parameter name="f">
        <paramtype>const <classname>functionN</classname>&amp;</paramtype>
      </parameter>
      <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.</simpara></postconditions>
      <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.</simpara></throws>
    </constructor>
        
    <constructor>
      <parameter name="f">
        <paramtype><classname>functionN</classname>&amp;&amp;</paramtype>
      </parameter>
      <requires><simpara>C++11 compatible compiler.</simpara></requires>
      <postconditions><simpara>Moves the value from <code>f</code> to <code>*this</code>. If the argument has its function object allocated on the heap, its buffer will be assigned to <code>*this</code> leaving argument empty.</simpara></postconditions>
      <throws><simpara>Will not throw unless argument has its function object allocated not on the heap and copying the target of <code>f</code> throws.</simpara></throws>
    </constructor>
    
    <constructor>
      <parameter name="f">
        <paramtype>const <classname>function</classname>&amp;</paramtype>
      </parameter>
      <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.</simpara></postconditions>
      <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.</simpara></throws>
    </constructor>

    <constructor>
      <parameter name="f">
        <paramtype><classname>function</classname>&amp;&amp;</paramtype>
      </parameter>
      <requires><simpara>C++11 compatible compiler.</simpara></requires>
      <postconditions><simpara>Moves the value from <code>f</code> to <code>*this</code>. If the argument has its function object allocated on the heap, its buffer will be assigned to <code>*this</code> leaving argument empty.</simpara></postconditions>
      <throws><simpara>Will not throw unless argument has its function object allocated not on the heap and copying the target of <code>f</code> throws.</simpara></throws>
    </constructor>
    
    <constructor>
      <template>
        <template-type-parameter name="F"/>
      </template>
      <parameter name="f"><paramtype>F</paramtype></parameter>
      <requires><simpara>F is a function object Callable from <code>this</code>.</simpara></requires>
      <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions>
    </constructor>

    <constructor>
      <template>
        <template-type-parameter name="F"/>
        <template-type-parameter name="Allocator"/>
      </template>
      <parameter name="f"><paramtype>F</paramtype></parameter>
      <parameter name="alloc"><paramtype>Allocator</paramtype></parameter>
      <requires><simpara>F is a function object Callable from <code>this</code>, Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw.</simpara></requires>
      <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions>

      <effects><simpara>If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory.</simpara></effects>
    </constructor>

    <destructor>
      <effects><simpara>If <code>!this-&gt;<methodname>empty</methodname>()</code>, destroys the target of <code>this</code>.</simpara></effects>

    </destructor>

    <copy-assignment>
      <parameter name="f">
        <paramtype>const <classname>functionN</classname>&amp;</paramtype>
      </parameter>
      <postconditions><simpara>If copy construction does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></postconditions>
    </copy-assignment>
    
    <copy-assignment>
      <parameter name="f">
        <paramtype><classname>functionN</classname>&amp;&amp;</paramtype>
      </parameter>
      <requires><simpara>C++11 compatible compiler.</simpara></requires>
      <postconditions><simpara>Moves the value from <code>f</code> to <code>*this</code>. If the argument has its function object allocated on the heap, its buffer will be assigned to <code>*this</code> leaving argument empty.</simpara></postconditions>
      <throws><simpara>Will not throw unless argument has its function object allocated not on the heap and copying the target of <code>f</code> throws.</simpara></throws>
    </copy-assignment>

    <copy-assignment>
      <parameter name="f">
        <paramtype>const <classname>function</classname>&amp;</paramtype>
      </parameter>
      <postconditions><simpara>If copy construction of the target of <code>f</code> does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. </simpara></postconditions>
      <throws><simpara>Will not throw when the target of <code>f</code> is a stateless function object or a reference to the function object. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></throws>
    </copy-assignment>
    
    <copy-assignment>
      <parameter name="f">
        <paramtype><classname>function</classname>&amp;&amp;</paramtype>
      </parameter>
      <requires><simpara>C++11 compatible compiler.</simpara></requires>
      <postconditions><simpara>Moves the value from <code>f</code> to <code>*this</code>. If the argument has its function object allocated on the heap, its buffer will be assigned to <code>*this</code> leaving argument empty.</simpara></postconditions>
      <throws><simpara>Will not throw unless argument has its function object allocated not on the heap and copying the target of <code>f</code> throws.</simpara></throws>
    </copy-assignment>

    <method-group name="modifiers">
      <method name="swap">
        <type>void</type>
        <parameter name="f"><paramtype>const <classname>function</classname>&amp;</paramtype></parameter>
        <effects><simpara>Interchanges the targets of <code>*this</code> and <code>f</code>.</simpara></effects>
      </method>

      <method name="clear">
        <type>void</type>
        <postconditions><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></postconditions>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>
    </method-group>

    <method-group name="capacity">
      <method name="empty" cv="const">
        <type>bool</type>
        <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>

      <method name="conversion-operator" cv="const">
        <type>safe_bool</type>
        <returns><simpara>A <code>safe_bool</code> that evaluates <code>false</code> in a boolean context when <code>this-&gt;<methodname>empty</methodname>()</code>, and <code>true</code> otherwise.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>

      <method name="operator!" cv="const">
        <type>bool</type>
        <returns><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>
    </method-group>

    <method-group name="target access">
      <overloaded-method name="target">
        <signature>
          <template> 
            <template-type-parameter name="Functor"/>
          </template>
          <type>Functor*</type>
        </signature>
        <signature cv="const">
          <template> 
            <template-type-parameter name="Functor"/>
          </template>
          <type>const Functor*</type>
        </signature>

        <returns><simpara>If <code>this</code> stores a target of type
        <code>Functor</code>, returns the address of the
        target. Otherwise, returns the NULL
        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 name="target_type" cv="const">
        <type>const std::type_info&amp;</type>
        <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></returns>
        <throws><simpara>Will not throw.</simpara></throws>
      </method>
    </method-group>

    <method-group name="invocation">
      <method name="operator()" cv="const">
        <type>result_type</type>
        <parameter name="a1"><paramtype>arg1_type</paramtype></parameter>
        <parameter name="a2"><paramtype>arg2_type</paramtype></parameter>
        <parameter><paramtype>...</paramtype></parameter>
        <parameter name="aN"><paramtype>argN_type</paramtype></parameter>
        <effects><simpara><code>f(a1, a2, ..., aN)</code>, where <code>f</code> is the target of <code>*this</code>.</simpara></effects>
        <returns><simpara>if <code>R</code> is <code>void</code>, nothing is returned; otherwise, the return value of the call to <code>f</code> is returned.</simpara></returns>
        <throws><simpara><code><classname>bad_function_call</classname></code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Otherwise, may through any exception thrown by the target function <code>f</code>.</simpara></throws>
      </method>
    </method-group>

    <free-function-group name="specialized algorithms">
      <function name="swap">
        <template>
          <template-type-parameter name="Signature"/>
        </template>
        <type>void</type>
        <parameter name="f1"><paramtype><classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
        <parameter name="f2"><paramtype><classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
        <effects><simpara><code>f1.<methodname>swap</methodname>(f2)</code></simpara></effects>
      </function>
    </free-function-group>

    <free-function-group name="comparison operators">
      <overloaded-function name="operator==">
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="Signature1"/>
            <template-type-parameter name="Signature2"/>
          </template>
          <type>void</type>
          <parameter name="f1"><paramtype>const <classname>function</classname>&lt;Signature1&gt;&amp;</paramtype></parameter>
          <parameter name="f2"><paramtype>const <classname>function</classname>&lt;Signature2&gt;&amp;</paramtype></parameter>
        </signature>

        <returns><simpara>True when <code>f</code> stores an object of
        type <code>Functor</code> and one of the following conditions applies:
          <itemizedlist>

            <listitem><simpara><code>g</code> is of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code>f.target&lt;Functor&gt;() == g.<methodname
            alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem>

            <listitem><simpara><code>g</code> is not of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code><functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem>

          </itemizedlist>
          </simpara></returns>

        <notes><simpara><code><classname>function</classname></code>
        objects are not
        <conceptname>EqualityComparable</conceptname>.</simpara></notes>

        <rationale><simpara>The <code>safe_bool</code> conversion
        opens a loophole whereby two <code>function</code>
        instances can be compared via <code>==</code>, although this
        is not feasible to implement. The undefined <code>void
        operator==</code> closes the loophole and ensures a
        compile-time or link-time error.</simpara></rationale>
      </overloaded-function>

      <overloaded-function name="operator!=">
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype>Functor</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
        </signature>
        <signature>
          <template>
            <template-type-parameter name="Signature"/>
            <template-type-parameter name="Functor"/>
          </template>
          <type>bool</type>
          <parameter name="g"><paramtype><classname>reference_wrapper</classname>&lt;Functor&gt;</paramtype></parameter>
          <parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature&gt;&amp;</paramtype></parameter>
        </signature>        
        <signature>
          <template>
            <template-type-parameter name="Signature1"/>
            <template-type-parameter name="Signature2"/>
          </template>
          <type>void</type>
          <parameter name="f1"><paramtype>const <classname>function</classname>&lt;Signature1&gt;&amp;</paramtype></parameter>
          <parameter name="f2"><paramtype>const <classname>function</classname>&lt;Signature2&gt;&amp;</paramtype></parameter>
        </signature>

        <returns><simpara>True when <code>f</code> does not store an
        object of type <code>Functor</code> or it stores an object of
        type <code>Functor</code> and one of the following conditions
        applies:
          <itemizedlist>

            <listitem><simpara><code>g</code> is of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code>f.target&lt;Functor&gt;() != g.<methodname
            alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem>

            <listitem><simpara><code>g</code> is not of type
            <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
            and <code>!<functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem>

          </itemizedlist>
          </simpara></returns>

        <notes><simpara><code><classname>function</classname></code>
        objects are not
        <conceptname>EqualityComparable</conceptname>.</simpara></notes>

        <rationale><simpara>The <code>safe_bool</code> conversion
        opens a loophole whereby two <code>function</code>
        instances can be compared via <code>!=</code>, although this
        is not feasible to implement. The undefined <code>void
        operator!=</code> closes the loophole and ensures a
        compile-time or link-time error.</simpara></rationale>
      </overloaded-function>
    </free-function-group>
  </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>