Compare commits

..

18 Commits

Author SHA1 Message Date
03bef419ac merged from trunk
[SVN r49607]
2008-11-06 00:15:47 +00:00
20efadeb6f merged from trunk
[SVN r49439]
2008-10-22 20:32:22 +00:00
4f50451f4b merged from trunk
[SVN r49133]
2008-10-05 01:47:33 +00:00
313a188f4d merged from trunk
[SVN r48673]
2008-09-08 21:00:49 +00:00
50525d7fcc merged from trunk
[SVN r47983]
2008-08-05 05:39:57 +00:00
eda8bd6d1c Merged revisions 44724,44726-44730,44738,44741-44742,44744,44746-44750,44752-44753,44755-44756,44758,44764,44766-44768,44771-44775,44777,44781-44787,44789-44807,44812-44816,44818-44826,44831,44837-44840,44842-44853,44857,44862,44864,44873,44877,44881-44883,44886-44887,44889,44891,44893,44895,44897,44900-44902,44904-44907,44919,44934,44941-44942,44946,44949-44954,44957,44962,44968-44973,44975,44977,44979-44984,44991-44993,44995,44997-45002,45004-45006,45010-45011,45019,45023,45025-45027 via svnmerge from
https://svn.boost.org/svn/boost/trunk

................
  r44724 | daniel_frey | 2008-04-22 12:48:39 -0700 (Tue, 22 Apr 2008) | 1 line
  
  Reduce enable_shared_from_this overhead
................
  r44726 | emildotchevski | 2008-04-22 15:23:27 -0700 (Tue, 22 Apr 2008) | 1 line
  
  seems like <link>static causes errors
................
  r44727 | chris_kohlhoff | 2008-04-22 16:46:15 -0700 (Tue, 22 Apr 2008) | 2 lines
  
  Fix or suppress MSVC level 4 warnings. Fixes #1703.
................
  r44728 | pdimov | 2008-04-22 17:33:58 -0700 (Tue, 22 Apr 2008) | 1 line
  
  Silence an g++ -Wextra warning.
................
  r44729 | noel_belcourt | 2008-04-22 18:35:01 -0700 (Tue, 22 Apr 2008) | 11 lines
  
  Fixed intel-darwin unresolved symbols by changing the 
  wide integer type from unsigned int (which managles as
  a 'j') to an int (which mangles as an 'i').  This
  change makes intel-darwin generated code match the 
  darwin toolset generated code.
  
  Intel reports this won't be fixed in 10.1 because it's
  an ABI breanking chanage so we won't see this patched 
  until the 10.2 compilers.
................
  r44730 | daniel_frey | 2008-04-22 23:12:39 -0700 (Tue, 22 Apr 2008) | 1 line
  
  Reduce enable_shared_from_this overhead (replace _internal_shared_ptr by _internal_shared_count)
................
  r44738 | danieljames | 2008-04-23 00:09:58 -0700 (Wed, 23 Apr 2008) | 85 lines
  
  Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
  Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ................
    r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Add C++-0x support to the test allocators.
  ................
    r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Add a C++-0x node_constructor.
  ................
    r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    C++-0x constructor for node.
  ................
    r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
    
    Merge in my work so far on implementing emplace for compilers with variadic
    template & rvalue references.
    
    Merged revisions 44059-44062 via svnmerge from 
    https://svn.boost.org/svn/boost/branches/unordered/dev
    
    ........
      r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
      
      First stab at implementing emplace - only for compilers with variadic template & rvalue references.
    ........
      r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
      
      Better variable template arguments, need to add proper support to BoostBook.
    ........
  ................
    r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
    
    Merge with trunk, fixes tabs.
  ................
    r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Some extra compile tests.
  ................
    r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Fix an error message.
  ................
    r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
    
    Merge latest changes from trunk.
    
    Merged revisions 44616-44702 via svnmerge from 
    https://svn.boost.org/svn/boost/trunk
    
    ........
      r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
      
      Update an include.
    ........
      r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
      
      Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
    ........
  ................
    r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
    
    Remove 'reserve_extra'.
  ................
    r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
    
    More unnecessary copy tests - showing some weakness in the emplace implementation.
  ................
    r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
    
    More tests.
  ................
    r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
    
    Comment out a test which requires a C++0x std::pair.
  ................
    r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
    
    Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
  ................
................
  r44741 | noel_belcourt | 2008-04-23 09:16:38 -0700 (Wed, 23 Apr 2008) | 4 lines
  
  Patch PGI to fix config problem (clock_gettime is unresolved
  external) and add required macro define for IOV_MAX support.
................
  r44742 | emildotchevski | 2008-04-23 10:31:56 -0700 (Wed, 23 Apr 2008) | 1 line
  
  Fix for http://tinyurl.com/6owy6b.
................
  r44744 | daniel_frey | 2008-04-23 12:32:44 -0700 (Wed, 23 Apr 2008) | 1 line
  
  Remove dynamic_cast in init_internal_shared_once()
................
  r44746 | noel_belcourt | 2008-04-23 18:40:31 -0700 (Wed, 23 Apr 2008) | 4 lines
  
  Fixup patch to intel-darwin.jam so it looks and
  reads a bit better.
................
  r44747 | noel_belcourt | 2008-04-23 21:58:27 -0700 (Wed, 23 Apr 2008) | 3 lines
  
  Force pgi to always link rt lib, ugh.
................
  r44748 | johnmaddock | 2008-04-24 02:40:31 -0700 (Thu, 24 Apr 2008) | 3 lines
  
  Apply VC-7.1 fixes: sometimes ADL fails, and we need a using declaration in order for the correct overload to be found.
  Add missing #include. to t_distribution_inv.hpp.
  Suppress unnecessary instantiations in instantiate_all.cpp.
................
  r44749 | hkaiser | 2008-04-24 06:52:22 -0700 (Thu, 24 Apr 2008) | 1 line
  
  Phoenix: disambiguated ref() (gcc 4.3 complained...)
................
  r44750 | hkaiser | 2008-04-24 06:54:05 -0700 (Thu, 24 Apr 2008) | 1 line
  
  Spirit.Qi: helping gcc 4.3 to understand what's going on.
................
  r44752 | bemandawes | 2008-04-24 13:29:08 -0700 (Thu, 24 Apr 2008) | 1 line
  
  Fix #1858, typo in non-member operators table
................
  r44753 | grafik | 2008-04-24 13:30:03 -0700 (Thu, 24 Apr 2008) | 1 line
  
  Make it possible to filter which libraries are tested from the CLI with "--filter-tests=" options.
................
  r44755 | djowel | 2008-04-24 15:13:32 -0700 (Thu, 24 Apr 2008) | 1 line
  
  added nullary function support
................
  r44756 | djowel | 2008-04-24 15:13:58 -0700 (Thu, 24 Apr 2008) | 1 line
  
  use plain functions instead of bind
................
  r44758 | noel_belcourt | 2008-04-24 16:05:16 -0700 (Thu, 24 Apr 2008) | 4 lines
  
  Added no two phase name lookup for intel-darwin
  compilers.
................
  r44764 | noel_belcourt | 2008-04-25 08:38:26 -0700 (Fri, 25 Apr 2008) | 4 lines
  
  Enable macros BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE and
  BOOST_HAS_NANOSLEEP.
................
  r44766 | niels_dekker | 2008-04-25 09:50:32 -0700 (Fri, 25 Apr 2008) | 1 line
  
  Improved swap for optional<T>, co-written by Thorsten and Fernando: added support for tweaking whether swap should use T's default constructor. Added swap member function. Discussed at Boost developers' mailing list, "[optional] problems with swap()", http://lists.boost.org/Archives/boost/2008/04/135882.php
................
  r44767 | niels_dekker | 2008-04-25 09:52:34 -0700 (Fri, 25 Apr 2008) | 1 line
  
  Added unit tests, testing optional<T> swap improvements of revision [44766] 
................
  r44768 | noel_belcourt | 2008-04-25 10:37:47 -0700 (Fri, 25 Apr 2008) | 3 lines
  
  Get config tests working (missing -lrt).
................
  r44771 | hkaiser | 2008-04-25 19:02:44 -0700 (Fri, 25 Apr 2008) | 1 line
  
  Applied patch provided by Felipe Magno de Almeida [felipe.m.almeida@gmail.com].
................
  r44772 | daniel_frey | 2008-04-25 23:36:59 -0700 (Fri, 25 Apr 2008) | 1 line
  
  No need for the new ctors to be templates
................
  r44773 | anthonyw | 2008-04-26 00:34:46 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Fixed g++ compile error
................
  r44774 | speedsnail | 2008-04-26 02:54:07 -0700 (Sat, 26 Apr 2008) | 3 lines
  
  use-project didn't actually do what the comment promised.
  This triggered an error with thread Jamfile that could be seen when bjam was invoked in rootdir with
  bjam --with-wave.
................
  r44775 | pdimov | 2008-04-26 06:39:52 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Added a few more tests.
................
  r44777 | daniel_frey | 2008-04-26 08:42:13 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Added new reset()-counterparts for the new ctors
................
  r44781 | emildotchevski | 2008-04-26 10:43:58 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Added protected destructor to the base type error_info_base
................
  r44782 | daniel_frey | 2008-04-26 12:59:11 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Refactored and optimized enable_shared_from_this
................
  r44783 | hkaiser | 2008-04-26 13:09:56 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Added wrap_action for zero parameter semantic actions
................
  r44784 | hkaiser | 2008-04-26 13:10:36 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Lex: fixed typos in comments
................
  r44785 | hkaiser | 2008-04-26 13:11:25 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Classic: Added some explaining comments to the namespace handling.
................
  r44786 | hkaiser | 2008-04-26 13:12:12 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: applied patch from #1886, closed now.
................
  r44787 | hkaiser | 2008-04-26 13:24:00 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: Switched to use unordered from main Boost distribution, removed local copy of unordered.
................
  r44789 | hkaiser | 2008-04-26 14:51:59 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Phoenix: Fixed gcc 4.3.0 compilation issue.
................
  r44790 | grafik | 2008-04-26 15:21:50 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Add the test target name to the bjam XML log output to make it easier to match tests to jam targets.
................
  r44791 | grafik | 2008-04-26 16:15:40 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Re-implement PJL in Python to fix various problems with the C++ version. In brief to remove the need of a good C++ compiler to submit results, remove the post-processing of the raw bjam output, and to fix missing results (for example Spirit classic results).
................
  r44792 | hkaiser | 2008-04-26 17:49:41 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: disabled some warnings for VC /W4
................
  r44793 | hkaiser | 2008-04-26 18:00:34 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: suppressed more VC level 4 warnings
................
  r44794 | hkaiser | 2008-04-26 18:04:25 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Fusion: Fixed a VC level 4 warning
................
  r44795 | hkaiser | 2008-04-26 18:08:04 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: suppressed more VC level 4 warnings.
................
  r44796 | hkaiser | 2008-04-26 18:08:43 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: suppressed more VC level 4 warnings.
................
  r44797 | hkaiser | 2008-04-26 18:38:42 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Lex: Attempt to fix Intel V9.1 issue.
................
  r44798 | hkaiser | 2008-04-26 18:44:31 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Lex: fixed some gcc 4.3 warnings.
................
  r44799 | hkaiser | 2008-04-26 18:45:05 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Lex: Fixed gcc 4.3 compilation erros.
................
  r44800 | hkaiser | 2008-04-26 18:46:24 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Lex: fixed some gcc 4.3 warnings.
................
  r44801 | hkaiser | 2008-04-26 18:47:35 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Lex: fixed some gcc 4.3 warnings.
................
  r44802 | hkaiser | 2008-04-26 18:50:50 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Karma: Fixed Jamfile
................
  r44803 | hkaiser | 2008-04-26 18:59:44 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Qi: Fixed a ambiguity reported by gcc 4.3
................
  r44804 | hkaiser | 2008-04-26 19:01:22 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit.Karma: Fixed gcc 4.3 compilation issue.
................
  r44805 | hkaiser | 2008-04-26 19:04:07 -0700 (Sat, 26 Apr 2008) | 1 line
  
  Spirit: Fixed a ambiguity reported by VC8 for embedded systems
................
  r44806 | djowel | 2008-04-26 20:21:12 -0700 (Sat, 26 Apr 2008) | 1 line
  
  tweak: const correctness
................
  r44807 | danieljames | 2008-04-27 00:39:49 -0700 (Sun, 27 Apr 2008) | 78 lines
  
  Merge in documentation fixes.  Apart from the change to optional's documenation
  Jamfile, which I included by mistake.
  
  Fixes #1659, #1661, #1684, #1685, 1687, #1690, #1801
  
  I wrote about this at:
  
  http://lists.boost.org/Archives/boost/2008/04/136405.php
  
  Merged revisions 44585-44806 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/doc
  
  ........
    r44585 | danieljames | 2008-04-19 16:25:27 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix broken link to vacpp in bjam docs. Refs #1512
  ........
    r44586 | danieljames | 2008-04-19 16:27:36 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix broken link to bcpp in bjam docs. Refs #1513
  ........
    r44587 | danieljames | 2008-04-19 16:33:58 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    DateTime documentation - Fix a link to the serialization library. Refs #1659
  ........
    r44588 | danieljames | 2008-04-19 16:35:36 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix some links in interprocess & intrusive. Refs #1661
  ........
    r44589 | danieljames | 2008-04-19 16:37:39 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix some links in the python docs. Refs #1684.
  ........
    r44590 | danieljames | 2008-04-19 16:38:29 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Work around a quickbook bug which is affecting the python docs. Refs #1684.
  ........
    r44591 | danieljames | 2008-04-19 16:39:34 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix a broken link in the numeric conversion docs. Refs #1685
  ........
    r44592 | danieljames | 2008-04-19 16:40:45 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix some links in the optional docs. Refs #1687
  ........
    r44593 | danieljames | 2008-04-19 16:42:09 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix link to the hash documentation from bimap. Refs #1690
  ........
    r44599 | danieljames | 2008-04-19 18:07:33 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix a typo in the format library. Refs #1801
  ........
    r44600 | danieljames | 2008-04-19 19:20:59 +0100 (Sat, 19 Apr 2008) | 1 line
    
    Initialise svnmerge.
  ........
    r44641 | danieljames | 2008-04-20 18:59:47 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Fix the lincense url in shared container iterator documentation.
  ........
    r44642 | danieljames | 2008-04-20 19:00:00 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Fix image link in the mpi documentation.
  ........
    r44643 | danieljames | 2008-04-20 19:00:11 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Fix a typo in the spirit docs.
  ........
    r44644 | danieljames | 2008-04-20 19:00:23 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Escape the slash so that quickbook doesn't think it the start of an italic section, and mess up the link. Refs #1844
  ........
    r44647 | danieljames | 2008-04-20 19:39:47 +0100 (Sun, 20 Apr 2008) | 2 lines
    
    Fix another typo in spirit docs.
  ........
................
  r44812 | djowel | 2008-04-27 01:41:13 -0700 (Sun, 27 Apr 2008) | 1 line
  
  added grammar_class
................
  r44813 | djowel | 2008-04-27 01:41:47 -0700 (Sun, 27 Apr 2008) | 1 line
  
  added grammar_class test
................
  r44814 | djowel | 2008-04-27 01:44:38 -0700 (Sun, 27 Apr 2008) | 1 line
  
  tweak grammar_class test
................
  r44815 | djowel | 2008-04-27 02:11:33 -0700 (Sun, 27 Apr 2008) | 1 line
  
  tweak grammar_class test
................
  r44816 | djowel | 2008-04-27 02:11:49 -0700 (Sun, 27 Apr 2008) | 1 line
  
  tweak grammar_class
................
  r44818 | igaztanaga | 2008-04-27 07:57:11 -0700 (Sun, 27 Apr 2008) | 13 lines
  
  Intrusive:
  
  *  Added `linear<>` and `cache_last<>` options to singly linked lists.
  *  Added `optimize_multikey<>` option to unordered container hooks.
  *  Optimized unordered containers when `store_hash` option is used in the hook.
  *  Implementation changed to be exception agnostic so that it can be used
     in environments without exceptions.
  *  Added `container_from_iterator` function to tree-based containers.
  
  Interprocess:
  
  *  Added anonymous shared memory for UNIX systems.
  *  Fixed file lock compilation errors
................
  r44819 | igaztanaga | 2008-04-27 08:03:06 -0700 (Sun, 27 Apr 2008) | 13 lines
  
  Intrusive:
  
  *  Added `linear<>` and `cache_last<>` options to singly linked lists.
  *  Added `optimize_multikey<>` option to unordered container hooks.
  *  Optimized unordered containers when `store_hash` option is used in the hook.
  *  Implementation changed to be exception agnostic so that it can be used
     in environments without exceptions.
  *  Added `container_from_iterator` function to tree-based containers.
  
  Interprocess:
  
  *  Added anonymous shared memory for UNIX systems.
  *  Fixed file lock compilation errors
................
  r44820 | hkaiser | 2008-04-27 11:09:29 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Spirit.Lex: introduced workaround for Intel compilers <= V9.1
................
  r44821 | hkaiser | 2008-04-27 11:11:17 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Spirit.Qi: Made it clear for gcc 4.3 which ref() to use.
................
  r44822 | hkaiser | 2008-04-27 11:14:49 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Spirit.Lex: Fixed a gcc 4.3 warning 
................
  r44823 | hkaiser | 2008-04-27 11:28:04 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Spirit.Lex: Fixed a gcc 4.3 warning 
................
  r44824 | hkaiser | 2008-04-27 11:37:41 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Spirit.Lex: Fixed a gcc 4.3 warning (again, sigh)
................
  r44825 | niels_dekker | 2008-04-27 14:07:10 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Added forward declaration of optional<T>'s boost::swap overload, as mentioned at http://article.gmane.org/gmane.comp.lib.boost.devel/174350 "Re: [optional] problems with swap()"
................
  r44826 | niels_dekker | 2008-04-27 14:09:50 -0700 (Sun, 27 Apr 2008) | 1 line
  
  Replaced "using std::swap" by "using boost::swap" within optional::swap member function, hoping to fix GCC test failures, as mentioned at http://article.gmane.org/gmane.comp.lib.boost.devel/174350 "Re: [optional] problems with swap()"
................
  r44831 | djowel | 2008-04-27 18:07:52 -0700 (Sun, 27 Apr 2008) | 1 line
  
  tweaks
................
  r44837 | daniel_frey | 2008-04-28 00:17:11 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Improved sp_deleter_wrapper implementation
................
  r44838 | anthonyw | 2008-04-28 02:00:58 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Added detail::try_lock_wrapper for use as scoped_try_lock typedefs, to fix issue #1873
................
  r44839 | anthonyw | 2008-04-28 02:04:40 -0700 (Mon, 28 Apr 2008) | 1 line
  
  reverted accidental change
................
  r44840 | anthonyw | 2008-04-28 02:10:38 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Added entry to breaking changes about default-constructed threads and the current thread: issue #1835
................
  r44842 | johnmaddock | 2008-04-28 04:07:14 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Fixes for issue #1871 that prevents duplicate symbol errors with VC++ compilers, when building with /Zc:wchar_t-.
................
  r44843 | djowel | 2008-04-28 04:15:13 -0700 (Mon, 28 Apr 2008) | 1 line
  
  experimental grammar/grammar_def unification
................
  r44844 | djowel | 2008-04-28 04:16:29 -0700 (Mon, 28 Apr 2008) | 1 line
  
  experimental grammar/grammar_def unification
................
  r44845 | djowel | 2008-04-28 04:17:09 -0700 (Mon, 28 Apr 2008) | 1 line
  
  calc2 generating an AST
................
  r44846 | anthonyw | 2008-04-28 05:26:27 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Updated locks.hpp to work with gcc as well as msvc
................
  r44847 | hkaiser | 2008-04-28 06:33:15 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Spirit.Lex: fixed workaround for Intel compilers <= V9.1
................
  r44848 | chris_kohlhoff | 2008-04-28 06:35:27 -0700 (Mon, 28 Apr 2008) | 2 lines
  
  Update asio version number.
................
  r44849 | chris_kohlhoff | 2008-04-28 06:36:18 -0700 (Mon, 28 Apr 2008) | 2 lines
  
  Add raw socket support.
................
  r44850 | hkaiser | 2008-04-28 06:44:40 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Spirit.Qi: Added a missing 'using namespace'.
................
  r44851 | chris_kohlhoff | 2008-04-28 06:56:07 -0700 (Mon, 28 Apr 2008) | 2 lines
  
  Add an experimental two-lock queue implementation for task_io_service.
................
  r44852 | dgregor | 2008-04-28 07:11:46 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Improve documentation on the size/efficiency of boost::function objects
................
  r44853 | hkaiser | 2008-04-28 07:34:02 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Spirit.Qi: calc2_ast: fixed a wrong include statement
................
  r44857 | eric_niebler | 2008-04-28 09:46:33 -0700 (Mon, 28 Apr 2008) | 1 line
  
  add missing #include
................
  r44862 | niels_dekker | 2008-04-28 14:14:15 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Marked MSVC 7.1 optional_test failure as "expected", because of an ADL-related compiler issue.
................
  r44864 | guwi17 | 2008-04-28 14:50:19 -0700 (Mon, 28 Apr 2008) | 4 lines
  
  - fix and close #1829
  - You are right. The scaled norm wrongly assumed that the first element is not zero.
................
  r44873 | daniel_frey | 2008-04-28 22:32:13 -0700 (Mon, 28 Apr 2008) | 1 line
  
  Fixed comment to reflect the intention and the current code
................
  r44877 | johnmaddock | 2008-04-29 03:05:11 -0700 (Tue, 29 Apr 2008) | 2 lines
  
  Changed long long to boost::long_long_type and unsigned long long to boost::ulong_long_type.
  A couple of other typo corrections, to get the code compiling with g++ -pedantic.
................
  r44881 | hkaiser | 2008-04-29 06:53:21 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Qi: Fixed grammar_test
................
  r44882 | hkaiser | 2008-04-29 07:09:40 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Qi: Fixed grammar_test
................
  r44883 | hkaiser | 2008-04-29 07:47:29 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Qi: Minor edits mainly in comments
................
  r44886 | emildotchevski | 2008-04-29 10:17:45 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Added required header #include <new>
................
  r44887 | dgregor | 2008-04-29 10:57:54 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Add support for MPI_SIGNED_CHAR to Boost.MPI
................
  r44889 | dgregor | 2008-04-29 11:18:01 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Remove names of unused variables. Fixes #1832 and fixes #1865
................
  r44891 | dgregor | 2008-04-29 11:34:28 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Correct erroneous call to is_reachable from is_connected. Fixes #870
................
  r44893 | dgregor | 2008-04-29 11:37:26 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Improve logic to guess the toolset name in top-level configure script. Fixes #1087
................
  r44895 | dgregor | 2008-04-29 11:46:17 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Make configure more closely follow autotools conventions. Fixes #1664
................
  r44897 | marshall | 2008-04-29 13:16:19 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Updated bounds on uniform_real and uniform_smallint to allow min == max
................
  r44900 | jurko | 2008-04-29 15:49:36 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Typo corrections & minor stylistic comment changes.
................
  r44901 | hkaiser | 2008-04-29 17:59:08 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Karma: Fixed rule, added calc2_ast_dump example
................
  r44902 | hkaiser | 2008-04-29 18:33:53 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit: Fixed main classic header
................
  r44904 | hkaiser | 2008-04-29 18:57:39 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Karma: Fixing ref() ambiguity
................
  r44905 | hkaiser | 2008-04-29 18:59:05 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Karma: Fixing ref() ambiguity
................
  r44906 | hkaiser | 2008-04-29 19:00:28 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Qi: Fixing ref() ambiguity
................
  r44907 | hkaiser | 2008-04-29 19:02:27 -0700 (Tue, 29 Apr 2008) | 1 line
  
  Spirit.Qi: Fixing ref() ambiguity
................
  r44919 | danieljames | 2008-04-30 00:57:04 -0700 (Wed, 30 Apr 2008) | 49 lines
  
  Merge in support for equality operators for the unordered containers and
  hopefully better cross-platform support.
  
  Merged revisions 44778-44835,44837-44918 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ........
    r44778 | danieljames | 2008-04-26 17:15:44 +0100 (Sat, 26 Apr 2008) | 2 lines
    
    Remove a trailing comma.
  ........
    r44779 | danieljames | 2008-04-26 17:23:51 +0100 (Sat, 26 Apr 2008) | 1 line
    
    Merge in support for equality operators.
  ........
    r44780 | danieljames | 2008-04-26 17:28:44 +0100 (Sat, 26 Apr 2008) | 1 line
    
    Use my own list container to avoid working around STL container bugs.
  ........
    r44833 | danieljames | 2008-04-28 08:03:43 +0100 (Mon, 28 Apr 2008) | 1 line
    
    Better equality tests.
  ........
    r44834 | danieljames | 2008-04-28 08:04:03 +0100 (Mon, 28 Apr 2008) | 1 line
    
    Remove a superfluous check.
  ........
    r44835 | danieljames | 2008-04-28 08:04:21 +0100 (Mon, 28 Apr 2008) | 1 line
    
    Add equality reference documentation.
  ........
    r44916 | danieljames | 2008-04-30 08:16:52 +0100 (Wed, 30 Apr 2008) | 1 line
    
    New version of list.hpp
  ........
    r44917 | danieljames | 2008-04-30 08:18:31 +0100 (Wed, 30 Apr 2008) | 1 line
    
    Support compilers without ADL in the compile tests.
  ........
    r44918 | danieljames | 2008-04-30 08:25:20 +0100 (Wed, 30 Apr 2008) | 7 lines
    
    Change the typedef of buffered functions as it was confusing MSVC 6.5
    
    get_allocator wasn't compiling when the allocator workaround is used because it
    couldn't cast from the wrapped allocator to an allocator of another type. So
    use value_alloc_ when it's available (it's only unavailable on compilers with
    C++0x support, which don't require the workaround).
  ........
................
  r44934 | hkaiser | 2008-04-30 08:47:07 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Spirit.Karma: Added example calc2_ast_rpn
................
  r44941 | jurko | 2008-04-30 12:24:04 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Comment cleanup - both stylistic & typo corrections.
................
  r44942 | jurko | 2008-04-30 12:26:55 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Comment typo correction.
................
  r44946 | jurko | 2008-04-30 12:45:29 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Added several svn:ignore Subversion properties to make Subversion ignore folders creating during default Boost & Boost Jam builds on Windows.
................
  r44949 | jurko | 2008-04-30 13:00:24 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Removed trailing spaces from tools/build/v2/build/modifiers.jam.
................
  r44950 | hkaiser | 2008-04-30 13:33:23 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Spirit.Karma: Fixed rule tests (pattern.cpp)
................
  r44951 | hkaiser | 2008-04-30 13:41:37 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Spirit.Karma: added #include <boost/config/warning_disable.hpp> to Karma examples
................
  r44952 | hkaiser | 2008-04-30 13:42:11 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Spirit.Lex: added #include <boost/config/warning_disable.hpp> to Lex examples
................
  r44953 | jurko | 2008-04-30 13:58:05 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Corrected a typo in the Boost Build documentation.
................
  r44954 | emildotchevski | 2008-04-30 14:45:00 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Integration of Boost Exception in boost::throw_exception().
................
  r44957 | hkaiser | 2008-04-30 15:54:09 -0700 (Wed, 30 Apr 2008) | 1 line
  
  Spirit.Qi: added #include <boost/config/warning_disable.hpp> to Qi examples
................
  r44962 | djowel | 2008-04-30 19:10:56 -0700 (Wed, 30 Apr 2008) | 1 line
  
  integer overflow fix
................
  r44968 | danieljames | 2008-05-01 02:23:22 -0700 (Thu, 01 May 2008) | 2 lines
  
  Add list.hpp which was missed from the merge.
................
  r44969 | jurko | 2008-05-01 02:39:45 -0700 (Thu, 01 May 2008) | 1 line
  
  Consistently converted tabs to spaces in tools/build/v2/test/BoostBuild.py to avoid confusion reading the Python source.
................
  r44970 | jurko | 2008-05-01 02:55:47 -0700 (Thu, 01 May 2008) | 1 line
  
  Renamed the Tester.wait_for_time_change() function to Tester.wait_for_time_change_since_last_build() to avoid confusion.
................
  r44971 | jurko | 2008-05-01 03:03:15 -0700 (Thu, 01 May 2008) | 1 line
  
  Boost Build documentation typo correction. Removed trailing spaces. Minor stylistic changes.
................
  r44972 | johnmaddock | 2008-05-01 04:51:39 -0700 (Thu, 01 May 2008) | 1 line
  
  Fix broken URL.
................
  r44973 | hkaiser | 2008-05-01 07:17:52 -0700 (Thu, 01 May 2008) | 1 line
  
  Spirit.Karma: Trying to workaround a gcc 4.2.1 bug.
................
  r44975 | jurko | 2008-05-01 08:09:58 -0700 (Thu, 01 May 2008) | 1 line
  
  Boost Build comment typo corrections and minor stylistic changes.
................
  r44977 | hkaiser | 2008-05-01 09:20:38 -0700 (Thu, 01 May 2008) | 1 line
  
  Wave: Changing properties for test.cfg to fix test failures non Windows systems
................
  r44979 | pdimov | 2008-05-01 09:50:39 -0700 (Thu, 01 May 2008) | 1 line
  
  make_shared added; tweaks for old compilers; fixes #1884.
................
  r44980 | jurko | 2008-05-01 10:01:03 -0700 (Thu, 01 May 2008) | 1 line
  
  Minor stylistic comment changes.
................
  r44981 | jurko | 2008-05-01 10:04:22 -0700 (Thu, 01 May 2008) | 1 line
  
  Added explanation comments for match_exact() and match_re() functions in tools/build/v2/test/TestCmd.py. Removed corpse interpreted member from the TescCmd class and the related setter function in tools/build/v2/test/TestCmd.py. Minor stylistic comment changes.
................
  r44982 | jurko | 2008-05-01 10:06:02 -0700 (Thu, 01 May 2008) | 1 line
  
  Updated the main Tester class comment in tools/build/v2/build/v2/test/BoostBuild.py describing all of its available constructor parameters. Minor stylistic changes.
................
  r44983 | jurko | 2008-05-01 10:08:04 -0700 (Thu, 01 May 2008) | 1 line
  
  Updated the Boost Build test system documentation. Now all the command line options are described. Several function descriptions updated.
................
  r44984 | hkaiser | 2008-05-01 10:31:42 -0700 (Thu, 01 May 2008) | 1 line
  
  Spirit.Lex: Removed unused variables
................
  r44991 | jurko | 2008-05-01 12:47:37 -0700 (Thu, 01 May 2008) | 1 line
  
  Fixed a bug with BOOST_BUILD_PATH not getting set correctly in Boost Build unit tests in case it contained spaces.
................
  r44992 | jurko | 2008-05-01 12:55:50 -0700 (Thu, 01 May 2008) | 1 line
  
  Added the default Boost Jam build target folders on cygwin - bin.cygwinx86 & bin.cygwinc86.debug to the svn:ignore list.
................
  r44993 | jurko | 2008-05-01 13:22:12 -0700 (Thu, 01 May 2008) | 1 line
  
  Upgraded the internal Boost Build test system so it can be run from folders whose names contain spaces on Windows. Also added a workaround for a Python bug on Windows where it has some undocumented behavior when starting processes using commands containing quotes.
................
  r44995 | jurko | 2008-05-01 14:19:11 -0700 (Thu, 01 May 2008) | 1 line
  
  Minor stylistic changes.
................
  r44997 | chris_kohlhoff | 2008-05-01 15:00:26 -0700 (Thu, 01 May 2008) | 3 lines
  
  Add a fast path for some speculative read and write operations in the
  epoll_reactor.
................
  r44998 | chris_kohlhoff | 2008-05-01 15:27:21 -0700 (Thu, 01 May 2008) | 3 lines
  
  A memory barrier is needed on some platforms to ensure that all updates
  to the node occur before the tail pointer is updated.
................
  r44999 | jurko | 2008-05-01 17:10:09 -0700 (Thu, 01 May 2008) | 1 line
  
  Minor stylistic changes.
................
  r45000 | jurko | 2008-05-01 17:12:29 -0700 (Thu, 01 May 2008) | 1 line
  
  Added support for tests checking that a build run did not take longer than expected to finish. Minor stylistic changes.
................
  r45001 | jurko | 2008-05-01 17:36:23 -0700 (Thu, 01 May 2008) | 1 line
  
  Added a new regression test making sure that the Boost Jam SORT builtin rule does not start getting quadratic behavior in some special cases as well as testing that the sorting algorithm works correctly. Related to the patch committed in revision 44195. Trimmed trailing spaces in tools/build/v2/test/test_all.py.
................
  r45002 | jurko | 2008-05-01 17:51:05 -0700 (Thu, 01 May 2008) | 1 line
  
  Documentation typo corrected.
................
  r45004 | jurko | 2008-05-01 17:57:29 -0700 (Thu, 01 May 2008) | 1 line
  
  Minor stylistic changes.
................
  r45005 | jurko | 2008-05-01 18:02:01 -0700 (Thu, 01 May 2008) | 1 line
  
  Updated the Boost Build test system's documentation about Tester.run_build_system() parameters. Minor stylistic changes.
................
  r45006 | chris_kohlhoff | 2008-05-02 00:59:01 -0700 (Fri, 02 May 2008) | 3 lines
  
  Fully qualify uses of asio's placeholders to resolve ambiguity with C++0x's
  placeholders namespace.
................
  r45010 | chris_kohlhoff | 2008-05-02 01:38:15 -0700 (Fri, 02 May 2008) | 3 lines
  
  Don't use the names readv and writev for functions defined inside asio as
  these names seem to be macros on Tru64.
................
  r45011 | nesotto | 2008-05-02 01:38:15 -0700 (Fri, 02 May 2008) | 1 line
  
  added missing const in insert()
................
  r45019 | igaztanaga | 2008-05-02 04:07:08 -0700 (Fri, 02 May 2008) | 1 line
  
  Tickets #1883, #1862, #1709
................
  r45023 | jurko | 2008-05-02 08:26:44 -0700 (Fri, 02 May 2008) | 1 line
  
  Minor stylistic Boost Build code changes.
................
  r45025 | grafik | 2008-05-02 08:44:25 -0700 (Fri, 02 May 2008) | 1 line
  
  Use all test sub-projects regardless of filtering so that the tests show up in the bjam XML log.
................
  r45026 | grafik | 2008-05-02 08:52:42 -0700 (Fri, 02 May 2008) | 1 line
  
  Add support for test log processing with process_jam_log.py instead of C++ PJL. (also fixes #1889)
................
  r45027 | pdimov | 2008-05-02 09:49:34 -0700 (Fri, 02 May 2008) | 1 line
  
  Fix throwing enums instead of archive_exceptions.
................


[SVN r45029]
2008-05-02 17:44:19 +00:00
c07234dd7c Merged revisions 44452,44472-44484,44486-44493,44495-44497,44499,44506-44507 via svnmerge from
https://svn.boost.org/svn/boost/trunk

................
  r44452 | johnmaddock | 2008-04-16 04:57:29 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Reinstated real_cast to that STLPort tests can pass.
................
  r44472 | emildotchevski | 2008-04-16 11:24:17 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Added #define NOMINMAX to preserve standard behavior of std::min and std::max. Is including <windows.h> here necessary?
................
  r44473 | emildotchevski | 2008-04-16 11:36:30 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Reverting previous change... #define NOMINMAX isn't a good idea either.
................
  r44474 | nasonov | 2008-04-16 14:13:25 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Use make_unsigned and get rid of gcc warnings when -DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE
................
  r44475 | hkaiser | 2008-04-16 15:50:47 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Spirit V2: started to address regression test failures
................
  r44476 | emildotchevski | 2008-04-16 15:55:19 -0700 (Wed, 16 Apr 2008) | 1 line
  
  minor documentation fixes.
................
  r44477 | hkaiser | 2008-04-16 15:56:15 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Wave: fixed a newly introduced compilation error specific to certain platforms.
................
  r44478 | hkaiser | 2008-04-16 16:17:24 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Spirit V2: Fixed more regression problems.
................
  r44479 | hkaiser | 2008-04-16 16:18:18 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Wave: minor edits...
................
  r44480 | jurko | 2008-04-16 17:20:33 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Added a workaround for a compilation failure when including some Boost Serialization headers before some Boost Pool headers using MSVC 7.1 or 8.0. Source of the problem is a compiler bug fixed in MSVC 9.0 and workaround consists of referencing some Windows API identifiers using their fully qualified names. Added a related regression test for the Boost Pool library. See the test code comments for more detailed information on the bug.
................
  r44481 | jurko | 2008-04-16 17:27:30 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Corrected the documentation related to installing new internal property types.
................
  r44482 | hkaiser | 2008-04-16 18:04:19 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Wave: minor edits...
................
  r44483 | hkaiser | 2008-04-16 18:56:25 -0700 (Wed, 16 Apr 2008) | 1 line
  
  Wave: Fixed slex test
................
  r44484 | hkaiser | 2008-04-16 19:00:20 -0700 (Wed, 16 Apr 2008) | 2 lines
  
  Wave: Fixed slex test
................
  r44486 | danieljames | 2008-04-17 00:34:15 -0700 (Thu, 17 Apr 2008) | 35 lines
  
  Movable unordered containers, full support only for compilers with rvalue references.
  
  Merged revisions 44076-44414 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ........
    r44076 | danieljames | 2008-04-06 20:41:19 +0100 (Sun, 06 Apr 2008) | 1 line
    
    Move semantics for compilers with rvalue references.
  ........
    r44077 | danieljames | 2008-04-06 20:48:59 +0100 (Sun, 06 Apr 2008) | 1 line
    
    Do move assignment 'properly'.
  ........
    r44085 | danieljames | 2008-04-06 22:46:04 +0100 (Sun, 06 Apr 2008) | 1 line
    
    Use normal references for the move members, reset the source buckets_ pointer to stop the buckets getting deleted, and remove a superflous pointer check.
  ........
    r44109 | danieljames | 2008-04-07 23:49:36 +0100 (Mon, 07 Apr 2008) | 1 line
    
    Add missing tests.
  ........
    r44366 | danieljames | 2008-04-13 12:59:46 +0100 (Sun, 13 Apr 2008) | 1 line
    
    Avoid using rvalue references in the implementation files.
  ........
    r44368 | danieljames | 2008-04-13 15:13:33 +0100 (Sun, 13 Apr 2008) | 6 lines
    
    Use a cut down version of the work in progress move library to implement move
    semantics on more compilers. Unfortunately the move constructor with allocator
    isn't really practical at the moment, since in the case where the container
    can't be moved, and the allocators aren't equal it will copy the container
    twice.
  ........
................
  r44487 | danieljames | 2008-04-17 00:39:24 -0700 (Thu, 17 Apr 2008) | 13 lines
  
  Use Boost.Test's minimal test library for unordered & hash. It's closer to
  Boster.Test which makes it easier to switch to take advantage of Boost.Test's
  extra testing facilities.
  
  Merged revisions 44420 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ........
    r44420 | danieljames | 2008-04-14 19:02:03 +0100 (Mon, 14 Apr 2008) | 1 line
    
    Use Boost.Test's minimal test library.
  ........
................
  r44488 | danieljames | 2008-04-17 00:42:47 -0700 (Thu, 17 Apr 2008) | 19 lines
  
  A few tweaks for the unordered tests.
  
  Merged revisions 44461-44462,44466 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ........
    r44461 | danieljames | 2008-04-16 18:34:48 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Try to get some more tests working on Borland.
  ........
    r44462 | danieljames | 2008-04-16 18:34:59 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Write out the number of copies when the unnecessary copy test fails.
  ........
    r44466 | danieljames | 2008-04-16 18:35:44 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Add compile test for get_allocator.
  ........
................
  r44489 | danieljames | 2008-04-17 00:45:20 -0700 (Thu, 17 Apr 2008) | 36 lines
  
  Refactor the hash table implementation a little bit. Some of the changes are to
  make implementing emplace easier.
  
  Merged revisions 44458-44460,44463-44465 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ........
    r44458 | danieljames | 2008-04-16 18:31:35 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Pull out the buffered functions.
  ........
    r44459 | danieljames | 2008-04-16 18:31:45 +0100 (Wed, 16 Apr 2008) | 4 lines
    
    Inline construct_node and create_node into copy_group - these used to be used
    in the implementation of insert but aren't now because of insert's exception
    requirements, so keeping them around was just confusing.
  ........
    r44460 | danieljames | 2008-04-16 18:31:54 +0100 (Wed, 16 Apr 2008) | 4 lines
    
    Change link_node so that it takes a node_constructor containing a constructed
    node instead of a node - this makes the code a little cleaner and also
    simplifies exception safety.
  ........
    r44463 | danieljames | 2008-04-16 18:35:11 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Explicitly name the different insert overloads.
  ........
    r44464 | danieljames | 2008-04-16 18:35:22 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Explicitly name the different erase overloads.
  ........
    r44465 | danieljames | 2008-04-16 18:35:33 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Call the erase methods in hash_table_data directly.
  ........
................
  r44490 | danieljames | 2008-04-17 00:49:45 -0700 (Thu, 17 Apr 2008) | 11 lines
  
  Fix an error on compilers without SFINAE.
  
  Merged revisions 44470 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/unordered/trunk
  
  ........
    r44470 | danieljames | 2008-04-16 18:36:26 +0100 (Wed, 16 Apr 2008) | 2 lines
    
    Missing semi-colon.
  ........
................
  r44491 | djowel | 2008-04-17 02:01:51 -0700 (Thu, 17 Apr 2008) | 1 line
  
  char-sets
................
  r44492 | djowel | 2008-04-17 02:02:03 -0700 (Thu, 17 Apr 2008) | 1 line
  
  char-sets
................
  r44493 | djowel | 2008-04-17 02:44:31 -0700 (Thu, 17 Apr 2008) | 1 line
  
  fixed redundancy in namespace qi::detail::detail
................
  r44495 | jurko | 2008-04-17 04:56:16 -0700 (Thu, 17 Apr 2008) | 1 line
  
  Removed an extra unused 'executed' feature attribute.
................
  r44496 | hkaiser | 2008-04-17 05:22:33 -0700 (Thu, 17 Apr 2008) | 1 line
  
  Spirit V2: Fixed a gcc complaint
................
  r44497 | hkaiser | 2008-04-17 05:29:18 -0700 (Thu, 17 Apr 2008) | 1 line
  
  Spirit V2: Fixed a gcc complaint
................
  r44499 | fmhess | 2008-04-17 06:40:44 -0700 (Thu, 17 Apr 2008) | 3 lines
  
  Added another BOOST_ASSERT to enable_shared_from_this::_internal_accept_owner.
................
  r44506 | johnmaddock | 2008-04-17 08:49:39 -0700 (Thu, 17 Apr 2008) | 1 line
  
  Change <functional> include so that it still works when Boost.TR1 is in the include path.
................
  r44507 | johnmaddock | 2008-04-17 09:21:04 -0700 (Thu, 17 Apr 2008) | 1 line
  
  Try and fix the remaining Intel-Linux failures.
................


[SVN r44523]
2008-04-17 21:50:51 +00:00
fc782cd4fe post-review proto version
[SVN r44061]
2008-04-05 18:00:00 +00:00
0936dbdd03 Add missing include for is_void
[SVN r44030]
2008-04-04 12:26:53 +00:00
adb7b0a214 Change Boost.Function allocator behavior, from Emil Dotchevski
[SVN r43884]
2008-03-27 19:44:37 +00:00
cead36cd5b Disable more Visual C++ warnings in Function headers. Fixes #1416
[SVN r41798]
2007-12-06 18:39:06 +00:00
81e558491b Merge lots of copyrights
[SVN r40811]
2007-11-05 21:22:29 +00:00
2378ba59e7 Fix for Borland compilers.
[SVN r39657]
2007-10-02 17:41:35 +00:00
53b95c386d Finalizes the fix to Bug #1260, making vtable_base an actual POD type (oops)
and playing more nicely with reinterpret_cast (thanks to Brad King for the
fixes).



[SVN r39285]
2007-09-14 21:05:46 +00:00
3312c7ffcd function_template.hpp:
- Pass-by-reference internally, when we can. Fixes #1067



[SVN r39244]
2007-09-13 19:06:53 +00:00
de27ae9697 function/function_base.hpp, function/function_template.hpp:
- Switch from dynamic initialization of the vtable pointer to static
    initialization (Fixes #1260)
  - Handle member pointers properly, only using mem_fn within the invoker
    to deal with all of the messy bits of calling member pointers



[SVN r39240]
2007-09-13 17:38:58 +00:00
a7b9940f15 Handle GCC's -fno-exceptions properly. Fixes #1198
[SVN r39061]
2007-08-29 19:06:11 +00:00
e4f165a4e8 Disable MSVC warning about native code generation. Fixes #1163
[SVN r39060]
2007-08-29 18:59:16 +00:00
22 changed files with 1221 additions and 361 deletions

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
#----------------------------------------------------------------------------
# This file was automatically generated from the original CMakeLists.txt file
# Add a variable to hold the headers for the library
set (lib_headers
function.hpp
function
)
# Add a library target to the build system
boost_library_project(
function
# SRCDIRS
TESTDIRS test
HEADERS ${lib_headers}
DOCDIRS doc
# DESCRIPTION
MODULARIZED
# AUTHORS
# MAINTAINERS
)

2
doc/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
boost_add_documentation(function.xml
faq.xml history.xml misc.xml reference.xml tests.xml tutorial.xml)

View File

@ -1,3 +1,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)
project boost/doc ;
import boostbook : boostbook ;

View File

@ -1,4 +1,11 @@
<?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">
<section id="function.faq" last-revision="$Date$">

View File

@ -1,4 +1,11 @@
<?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">
<section id="function.history" last-revision="$Date$">
@ -6,6 +13,42 @@
<itemizedlist spacing="compact">
<listitem><para><bold>Version 1.37.0</bold>: </para>
<itemizedlist spacing="compact">
<listitem><para>Improved the performance of Boost.Function's
swap() operation for large function objects. Original patch
contributed by Niels Dekker.</para></listitem>
<listitem><para>Added a new header &lt;boost/function/function_typeof.hpp&gt; that provides support for using the Boost.Typeof library on Boost.Function objects.</para></listitem>
<listitem><para>Added a new header &lt;boost/function/function_fwd.hpp&gt; that provides support for using the Boost.Typeof library on Boost.Function objects.</para></listitem>
<listitem><para>The <methodname alt="boost::function::target">target</methodname>()
function now respects the cv-qualifiers of function objects
stored by reference
(using <classname>boost::reference_wrapper</classname>), such
that a reference to a <code>const</code> function object cannot
be accessed as a reference to a non-<code>const</code> function
object.</para></listitem>
</itemizedlist>
</listitem>
<listitem><para><bold>Version 1.36.0</bold>: </para>
<itemizedlist spacing="compact">
<listitem><para>Boost.Function now implements allocator support
in the same way that is is provided in C++0x, based on C++
committee
proposal <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2308.html">N2308</ulink>. This
change removes the <computeroutput>Allocator</computeroutput>
template parameter of <classname>boost::function</classname> in
favor of a constructor that takes an argument. While this is a
backward-incompatible change, it is likely to affect only a few
users. This change to Function was contributed by Emil
Dotchevski, which also authored the corresponding C++ committee
proposal.</para></listitem>
</itemizedlist>
</listitem>
<listitem><para><bold>Version 1.34.0</bold>: </para>
<itemizedlist spacing="compact">
<listitem><para>Boost.Function now implements a small buffer optimization, which can drastically improve the performance when copying or construction Boost.Function objects storing small function objects. For instance, <code>bind(&amp;X:foo, &amp;x, _1, _2)</code> requires no heap allocation when placed into a Boost.Function object. Note that some exception-safety guarantees have changed: assignment provides the basic exception guarantee and <code>swap()</code> may throw.</para></listitem>

View File

@ -1,4 +1,11 @@
<?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">
<section id="function.misc" last-revision="$Date$">
@ -17,7 +24,7 @@
<para> And, of course, function pointers have several advantages over Boost.Function:
<itemizedlist spacing="compact">
<listitem><para> Function pointers are smaller (the size of one pointer instead of three) </para></listitem>
<listitem><para> Function pointers are smaller (the size of one pointer instead of four or more) </para></listitem>
<listitem><para> Function pointers are faster (Boost.Function may require two calls through function pointers) </para></listitem>
<listitem><para> Function pointers are backward-compatible with C libraries.</para></listitem>
<listitem><para> More readable error messages. </para></listitem>
@ -30,12 +37,12 @@
<section>
<title>Function object wrapper size</title>
<para> Function object wrappers will be the size of two function pointers plus one function pointer or data pointer (whichever is larger). On common 32-bit platforms, this amounts to 12 bytes per wrapper. Additionally, the function object target will be allocated on the heap.</para>
<para> Function object wrappers will be the size of a struct containing a member function pointer and two data pointers. The actual size can vary significantly depending on the underlying platform; on 32-bit Mac OS X with GCC, this amounts to 16 bytes, while it is 32 bytes Windows with Visual C++. Additionally, the function object target may be allocated on the heap, if it cannot be placed into the small-object buffer in the <code>boost::function</code> object.</para>
</section>
<section>
<title>Copying efficiency</title>
<para> Copying function object wrappers may require allocating memory for a copy of the function object target. The default allocator may be replaced with a faster custom allocator or one may choose to allow the function object wrappers to only store function object targets by reference (using <computeroutput>ref</computeroutput>) if the cost of this cloning becomes prohibitive.</para>
<para> Copying function object wrappers may require allocating memory for a copy of the function object target. The default allocator may be replaced with a faster custom allocator or one may choose to allow the function object wrappers to only store function object targets by reference (using <computeroutput>ref</computeroutput>) if the cost of this cloning becomes prohibitive. Small function objects can be stored within the <code>boost::function</code> object itself, improving copying efficiency.</para>
</section>
<section>

View File

@ -1,4 +1,11 @@
<?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">
@ -134,9 +141,6 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator">
<default><classname>std::allocator</classname>&lt;void&gt;</default>
</template-type-parameter>
</template>
<inherit access="public"><classname>function_base</classname></inherit>
@ -153,7 +157,6 @@
</description>
<typedef name="result_type"><type>R</type></typedef>
<typedef name="allocator_type"><type>Allocator</type></typedef>
<typedef name="argument_type">
<type>T1</type><purpose>If N == 1</purpose>
</typedef>
@ -209,6 +212,19 @@
<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>
@ -317,11 +333,10 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
</template>
<type>void</type>
<parameter name="f1"><paramtype><classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator&gt;&amp;</paramtype></parameter>
<parameter name="f2"><paramtype><classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator&gt;&amp;</paramtype></parameter>
<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>
@ -334,11 +349,10 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator&gt;&amp;</paramtype></parameter>
<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>
@ -347,12 +361,11 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<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, Allocator&gt;&amp;</paramtype></parameter>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
</signature>
<signature>
<template>
@ -360,11 +373,10 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator&gt;&amp;</paramtype></parameter>
<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>
@ -373,12 +385,11 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<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, Allocator&gt;&amp;</paramtype></parameter>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
</signature>
<signature>
<template>
@ -386,16 +397,14 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator1"/>
<template-type-parameter name="U1"/>
<template-type-parameter name="U2"/>
<template-varargs/>
<template-type-parameter name="UN"/>
<template-type-parameter name="Allocator2"/>
</template>
<type>void</type>
<parameter name="f1"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator1&gt;&amp;</paramtype></parameter>
<parameter name="f2"><paramtype>const <classname>functionN</classname>&lt;U1, U2, ..., UN, Allocator2&gt;&amp;</paramtype></parameter>
<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
@ -435,11 +444,10 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator&gt;&amp;</paramtype></parameter>
<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>
@ -448,12 +456,11 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<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, Allocator&gt;&amp;</paramtype></parameter>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
</signature>
<signature>
<template>
@ -461,11 +468,10 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator&gt;&amp;</paramtype></parameter>
<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>
@ -474,12 +480,11 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator"/>
<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, Allocator&gt;&amp;</paramtype></parameter>
<parameter name="f"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN&gt;&amp;</paramtype></parameter>
</signature>
<signature>
<template>
@ -487,16 +492,14 @@
<template-type-parameter name="T2"/>
<template-varargs/>
<template-type-parameter name="TN"/>
<template-type-parameter name="Allocator1"/>
<template-type-parameter name="U1"/>
<template-type-parameter name="U2"/>
<template-varargs/>
<template-type-parameter name="UN"/>
<template-type-parameter name="Allocator2"/>
</template>
<type>void</type>
<parameter name="f1"><paramtype>const <classname>functionN</classname>&lt;T1, T2, ..., TN, Allocator1&gt;&amp;</paramtype></parameter>
<parameter name="f2"><paramtype>const <classname>functionN</classname>&lt;U1, U2, ..., UN, Allocator2&gt;&amp;</paramtype></parameter>
<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
@ -536,11 +539,8 @@
<template-type-parameter name="Signature">
<purpose>Function type R (T1, T2, ..., TN)</purpose>
</template-type-parameter>
<template-type-parameter name="Allocator">
<default><classname>std::allocator</classname>&lt;void&gt;</default>
</template-type-parameter>
</template>
<inherit access="public"><classname>functionN</classname>&lt;R, T1, T2, ..., TN, Allocator&gt;</inherit>
<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>
@ -562,7 +562,6 @@
</description>
<typedef name="result_type"><type>R</type></typedef>
<typedef name="allocator_type"><type>Allocator</type></typedef>
<typedef name="argument_type">
<type>T1</type><purpose>If N == 1</purpose>
</typedef>
@ -626,6 +625,19 @@
<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>
@ -738,11 +750,10 @@
<function name="swap">
<template>
<template-type-parameter name="Signature"/>
<template-type-parameter name="Allocator"/>
</template>
<type>void</type>
<parameter name="f1"><paramtype><classname>function</classname>&lt;Signature, Allocator&gt;&amp;</paramtype></parameter>
<parameter name="f2"><paramtype><classname>function</classname>&lt;Signature, Allocator&gt;&amp;</paramtype></parameter>
<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>
@ -752,53 +763,47 @@
<signature>
<template>
<template-type-parameter name="Signature"/>
<template-type-parameter name="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature, Allocator&gt;&amp;</paramtype></parameter>
<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="Allocator"/>
<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, Allocator&gt;&amp;</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="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature, Allocator&gt;&amp;</paramtype></parameter>
<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="Allocator"/>
<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, Allocator&gt;&amp;</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="Allocator1"/>
<template-type-parameter name="Signature2"/>
<template-type-parameter name="Allocator2"/>
</template>
<type>void</type>
<parameter name="f1"><paramtype>const <classname>function</classname>&lt;Signature1, Allocator1&gt;&amp;</paramtype></parameter>
<parameter name="f2"><paramtype>const <classname>function</classname>&lt;Signature2, Allocator2&gt;&amp;</paramtype></parameter>
<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
@ -833,53 +838,47 @@
<signature>
<template>
<template-type-parameter name="Signature"/>
<template-type-parameter name="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature, Allocator&gt;&amp;</paramtype></parameter>
<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="Allocator"/>
<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, Allocator&gt;&amp;</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="Allocator"/>
<template-type-parameter name="Functor"/>
</template>
<type>bool</type>
<parameter name="f"><paramtype>const <classname>function</classname>&lt;Signature, Allocator&gt;&amp;</paramtype></parameter>
<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="Allocator"/>
<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, Allocator&gt;&amp;</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="Allocator1"/>
<template-type-parameter name="Signature2"/>
<template-type-parameter name="Allocator2"/>
</template>
<type>void</type>
<parameter name="f1"><paramtype>const <classname>function</classname>&lt;Signature1, Allocator1&gt;&amp;</paramtype></parameter>
<parameter name="f2"><paramtype>const <classname>function</classname>&lt;Signature2, Allocator2&gt;&amp;</paramtype></parameter>
<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

View File

@ -1,4 +1,11 @@
<?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">
<testsuite id="function.testsuite" last-revision="$Date$">

View File

@ -1,4 +1,11 @@
<?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">
<section xmlns:xi="http://www.w3.org/2001/XInclude" id="function.tutorial"

View File

@ -11,7 +11,7 @@
#define BOOST_FUNCTION_PROLOGUE_HPP
# include <cassert>
# include <algorithm>
# include <functional> // unary_function, binary_function
# include <boost/config/no_tr1/functional.hpp> // unary_function, binary_function
# include <boost/throw_exception.hpp>
# include <boost/config.hpp>
# include <boost/function/function_base.hpp>
@ -22,4 +22,5 @@
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/inc.hpp>
# include <boost/type_traits/is_void.hpp>
#endif // BOOST_FUNCTION_PROLOGUE_HPP

View File

@ -1,8 +1,9 @@
// Boost.Function library
// Copyright Douglas Gregor 2001-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// Copyright Douglas Gregor 2001-2006
// Copyright Emil Dotchevski 2007
// 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
@ -17,8 +18,11 @@
#include <typeinfo>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/composite_traits.hpp>
#include <boost/type_traits/ice.hpp>
#include <boost/ref.hpp>
#include <boost/mpl/if.hpp>
#include <boost/detail/workaround.hpp>
@ -29,9 +33,16 @@
# include "boost/mpl/bool.hpp"
#endif
#include <boost/function_equal.hpp>
#include <boost/function/function_fwd.hpp>
#if defined(BOOST_MSVC)
# pragma warning( push )
# pragma warning( disable : 4793 ) // complaint about native code generation
# pragma warning( disable : 4127 ) // "conditional expression is constant"
#endif
// Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info.
#ifdef BOOST_NO_EXCEPTION_STD_NAMESPACE
#ifdef BOOST_NO_STD_TYPEINFO
// Embedded VC++ does not have type_info in namespace std
# define BOOST_FUNCTION_STD_NS
#else
@ -56,22 +67,7 @@
# define BOOST_FUNCTION_TARGET_FIX(x)
#endif // not MSVC
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 && !defined(BOOST_STRICT_CONFIG)
// Work around a compiler bug.
// boost::python::objects::function has to be seen by the compiler before the
// boost::function class template.
namespace boost { namespace python { namespace objects {
class function;
}}}
#endif
#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|| defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) \
|| !(defined(BOOST_STRICT_CONFIG) || !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540)
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x5A0)
# 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), \
@ -85,31 +81,6 @@ namespace boost { namespace python { namespace objects {
Type>::type
#endif
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
namespace boost {
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 && !defined(BOOST_STRICT_CONFIG)
// The library shipping with MIPSpro 7.3.1.3m has a broken allocator<void>
class function_base;
template<typename Signature,
typename Allocator = std::allocator<function_base> >
class function;
#else
template<typename Signature, typename Allocator = std::allocator<void> >
class function;
#endif
template<typename Signature, typename Allocator>
inline void swap(function<Signature, Allocator>& f1,
function<Signature, Allocator>& f2)
{
f1.swap(f2);
}
} // end namespace boost
#endif // have partial specialization
namespace boost {
namespace detail {
namespace function {
@ -124,11 +95,18 @@ namespace boost {
union function_buffer
{
// For pointers to function objects
void* obj_ptr;
mutable void* obj_ptr;
// For pointers to std::type_info objects
// (get_functor_type_tag, check_functor_type_tag).
const void* const_obj_ptr;
struct type_t {
// (get_functor_type_tag, check_functor_type_tag).
const BOOST_FUNCTION_STD_NS::type_info* type;
// Whether the type is const-qualified.
bool const_qualified;
// Whether the type is volatile-qualified.
bool volatile_qualified;
} type;
// For function pointers of all kinds
mutable void (*func_ptr)();
@ -139,6 +117,14 @@ namespace boost {
void* obj_ptr;
} bound_memfunc_ptr;
// For references to function objects. We explicitly keep
// track of the cv-qualifiers on the object referenced.
struct obj_ref_t {
mutable void* obj_ptr;
bool is_const_qualified;
bool is_volatile_qualified;
} obj_ref;
// To relax aliasing constraints
mutable char data;
};
@ -170,6 +156,7 @@ namespace boost {
// The operation type to perform on the given functor/function pointer
enum functor_manager_operation_type {
clone_functor_tag,
move_functor_tag,
destroy_functor_tag,
check_functor_type_tag,
get_functor_type_tag
@ -206,34 +193,45 @@ namespace boost {
struct reference_manager
{
static inline void
get(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op)
manage(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op)
{
switch (op) {
case clone_functor_tag:
out_buffer.obj_ptr = in_buffer.obj_ptr;
out_buffer.obj_ref.obj_ptr = in_buffer.obj_ref.obj_ptr;
return;
case move_functor_tag:
out_buffer.obj_ref.obj_ptr = in_buffer.obj_ref.obj_ptr;
in_buffer.obj_ref.obj_ptr = 0;
return;
case destroy_functor_tag:
out_buffer.obj_ptr = 0;
out_buffer.obj_ref.obj_ptr = 0;
return;
case check_functor_type_tag:
{
// DPG TBD: Since we're only storing a pointer, it's
// possible that the user could ask for a base class or
// derived class. Is that okay?
const BOOST_FUNCTION_STD_NS::type_info& check_type =
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(F)))
out_buffer.obj_ptr = in_buffer.obj_ptr;
const BOOST_FUNCTION_STD_NS::type_info& check_type
= *out_buffer.type.type;
// Check whether we have the same type. We can add
// cv-qualifiers, but we can't take them away.
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(F))
&& (!in_buffer.obj_ref.is_const_qualified
|| out_buffer.type.const_qualified)
&& (!in_buffer.obj_ref.is_volatile_qualified
|| out_buffer.type.volatile_qualified))
out_buffer.obj_ptr = in_buffer.obj_ref.obj_ptr;
else
out_buffer.obj_ptr = 0;
}
return;
case get_functor_type_tag:
out_buffer.const_obj_ptr = &typeid(F);
out_buffer.type.type = &typeid(F);
out_buffer.type.const_qualified = in_buffer.obj_ref.is_const_qualified;
out_buffer.type.volatile_qualified = in_buffer.obj_ref.is_volatile_qualified;
return;
}
}
@ -253,33 +251,94 @@ namespace boost {
% alignment_of<F>::value == 0))));
};
template <typename F,typename A>
struct functor_wrapper: public F, public A
{
functor_wrapper( F f, A a ):
F(f),
A(a)
{
}
};
/**
* The functor_manager class contains a static function "manage" which
* can clone or destroy the given function/function object pointer.
*/
template<typename Functor, typename Allocator>
template<typename Functor>
struct functor_manager_common
{
typedef Functor functor_type;
// Function pointers
static inline void
manage_ptr(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op)
{
if (op == clone_functor_tag)
out_buffer.func_ptr = in_buffer.func_ptr;
else if (op == move_functor_tag) {
out_buffer.func_ptr = in_buffer.func_ptr;
in_buffer.func_ptr = 0;
} else if (op == destroy_functor_tag)
out_buffer.func_ptr = 0;
else if (op == check_functor_type_tag) {
const BOOST_FUNCTION_STD_NS::type_info& check_type
= *out_buffer.type.type;
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
out_buffer.obj_ptr = &in_buffer.func_ptr;
else
out_buffer.obj_ptr = 0;
} else /* op == get_functor_type_tag */ {
out_buffer.type.type = &typeid(Functor);
out_buffer.type.const_qualified = false;
out_buffer.type.volatile_qualified = false;
}
}
// Function objects that fit in the small-object buffer.
static inline void
manage_small(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op)
{
if (op == clone_functor_tag || op == move_functor_tag) {
const functor_type* in_functor =
reinterpret_cast<const functor_type*>(&in_buffer.data);
new ((void*)&out_buffer.data) functor_type(*in_functor);
if (op == move_functor_tag) {
reinterpret_cast<functor_type*>(&in_buffer.data)->~Functor();
}
} else if (op == destroy_functor_tag) {
// Some compilers (Borland, vc6, ...) are unhappy with ~functor_type.
reinterpret_cast<functor_type*>(&out_buffer.data)->~Functor();
} else if (op == check_functor_type_tag) {
const BOOST_FUNCTION_STD_NS::type_info& check_type
= *out_buffer.type.type;
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
out_buffer.obj_ptr = &in_buffer.data;
else
out_buffer.obj_ptr = 0;
} else /* op == get_functor_type_tag */ {
out_buffer.type.type = &typeid(Functor);
out_buffer.type.const_qualified = false;
out_buffer.type.volatile_qualified = false;
}
}
};
template<typename Functor>
struct functor_manager
{
private:
typedef Functor functor_type;
// For function pointers, the manager is trivial
// Function pointers
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, function_ptr_tag)
{
if (op == clone_functor_tag)
out_buffer.func_ptr = in_buffer.func_ptr;
else if (op == destroy_functor_tag)
out_buffer.func_ptr = 0;
else /* op == check_functor_type_tag */ {
const BOOST_FUNCTION_STD_NS::type_info& check_type =
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
out_buffer.obj_ptr = &in_buffer.func_ptr;
else
out_buffer.obj_ptr = 0;
}
functor_manager_common<Functor>::manage_ptr(in_buffer,out_buffer,op);
}
// Function objects that fit in the small-object buffer.
@ -287,21 +346,7 @@ namespace boost {
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::true_)
{
if (op == clone_functor_tag) {
const functor_type* in_functor =
reinterpret_cast<const functor_type*>(&in_buffer.data);
new ((void*)&out_buffer.data) functor_type(*in_functor);
} else if (op == destroy_functor_tag) {
// Some compilers (Borland, vc6, ...) are unhappy with ~functor_type.
reinterpret_cast<functor_type*>(&out_buffer.data)->~Functor();
} else /* op == check_functor_type_tag */ {
const BOOST_FUNCTION_STD_NS::type_info& check_type =
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
out_buffer.obj_ptr = &in_buffer.data;
else
out_buffer.obj_ptr = 0;
}
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
}
// Function objects that require heap allocation
@ -309,59 +354,145 @@ namespace boost {
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::false_)
{
#ifndef BOOST_NO_STD_ALLOCATOR
typedef typename Allocator::template rebind<functor_type>::other
allocator_type;
typedef typename allocator_type::pointer pointer_type;
#else
typedef functor_type* pointer_type;
#endif // BOOST_NO_STD_ALLOCATOR
# ifndef BOOST_NO_STD_ALLOCATOR
allocator_type allocator;
# endif // BOOST_NO_STD_ALLOCATOR
if (op == clone_functor_tag) {
// Clone the functor
// GCC 2.95.3 gets the CV qualifiers wrong here, so we
// can't do the static_cast that we should do.
const functor_type* f =
(const functor_type*)(in_buffer.obj_ptr);
// Clone the functor
# ifndef BOOST_NO_STD_ALLOCATOR
pointer_type copy = allocator.allocate(1);
allocator.construct(copy, *f);
// Get back to the original pointer type
functor_type* new_f = static_cast<functor_type*>(copy);
# else
functor_type* new_f = new functor_type(*f);
# endif // BOOST_NO_STD_ALLOCATOR
out_buffer.obj_ptr = new_f;
} else if (op == move_functor_tag) {
out_buffer.obj_ptr = in_buffer.obj_ptr;
in_buffer.obj_ptr = 0;
} else if (op == destroy_functor_tag) {
/* Cast from the void pointer to the functor pointer type */
functor_type* f =
static_cast<functor_type*>(out_buffer.obj_ptr);
# ifndef BOOST_NO_STD_ALLOCATOR
/* Cast from the functor pointer type to the allocator's pointer
type */
pointer_type victim = static_cast<pointer_type>(f);
// Destroy and deallocate the functor
allocator.destroy(victim);
allocator.deallocate(victim, 1);
# else
delete f;
# endif // BOOST_NO_STD_ALLOCATOR
out_buffer.obj_ptr = 0;
} else /* op == check_functor_type_tag */ {
const BOOST_FUNCTION_STD_NS::type_info& check_type =
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
} else if (op == check_functor_type_tag) {
const BOOST_FUNCTION_STD_NS::type_info& check_type
= *out_buffer.type.type;
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
out_buffer.obj_ptr = in_buffer.obj_ptr;
else
out_buffer.obj_ptr = 0;
} else /* op == get_functor_type_tag */ {
out_buffer.type.type = &typeid(Functor);
out_buffer.type.const_qualified = false;
out_buffer.type.volatile_qualified = false;
}
}
// For function objects, we determine whether the function
// object can use the small-object optimization buffer or
// whether we need to allocate it on the heap.
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, function_obj_tag)
{
manager(in_buffer, out_buffer, op,
mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
}
// For member pointers, we use the small-object optimization buffer.
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, member_ptr_tag)
{
manager(in_buffer, out_buffer, op, mpl::true_());
}
public:
/* Dispatch to an appropriate manager based on whether we have a
function pointer or a function object pointer. */
static inline void
manage(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op)
{
typedef typename get_function_tag<functor_type>::type tag_type;
switch (op) {
case get_functor_type_tag:
out_buffer.type.type = &typeid(functor_type);
out_buffer.type.const_qualified = false;
out_buffer.type.volatile_qualified = false;
return;
default:
manager(in_buffer, out_buffer, op, tag_type());
return;
}
}
};
template<typename Functor, typename Allocator>
struct functor_manager_a
{
private:
typedef Functor functor_type;
// Function pointers
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, function_ptr_tag)
{
functor_manager_common<Functor>::manage_ptr(in_buffer,out_buffer,op);
}
// Function objects that fit in the small-object buffer.
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::true_)
{
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
}
// Function objects that require heap allocation
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::false_)
{
typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
typedef typename Allocator::template rebind<functor_wrapper_type>::other
wrapper_allocator_type;
typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
if (op == clone_functor_tag) {
// Clone the functor
// GCC 2.95.3 gets the CV qualifiers wrong here, so we
// can't do the static_cast that we should do.
const functor_wrapper_type* f =
(const functor_wrapper_type*)(in_buffer.obj_ptr);
wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*f));
wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
wrapper_allocator.construct(copy, *f);
// Get back to the original pointer type
functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
out_buffer.obj_ptr = new_f;
} else if (op == move_functor_tag) {
out_buffer.obj_ptr = in_buffer.obj_ptr;
in_buffer.obj_ptr = 0;
} else if (op == destroy_functor_tag) {
/* Cast from the void pointer to the functor_wrapper_type */
functor_wrapper_type* victim =
static_cast<functor_wrapper_type*>(in_buffer.obj_ptr);
wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*victim));
wrapper_allocator.destroy(victim);
wrapper_allocator.deallocate(victim,1);
out_buffer.obj_ptr = 0;
} else if (op == check_functor_type_tag) {
const BOOST_FUNCTION_STD_NS::type_info& check_type
= *out_buffer.type.type;
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
out_buffer.obj_ptr = in_buffer.obj_ptr;
else
out_buffer.obj_ptr = 0;
} else /* op == get_functor_type_tag */ {
out_buffer.type.type = &typeid(Functor);
out_buffer.type.const_qualified = false;
out_buffer.type.volatile_qualified = false;
}
}
@ -386,7 +517,9 @@ namespace boost {
typedef typename get_function_tag<functor_type>::type tag_type;
switch (op) {
case get_functor_type_tag:
out_buffer.const_obj_ptr = &typeid(functor_type);
out_buffer.type.type = &typeid(functor_type);
out_buffer.type.const_qualified = false;
out_buffer.type.volatile_qualified = false;
return;
default:
@ -464,7 +597,6 @@ namespace boost {
*/
struct vtable_base
{
vtable_base() : manager(0) { }
void (*manager)(const function_buffer& in_buffer,
function_buffer& out_buffer,
functor_manager_operation_type op);
@ -494,7 +626,7 @@ public:
detail::function::function_buffer type;
vtable->manager(functor, type, detail::function::get_functor_type_tag);
return *static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(type.const_obj_ptr);
return *type.type.type;
}
template<typename Functor>
@ -503,7 +635,9 @@ public:
if (!vtable) return 0;
detail::function::function_buffer type_result;
type_result.const_obj_ptr = &typeid(Functor);
type_result.type.type = &typeid(Functor);
type_result.type.const_qualified = is_const<Functor>::value;
type_result.type.volatile_qualified = is_volatile<Functor>::value;
vtable->manager(functor, type_result,
detail::function::check_functor_type_tag);
return static_cast<Functor*>(type_result.obj_ptr);
@ -519,7 +653,9 @@ public:
if (!vtable) return 0;
detail::function::function_buffer type_result;
type_result.const_obj_ptr = &typeid(Functor);
type_result.type.type = &typeid(Functor);
type_result.type.const_qualified = true;
type_result.type.volatile_qualified = is_volatile<Functor>::value;
vtable->manager(functor, type_result,
detail::function::check_functor_type_tag);
// GCC 2.95.3 gets the CV qualifiers wrong here, so we

View File

@ -0,0 +1,70 @@
// Boost.Function library
// Copyright (C) Douglas Gregor 2008
//
// 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_FWD_HPP
#define BOOST_FUNCTION_FWD_HPP
#include <boost/config.hpp>
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 && !defined(BOOST_STRICT_CONFIG)
// Work around a compiler bug.
// boost::python::objects::function has to be seen by the compiler before the
// boost::function class template.
namespace boost { namespace python { namespace objects {
class function;
}}}
#endif
#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|| defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) \
|| !(BOOST_STRICT_CONFIG || !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540)
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
#endif
namespace boost {
class bad_function_call;
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
// Preferred syntax
template<typename Signature> class function;
template<typename Signature>
inline void swap(function<Signature>& f1, function<Signature>& f2)
{
f1.swap(f2);
}
#endif // have partial specialization
// Portable syntax
template<typename R> class function0;
template<typename R, typename T1> class function1;
template<typename R, typename T1, typename T2> class function2;
template<typename R, typename T1, typename T2, typename T3> class function3;
template<typename R, typename T1, typename T2, typename T3, typename T4>
class function4;
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5>
class function5;
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
class function6;
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
class function7;
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
class function8;
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8, typename T9>
class function9;
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8, typename T9,
typename T10>
class function10;
}
#endif

View File

@ -1,8 +1,9 @@
// Boost.Function library
// Copyright Douglas Gregor 2001-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// Copyright Douglas Gregor 2001-2006
// Copyright Emil Dotchevski 2007
// 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
@ -11,6 +12,11 @@
// protection.
#include <boost/function/detail/prologue.hpp>
#if defined(BOOST_MSVC)
# pragma warning( push )
# pragma warning( disable : 4127 ) // "conditional expression is constant"
#endif
#define BOOST_FUNCTION_TEMPLATE_PARMS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, typename T)
#define BOOST_FUNCTION_TEMPLATE_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, T)
@ -26,13 +32,6 @@
#define BOOST_FUNCTION_ARG_TYPES BOOST_PP_REPEAT(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG_TYPE,BOOST_PP_EMPTY)
// Type of the default allocator
#ifndef BOOST_NO_STD_ALLOCATOR
# define BOOST_FUNCTION_DEFAULT_ALLOCATOR std::allocator<function_base>
#else
# define BOOST_FUNCTION_DEFAULT_ALLOCATOR int
#endif // BOOST_NO_STD_ALLOCATOR
// Comma if nonzero number of arguments
#if BOOST_FUNCTION_NUM_ARGS == 0
# define BOOST_FUNCTION_COMMA
@ -54,12 +53,20 @@
BOOST_JOIN(function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER \
BOOST_JOIN(void_function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_MEMBER_INVOKER \
BOOST_JOIN(function_mem_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_VOID_MEMBER_INVOKER \
BOOST_JOIN(function_void_mem_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_GET_FUNCTION_INVOKER \
BOOST_JOIN(get_function_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER \
BOOST_JOIN(get_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER \
BOOST_JOIN(get_function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_GET_MEMBER_INVOKER \
BOOST_JOIN(get_member_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_GET_INVOKER \
BOOST_JOIN(get_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_VTABLE BOOST_JOIN(basic_vtable,BOOST_FUNCTION_NUM_ARGS)
#ifndef BOOST_NO_VOID_RETURNS
@ -181,6 +188,44 @@ namespace boost {
}
};
#if BOOST_FUNCTION_NUM_ARGS > 0
/* Handle invocation of member pointers. */
template<
typename MemberPtr,
typename R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_PARMS
>
struct BOOST_FUNCTION_MEMBER_INVOKER
{
static R invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
BOOST_FUNCTION_PARMS)
{
MemberPtr* f =
reinterpret_cast<MemberPtr*>(&function_obj_ptr.data);
return boost::mem_fn(*f)(BOOST_FUNCTION_ARGS);
}
};
template<
typename MemberPtr,
typename R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_PARMS
>
struct BOOST_FUNCTION_VOID_MEMBER_INVOKER
{
static BOOST_FUNCTION_VOID_RETURN_TYPE
invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
BOOST_FUNCTION_PARMS)
{
MemberPtr* f =
reinterpret_cast<MemberPtr*>(&function_obj_ptr.data);
BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));
}
};
#endif
template<
typename FunctionPtr,
typename R BOOST_FUNCTION_COMMA
@ -244,12 +289,190 @@ namespace boost {
>::type type;
};
#if BOOST_FUNCTION_NUM_ARGS > 0
/* Retrieve the appropriate invoker for a member pointer. */
template<
typename MemberPtr,
typename R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_PARMS
>
struct BOOST_FUNCTION_GET_MEMBER_INVOKER
{
typedef typename mpl::if_c<(is_void<R>::value),
BOOST_FUNCTION_VOID_MEMBER_INVOKER<
MemberPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>,
BOOST_FUNCTION_MEMBER_INVOKER<
MemberPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>
>::type type;
};
#endif
/* Given the tag returned by get_function_tag, retrieve the
actual invoker that will be used for the given function
object.
Each specialization contains an "apply" nested class template
that accepts the function object, return type, function
argument types, and allocator. The resulting "apply" class
contains two typedefs, "invoker_type" and "manager_type",
which correspond to the invoker and manager types. */
template<typename Tag>
struct BOOST_FUNCTION_GET_INVOKER { };
/* Retrieve the invoker for a function pointer. */
template<>
struct BOOST_FUNCTION_GET_INVOKER<function_ptr_tag>
{
template<typename FunctionPtr,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
FunctionPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef functor_manager<FunctionPtr> manager_type;
};
template<typename FunctionPtr,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
FunctionPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef functor_manager<FunctionPtr> manager_type;
};
};
#if BOOST_FUNCTION_NUM_ARGS > 0
/* Retrieve the invoker for a member pointer. */
template<>
struct BOOST_FUNCTION_GET_INVOKER<member_ptr_tag>
{
template<typename MemberPtr,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply
{
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
MemberPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef functor_manager<MemberPtr> manager_type;
};
template<typename MemberPtr,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
MemberPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef functor_manager<MemberPtr> manager_type;
};
};
#endif
/* Retrieve the invoker for a function object. */
template<>
struct BOOST_FUNCTION_GET_INVOKER<function_obj_tag>
{
template<typename FunctionObj,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
FunctionObj,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef functor_manager<FunctionObj> manager_type;
};
template<typename FunctionObj,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
FunctionObj,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef functor_manager_a<FunctionObj, Allocator> manager_type;
};
};
/* Retrieve the invoker for a reference to a function object. */
template<>
struct BOOST_FUNCTION_GET_INVOKER<function_obj_ref_tag>
{
template<typename RefWrapper,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
typename RefWrapper::type,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef reference_manager<typename RefWrapper::type> manager_type;
};
template<typename RefWrapper,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
typename RefWrapper::type,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
invoker_type;
typedef reference_manager<typename RefWrapper::type> manager_type;
};
};
/**
* vtable for a specific boost::function instance.
* vtable for a specific boost::function instance. This
* structure must be an aggregate so that we can use static
* initialization in boost::function's assign_to and assign_to_a
* members. It therefore cannot have any constructors,
* destructors, base classes, etc.
*/
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
struct BOOST_FUNCTION_VTABLE : vtable_base
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct BOOST_FUNCTION_VTABLE
{
#ifndef BOOST_NO_VOID_RETURNS
typedef R result_type;
@ -261,48 +484,27 @@ namespace boost {
BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS);
template<typename F>
BOOST_FUNCTION_VTABLE(F f) : vtable_base(), invoker(0)
{
init(f);
}
template<typename F>
bool assign_to(F f, function_buffer& functor)
{
typedef typename get_function_tag<F>::type tag;
return assign_to(f, functor, tag());
}
template<typename F,typename Allocator>
bool assign_to_a(F f, function_buffer& functor, Allocator a)
{
typedef typename get_function_tag<F>::type tag;
return assign_to_a(f, functor, a, tag());
}
void clear(function_buffer& functor)
{
if (manager)
manager(functor, functor, destroy_functor_tag);
if (base.manager)
base.manager(functor, functor, destroy_functor_tag);
}
private:
template<typename F>
void init(F f)
{
typedef typename get_function_tag<F>::type tag;
init(f, tag());
}
// Function pointers
template<typename FunctionPtr>
void init(FunctionPtr /*f*/, function_ptr_tag)
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
FunctionPtr,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
actual_invoker_type;
invoker = &actual_invoker_type::invoke;
manager = &functor_manager<FunctionPtr, Allocator>::manage;
}
template<typename FunctionPtr>
bool
assign_to(FunctionPtr f, function_buffer& functor, function_ptr_tag)
@ -317,18 +519,15 @@ namespace boost {
return false;
}
}
template<typename FunctionPtr,typename Allocator>
bool
assign_to_a(FunctionPtr f, function_buffer& functor, Allocator, function_ptr_tag)
{
return assign_to(f,functor,function_ptr_tag());
}
// Member pointers
#if BOOST_FUNCTION_NUM_ARGS > 0
template<typename MemberPtr>
void init(MemberPtr f, member_ptr_tag)
{
// DPG TBD: Add explicit support for member function
// objects, so we invoke through mem_fn() but we retain the
// right target_type() values.
this->init(mem_fn(f));
}
template<typename MemberPtr>
bool assign_to(MemberPtr f, function_buffer& functor, member_ptr_tag)
{
@ -342,23 +541,22 @@ namespace boost {
return false;
}
}
template<typename MemberPtr,typename Allocator>
bool assign_to_a(MemberPtr f, function_buffer& functor, Allocator a, member_ptr_tag)
{
// DPG TBD: Add explicit support for member function
// objects, so we invoke through mem_fn() but we retain the
// right target_type() values.
if (f) {
this->assign_to_a(mem_fn(f), functor, a);
return true;
} else {
return false;
}
}
#endif // BOOST_FUNCTION_NUM_ARGS > 0
// Function objects
template<typename FunctionObj>
void init(FunctionObj /*f*/, function_obj_tag)
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
FunctionObj,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
actual_invoker_type;
invoker = &actual_invoker_type::invoke;
manager = &functor_manager<FunctionObj, Allocator>::manage;
}
// Assign to a function object using the small object optimization
template<typename FunctionObj>
void
@ -366,26 +564,33 @@ namespace boost {
{
new ((void*)&functor.data) FunctionObj(f);
}
template<typename FunctionObj,typename Allocator>
void
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, mpl::true_)
{
assign_functor(f,functor,mpl::true_());
}
// Assign to a function object allocated on the heap.
template<typename FunctionObj>
void
assign_functor(FunctionObj f, function_buffer& functor, mpl::false_)
{
#ifndef BOOST_NO_STD_ALLOCATOR
typedef typename Allocator::template rebind<FunctionObj>::other
allocator_type;
typedef typename allocator_type::pointer pointer_type;
allocator_type allocator;
pointer_type copy = allocator.allocate(1);
allocator.construct(copy, f);
// Get back to the original pointer type
functor.obj_ptr = static_cast<FunctionObj*>(copy);
# else
functor.obj_ptr = new FunctionObj(f);
# endif // BOOST_NO_STD_ALLOCATOR
}
template<typename FunctionObj,typename Allocator>
void
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, mpl::false_)
{
typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
typedef typename Allocator::template rebind<functor_wrapper_type>::other
wrapper_allocator_type;
typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
wrapper_allocator_type wrapper_allocator(a);
wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
wrapper_allocator.construct(copy, functor_wrapper_type(f,a));
functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
functor.obj_ptr = new_f;
}
template<typename FunctionObj>
@ -400,41 +605,44 @@ namespace boost {
return false;
}
}
// Reference to a function object
template<typename FunctionObj>
void
init(const reference_wrapper<FunctionObj>& /*f*/, function_obj_ref_tag)
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
FunctionObj,
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS
>::type
actual_invoker_type;
invoker = &actual_invoker_type::invoke;
manager = &reference_manager<FunctionObj>::get;
}
template<typename FunctionObj>
template<typename FunctionObj,typename Allocator>
bool
assign_to(const reference_wrapper<FunctionObj>& f,
function_buffer& functor, function_obj_ref_tag)
assign_to_a(FunctionObj f, function_buffer& functor, Allocator a, function_obj_tag)
{
if (!boost::detail::function::has_empty_target(f.get_pointer())) {
// DPG TBD: We might need to detect constness of
// FunctionObj to assign into obj_ptr or const_obj_ptr to
// be truly legit, but no platform in existence makes
// const void* different from void*.
functor.const_obj_ptr = f.get_pointer();
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
assign_functor_a(f, functor, a,
mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
return true;
} else {
return false;
}
}
// Reference to a function object
template<typename FunctionObj>
bool
assign_to(const reference_wrapper<FunctionObj>& f,
function_buffer& functor, function_obj_ref_tag)
{
if (!boost::detail::function::has_empty_target(f.get_pointer())) {
functor.obj_ref.obj_ptr = (void *)f.get_pointer();
functor.obj_ref.is_const_qualified = is_const<FunctionObj>::value;
functor.obj_ref.is_volatile_qualified = is_volatile<FunctionObj>::value;
return true;
} else {
return false;
}
}
template<typename FunctionObj,typename Allocator>
bool
assign_to_a(const reference_wrapper<FunctionObj>& f,
function_buffer& functor, Allocator, function_obj_ref_tag)
{
return assign_to(f,functor,function_obj_ref_tag());
}
public:
vtable_base base;
invoker_type invoker;
};
} // end namespace function
@ -442,8 +650,7 @@ namespace boost {
template<
typename R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator = BOOST_FUNCTION_DEFAULT_ALLOCATOR
BOOST_FUNCTION_TEMPLATE_PARMS
>
class BOOST_FUNCTION_FUNCTION : public function_base
@ -468,7 +675,7 @@ namespace boost {
private:
typedef boost::detail::function::BOOST_FUNCTION_VTABLE<
R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS, Allocator>
R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>
vtable_type;
struct clear_type {};
@ -493,7 +700,6 @@ namespace boost {
BOOST_STATIC_CONSTANT(int, arity = BOOST_FUNCTION_NUM_ARGS);
BOOST_FUNCTION_ARG_TYPES
typedef Allocator allocator_type;
typedef BOOST_FUNCTION_FUNCTION self_type;
BOOST_FUNCTION_FUNCTION() : function_base() { }
@ -513,6 +719,19 @@ namespace boost {
{
this->assign_to(f);
}
template<typename Functor,typename Allocator>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a
#ifndef BOOST_NO_SFINAE
,typename enable_if_c<
(boost::type_traits::ice_not<
(is_integral<Functor>::value)>::value),
int>::type = 0
#endif // BOOST_NO_SFINAE
) :
function_base()
{
this->assign_to_a(f,a);
}
#ifndef BOOST_NO_SFINAE
BOOST_FUNCTION_FUNCTION(clear_type*) : function_base() { }
@ -570,6 +789,17 @@ namespace boost {
}
return *this;
}
template<typename Functor,typename Allocator>
void assign(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a)
{
this->clear();
try {
this->assign_to_a(f,a);
} catch (...) {
vtable = 0;
throw;
}
}
#ifndef BOOST_NO_SFINAE
BOOST_FUNCTION_FUNCTION& operator=(clear_type*)
@ -607,16 +837,17 @@ namespace boost {
if (&other == this)
return;
BOOST_FUNCTION_FUNCTION tmp = *this;
*this = other;
other = tmp;
BOOST_FUNCTION_FUNCTION tmp;
tmp.move_assign(*this);
this->move_assign(other);
other.move_assign(tmp);
}
// Clear out a target, if there is one
void clear()
{
if (vtable) {
static_cast<vtable_type*>(vtable)->clear(this->functor);
reinterpret_cast<vtable_type*>(vtable)->clear(this->functor);
vtable = 0;
}
}
@ -653,68 +884,127 @@ namespace boost {
template<typename Functor>
void assign_to(Functor f)
{
static vtable_type stored_vtable(f);
if (stored_vtable.assign_to(f, functor)) vtable = &stored_vtable;
using detail::function::vtable_base;
typedef typename detail::function::get_function_tag<Functor>::type tag;
typedef detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
typedef typename get_invoker::
template apply<Functor, R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS>
handler_type;
typedef typename handler_type::invoker_type invoker_type;
typedef typename handler_type::manager_type manager_type;
// Note: it is extremely important that this initialization use
// static initialization. Otherwise, we will have a race
// condition here in multi-threaded code. See
// http://thread.gmane.org/gmane.comp.lib.boost.devel/164902/.
static vtable_type stored_vtable =
{ { &manager_type::manage }, &invoker_type::invoke };
if (stored_vtable.assign_to(f, functor)) vtable = &stored_vtable.base;
else vtable = 0;
}
template<typename Functor,typename Allocator>
void assign_to_a(Functor f,Allocator a)
{
using detail::function::vtable_base;
typedef typename detail::function::get_function_tag<Functor>::type tag;
typedef detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
typedef typename get_invoker::
template apply_a<Functor, R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS,
Allocator>
handler_type;
typedef typename handler_type::invoker_type invoker_type;
typedef typename handler_type::manager_type manager_type;
// Note: it is extremely important that this initialization use
// static initialization. Otherwise, we will have a race
// condition here in multi-threaded code. See
// http://thread.gmane.org/gmane.comp.lib.boost.devel/164902/.
static vtable_type stored_vtable =
{ { &manager_type::manage }, &invoker_type::invoke };
if (stored_vtable.assign_to_a(f, functor, a)) vtable = &stored_vtable.base;
else vtable = 0;
}
// Moves the value from the specified argument to *this. If the argument
// has its function object allocated on the heap, move_assign will pass
// its buffer to *this, and set the argument's buffer pointer to NULL.
void move_assign(BOOST_FUNCTION_FUNCTION& f)
{
if (&f == this)
return;
#if !defined(BOOST_NO_EXCEPTIONS)
try {
#endif
if (!f.empty()) {
this->vtable = f.vtable;
f.vtable->manager(f.functor, this->functor,
boost::detail::function::move_functor_tag);
f.vtable = 0;
#if !defined(BOOST_NO_EXCEPTIONS)
} else {
clear();
}
} catch (...) {
vtable = 0;
throw;
}
#endif
}
};
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator>
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
inline void swap(BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator
BOOST_FUNCTION_TEMPLATE_ARGS
>& f1,
BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS,
Allocator
BOOST_FUNCTION_TEMPLATE_ARGS
>& f2)
{
f1.swap(f2);
}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
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>
R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>::result_type
BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>
::operator()(BOOST_FUNCTION_PARMS) const
{
if (this->empty())
boost::throw_exception(bad_function_call());
return static_cast<vtable_type*>(vtable)->invoker
return reinterpret_cast<const vtable_type*>(vtable)->invoker
(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
}
#endif
// Poison comparisons between boost::function objects of the same type.
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator>
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
void operator==(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>&,
BOOST_FUNCTION_TEMPLATE_ARGS>&,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>&);
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Allocator>
BOOST_FUNCTION_TEMPLATE_ARGS>&);
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
void operator!=(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>&,
BOOST_FUNCTION_TEMPLATE_ARGS>&,
const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Allocator>&);
BOOST_FUNCTION_TEMPLATE_ARGS>& );
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
@ -725,20 +1015,16 @@ template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
#endif
template<typename R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
class function<BOOST_FUNCTION_PARTIAL_SPEC, Allocator>
: public BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
BOOST_FUNCTION_COMMA Allocator>
BOOST_FUNCTION_TEMPLATE_PARMS>
class function<BOOST_FUNCTION_PARTIAL_SPEC>
: public BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>
{
typedef BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
BOOST_FUNCTION_COMMA Allocator> base_type;
typedef BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS> base_type;
typedef function self_type;
struct clear_type {};
public:
typedef typename base_type::allocator_type allocator_type;
function() : base_type() {}
@ -754,6 +1040,18 @@ public:
base_type(f)
{
}
template<typename Functor,typename Allocator>
function(Functor f, Allocator a
#ifndef BOOST_NO_SFINAE
,typename enable_if_c<
(boost::type_traits::ice_not<
(is_integral<Functor>::value)>::value),
int>::type = 0
#endif
) :
base_type(f,a)
{
}
#ifndef BOOST_NO_SFINAE
function(clear_type*) : base_type() {}
@ -806,7 +1104,6 @@ public:
// Cleanup after ourselves...
#undef BOOST_FUNCTION_VTABLE
#undef BOOST_FUNCTION_DEFAULT_ALLOCATOR
#undef BOOST_FUNCTION_COMMA
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_FUNCTION_INVOKER
@ -815,10 +1112,13 @@ public:
#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
#undef BOOST_FUNCTION_FUNCTION_REF_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER
#undef BOOST_FUNCTION_MEMBER_INVOKER
#undef BOOST_FUNCTION_VOID_MEMBER_INVOKER
#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER
#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
#undef BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
#undef BOOST_FUNCTION_GET_MEM_FUNCTION_INVOKER
#undef BOOST_FUNCTION_GET_INVOKER
#undef BOOST_FUNCTION_TEMPLATE_PARMS
#undef BOOST_FUNCTION_TEMPLATE_ARGS
#undef BOOST_FUNCTION_PARMS
@ -828,3 +1128,7 @@ public:
#undef BOOST_FUNCTION_ARG_TYPES
#undef BOOST_FUNCTION_VOID_RETURN_TYPE
#undef BOOST_FUNCTION_RETURN
#if defined(BOOST_MSVC)
# pragma warning( pop )
#endif

View File

@ -0,0 +1,45 @@
// Boost.Function library - Typeof support
// Copyright (C) Douglas Gregor 2008
//
// 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_TYPEOF_HPP
#define BOOST_FUNCTION_TYPEOF_HPP
#include <boost/function/function_fwd.hpp>
#include <boost/typeof/typeof.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TYPE(boost::bad_function_call)
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, (typename))
#endif
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function0, (typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function1, (typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function2, (typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function3,
(typename)(typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function4,
(typename)(typename)(typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function5,
(typename)(typename)(typename)(typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function6,
(typename)(typename)(typename)(typename)(typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function7,
(typename)(typename)(typename)(typename)(typename)(typename)(typename)
(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function8,
(typename)(typename)(typename)(typename)(typename)(typename)(typename)
(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function9,
(typename)(typename)(typename)(typename)(typename)(typename)(typename)
(typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function10,
(typename)(typename)(typename)(typename)(typename)(typename)(typename)
(typename)(typename)(typename)(typename))
#endif

View File

@ -1,4 +1,11 @@
<html>
<!--
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)
-->
<head>
<meta http-equiv="refresh" content="0; URL=../../doc/html/function.html">
</head>

20
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
boost_test_run(lib_function_test function_test.cpp)
boost_test_run(function_n_test)
boost_test_run(allocator_test)
boost_test_run(stateless_test)
boost_test_run(lambda_test)
boost_test_compile_fail(function_test_fail1)
boost_test_compile_fail(function_test_fail2)
boost_test_compile(function_30)
boost_test_run(function_arith_cxx98)
boost_test_run(function_arith_portable)
boost_test_run(sum_avg_cxx98)
boost_test_run(sum_avg_portable)
boost_test_run(mem_fun_cxx98)
boost_test_run(mem_fun_portable)
boost_test_run(std_bind_cxx98)
boost_test_run(std_bind_portable)
boost_test_run(function_ref_cxx98)
boost_test_run(function_ref_portable)
boost_test_run(contains_test)
boost_test_run(contains2_test)

View File

@ -58,6 +58,9 @@ import testing ;
[ run libs/function/test/contains2_test.cpp : : : : ]
[ run libs/function/test/nothrow_swap.cpp : : : : ]
[ compile libs/function/test/function_typeof_test.cpp ]
;
}

View File

@ -27,6 +27,14 @@ struct counting_allocator : public std::allocator<T>
typedef counting_allocator<U> other;
};
counting_allocator()
{
}
template<typename U>
counting_allocator( counting_allocator<U> )
{
}
T* allocate(std::size_t n)
{
@ -41,20 +49,27 @@ struct counting_allocator : public std::allocator<T>
}
};
struct plus_int
struct enable_small_object_optimization
{
};
struct disable_small_object_optimization
{
int unused_state_data[32];
};
template <typename base>
struct plus_int: base
{
int operator()(int x, int y) const { return x + y; }
int unused_state_data[32];
};
static int do_minus(int x, int y) { return x-y; }
struct DoNothing
template <typename base>
struct DoNothing: base
{
void operator()() const {}
int unused_state_data[32];
};
static void do_nothing() {}
@ -62,33 +77,57 @@ static void do_nothing() {}
int
test_main(int, char*[])
{
function2<int, int, int, counting_allocator<int> > f;
f = plus_int();
function2<int, int, int> f;
f.assign( plus_int<disable_small_object_optimization>(), counting_allocator<int>() );
f.clear();
BOOST_CHECK(alloc_count == 1);
BOOST_CHECK(dealloc_count == 1);
alloc_count = 0;
dealloc_count = 0;
f = &do_minus;
f.assign( plus_int<enable_small_object_optimization>(), counting_allocator<int>() );
f.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
f.assign( plus_int<disable_small_object_optimization>(), std::allocator<int>() );
f.clear();
f.assign( plus_int<enable_small_object_optimization>(), std::allocator<int>() );
f.clear();
function0<void, counting_allocator<int> > fv;
alloc_count = 0;
dealloc_count = 0;
fv = DoNothing();
f.assign( &do_minus, counting_allocator<int>() );
f.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
f.assign( &do_minus, std::allocator<int>() );
f.clear();
function0<void> fv;
alloc_count = 0;
dealloc_count = 0;
fv.assign( DoNothing<disable_small_object_optimization>(), counting_allocator<int>() );
fv.clear();
BOOST_CHECK(alloc_count == 1);
BOOST_CHECK(dealloc_count == 1);
alloc_count = 0;
dealloc_count = 0;
fv = &do_nothing;
fv.assign( DoNothing<enable_small_object_optimization>(), counting_allocator<int>() );
fv.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
fv.assign( DoNothing<disable_small_object_optimization>(), std::allocator<int>() );
fv.clear();
fv.assign( DoNothing<enable_small_object_optimization>(), std::allocator<int>() );
fv.clear();
alloc_count = 0;
dealloc_count = 0;
fv.assign( &do_nothing, counting_allocator<int>() );
fv.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
fv.assign( &do_nothing, std::allocator<int>() );
fv.clear();
return 0;
}

View File

@ -88,6 +88,15 @@ static void target_test()
BOOST_CHECK(!f.target<int (*)()>());
BOOST_CHECK(f.target<Seventeen>());
BOOST_CHECK(f.target<Seventeen>() == &this_seventeen);
const Seventeen const_seventeen = this_seventeen;
f = boost::ref(const_seventeen);
BOOST_CHECK(!f.target<int (*)()>());
BOOST_CHECK(f.target<const Seventeen>());
BOOST_CHECK(f.target<const Seventeen>() == &const_seventeen);
BOOST_CHECK(f.target<const volatile Seventeen>());
BOOST_CHECK(!f.target<Seventeen>());
BOOST_CHECK(!f.target<volatile Seventeen>());
}
static void equal_test()

View File

@ -636,6 +636,54 @@ test_ref()
}
}
static unsigned construction_count = 0;
static unsigned destruction_count = 0;
struct MySmallFunctor {
MySmallFunctor() { ++construction_count; }
MySmallFunctor(const MySmallFunctor &) { ++construction_count; }
~MySmallFunctor() { ++destruction_count; }
int operator()() { return 0; }
};
struct MyLargeFunctor {
MyLargeFunctor() { ++construction_count; }
MyLargeFunctor(const MyLargeFunctor &) { ++construction_count; }
~MyLargeFunctor() { ++destruction_count; }
int operator()() { return 0; }
float data[128];
};
void test_construct_destroy_count()
{
{
boost::function0<int> f;
boost::function0<int> g;
f = MySmallFunctor();
g = MySmallFunctor();
f.swap(g);
}
// MySmallFunctor objects should be constructed as many times as
// they are destroyed.
BOOST_CHECK(construction_count == destruction_count);
construction_count = 0;
destruction_count = 0;
{
boost::function0<int> f;
boost::function0<int> g;
f = MyLargeFunctor();
g = MyLargeFunctor();
f.swap(g);
}
// MyLargeFunctor objects should be constructed as many times as
// they are destroyed.
BOOST_CHECK(construction_count == destruction_count);
}
int test_main(int, char* [])
{
test_zero_args();
@ -644,5 +692,6 @@ int test_main(int, char* [])
test_emptiness();
test_member_functions();
test_ref();
test_construct_destroy_count();
return 0;
}

View File

@ -0,0 +1,18 @@
// Boost.Function library
// Copyright Douglas Gregor 2008. 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
#include <boost/function/function_typeof.hpp>
#include <boost/function.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
void f(boost::function0<void> f, boost::function0<void> g)
{
BOOST_STATIC_ASSERT((boost::is_same<boost::function0<void>, BOOST_TYPEOF(f = g)>::value));
}

60
test/nothrow_swap.cpp Normal file
View File

@ -0,0 +1,60 @@
// Boost.Function library
// Copyright Douglas Gregor 2008. 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
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
struct tried_to_copy { };
struct MaybeThrowOnCopy {
MaybeThrowOnCopy(int value = 0) : value(value) { }
MaybeThrowOnCopy(const MaybeThrowOnCopy& other) : value(other.value) {
if (throwOnCopy)
throw tried_to_copy();
}
MaybeThrowOnCopy& operator=(const MaybeThrowOnCopy& other) {
if (throwOnCopy)
throw tried_to_copy();
value = other.value;
return *this;
}
int operator()() { return value; }
int value;
// Make sure that this function object doesn't trigger the
// small-object optimization in Function.
float padding[100];
static bool throwOnCopy;
};
bool MaybeThrowOnCopy::throwOnCopy = false;
int test_main(int, char* [])
{
boost::function0<int> f;
boost::function0<int> g;
MaybeThrowOnCopy::throwOnCopy = false;
f = MaybeThrowOnCopy(1);
g = MaybeThrowOnCopy(2);
BOOST_CHECK(f() == 1);
BOOST_CHECK(g() == 2);
MaybeThrowOnCopy::throwOnCopy = true;
f.swap(g);
BOOST_CHECK(f() == 2);
BOOST_CHECK(g() == 1);
return 0;
}