Compare commits

...

138 Commits

Author SHA1 Message Date
4d917003e2 v2, v3, integration branch
[SVN r62649]
2010-06-09 11:34:33 +00:00
a991936c96 Made memset call in value_init conditional, see #3869. Updated the section "compiler issues" of its documentation.
[SVN r62307]
2010-05-30 09:19:09 +00:00
6239e685a2 value_init_test now uses lightweight_test by Peter Dimov; see #4246. Fernando Cacciola mailed me he agreed as well.
[SVN r62158]
2010-05-22 22:05:54 +00:00
e601fcb9c9 Locally disabled a trivial MSVC warning in value_init.hpp (C4512, "assignment operator could not be generated")
[SVN r62030]
2010-05-16 11:08:00 +00:00
f29a5db08e Hopefully fixed value_initialized compile errors on clang and comeau (strict mode) reported by Christopher Jefferson, see #4213
[SVN r61947]
2010-05-13 14:36:06 +00:00
22743ee125 Added boost::initialized<T> as was agreed at http://lists.boost.org/Archives/boost/2010/04/164916.php -- see #3472
[SVN r61883]
2010-05-09 20:51:24 +00:00
e3c982287a add tr1_result_of that always behaves as TR1 specifies, fix Boost.TR1's result_of to use tr1_result_of
[SVN r61248]
2010-04-13 15:01:11 +00:00
82e1111bb8 Revert [60052], as it causes other libraries to break.
[SVN r61097]
2010-04-06 07:56:54 +00:00
9339b32178 Updated copyright notice.
[SVN r61075]
2010-04-05 19:08:01 +00:00
3770221507 Hopefully fixed #3984 (std::bitset constructor issue). Tested by Juergen Hunold on msvc-10.0, msvc-9.0, and gcc-4.4. See thread starting at http://lists.boost.org/Archives/boost/2010/03/162690.php
[SVN r60331]
2010-03-07 21:42:22 +00:00
e6cb3a77ee Fix a couple of comments.
[SVN r60294]
2010-03-07 13:11:10 +00:00
bbccfbbab4 Remove use of deprecated macro in result_of test.
[SVN r60293]
2010-03-07 13:10:54 +00:00
74a6a693d3 Remove use of deprecated config macro in result_of.
[SVN r60052]
2010-03-01 19:39:52 +00:00
bf713ad47a Revert unintentional reference to "noncopyable_adl_barrier" test that's not checked in.
[SVN r59332]
2010-01-28 14:41:16 +00:00
76b17c497b Support different MS calling conventions, thanks to Nicolas Lelong.
Closes #3833.


[SVN r59247]
2010-01-24 02:08:46 +00:00
3de5974419 Suppressing warnings. Please report any problems (may have broken something!)
[SVN r58072]
2009-12-01 02:16:50 +00:00
7eb1536590 Suppress/fix some msvc and gcc compiler warnings.
[SVN r57494]
2009-11-08 18:53:59 +00:00
9339431e03 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
f2349baf7d Updated value_init documentation, because the fix of #2548 was not yet included with Boost release 1.40.0.
[SVN r56544]
2009-10-03 09:18:26 +00:00
8745ca628a Updated revision date of Boost Swap documentation
[SVN r56108]
2009-09-08 17:07:13 +00:00
ba61e9d796 Mentioned swap.hpp header, as requested by Thorsten Ottosen <http://lists.boost.org/Archives/boost/2009/06/153477.php> and David Abrahams <http://lists.boost.org/Archives/boost/2009/09/156064.php>
[SVN r56107]
2009-09-08 16:54:54 +00:00
afe74fffbc Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
09a0137016 Reverted value_init revision [54502], intel_9_value_init_conversion-operator.patch from ticket #2548, as it only increased the number of compile errors at the regression page, and Fernando Cacciola also suggested me to leave it broken (without the patch), for this specific (old) compiler version.
[SVN r54832]
2009-07-09 08:06:19 +00:00
a1d3ec6c53 Documentation update
[SVN r54828]
2009-07-09 03:51:30 +00:00
5be3004e6c Added commonly used error_info typedefs.
Added boost/exception/all.hpp.
Removed tabs from source files.

[SVN r54825]
2009-07-08 23:44:28 +00:00
d387905150 Updated documentation of value_initialized, according to a remark by Daniel James at ticket #2548
[SVN r54503]
2009-06-29 18:04:24 +00:00
b514e40733 Worked around Intel 9 specific ambiguity w.r.t. value_initialized conversion operators, by applying intel_9_value_init_conversion-operator.patch, as discussed w/ Daniel James at ticket #2548
[SVN r54502]
2009-06-29 17:53:33 +00:00
b02677375f Fixed most tab and min/max issues from trunk inspection report
[SVN r53141]
2009-05-20 19:19:00 +00:00
61a6015b5a Replace aFactoty with aFactory. Fixes #3019
[SVN r53060]
2009-05-17 00:06:34 +00:00
682032a340 Use a local copy of the valid HTML 4.01 icon.
[SVN r53048]
2009-05-16 14:23:59 +00:00
67afd7e315 eliminate noisy warning on msvc, fixes #2993
[SVN r52837]
2009-05-07 17:47:08 +00:00
75cf20cace primary operand type must be class type, see ticket #2938
[SVN r52463]
2009-04-18 09:06:31 +00:00
91385ac627 Another try at the Sun workaround.
[SVN r52010]
2009-03-27 12:50:09 +00:00
61e9b93f7c Try the Sun workaround with int instead of size_t.
[SVN r51986]
2009-03-26 13:05:05 +00:00
d97b303777 Try to fix array addressof failures on Sun C++.
[SVN r51977]
2009-03-26 00:06:47 +00:00
3900e8ece4 Disable new addressof code for all Borland versions. Refs #2878.
[SVN r51891]
2009-03-21 20:20:37 +00:00
e27fc4a853 Attempt to fix addressof in trunk to handle classes with conversion operators. Refs #2878.
[SVN r51872]
2009-03-20 17:14:00 +00:00
f7aa9a8935 Refs #2128 (fixed in trunk.)
[SVN r51512]
2009-03-01 17:04:14 +00:00
0af1959b30 Updated value_initialized documentation and test following changeset [51355].
[SVN r51356]
2009-02-20 20:35:34 +00:00
5f0cf4f5de Fixed const issue of value_initialized according to ticket #2548. See also http://lists.boost.org/Archives/boost/2009/02/148489.php
[SVN r51355]
2009-02-20 20:28:54 +00:00
0282c8a141 added #error in headers incompatible with BOOST_NO_EXCEPTIONS
[SVN r50887]
2009-01-30 00:06:01 +00:00
6725719bd9 This html was outdated; changed to forward to throw_exception.html documentation from Boost Exception
[SVN r50879]
2009-01-29 19:13:08 +00:00
97e11b024e [utility/swap] Distinguished between testing array-of-array-of-class and array-of-array-of-int, as the latter appears to succeed on CodeGear 6.10 while the former does not.
[SVN r49954]
2008-11-27 11:14:52 +00:00
118e473a3d [utility/swap] Added comment to various array swapping tests, added member typedef to swap_test_template, to make the test more realistic.
[SVN r49953]
2008-11-27 11:08:05 +00:00
d4b6193f94 Replaced swap/test/swap_arrays by more specific tests: array_of_array, array_of_class, and array_of_int.
[SVN r49916]
2008-11-24 17:41:15 +00:00
d420c98a53 Added array_of_template test, testing the boost::swap utility on an array of objects of a template class.
[SVN r49862]
2008-11-21 21:28:47 +00:00
d153ab4daa Fix a typo.
[SVN r49811]
2008-11-16 23:10:00 +00:00
561f83b991 Updated swap.html because LWG issue 809 is now accepted as a defect. Fixed some HTML formatting.
[SVN r49771]
2008-11-15 15:07:42 +00:00
57124703f9 Fixing include path to compile with modularized source tree.
[SVN r49685]
2008-11-11 17:22:34 +00:00
53f6d10652 Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
ebe853ff2f Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
487a5c1ea5 Swap documentation: fixed a misspelling of the name of Steven Watanabe.
[SVN r49416]
2008-10-21 09:55:54 +00:00
c4338b1ce8 Clean up some link errors.
[SVN r48987]
2008-09-28 12:21:39 +00:00
ddd8a58ae0 Fixes #2341.
[SVN r48910]
2008-09-20 15:39:47 +00:00
28061ba3a8 Removed boost directory binary.hpp.
[SVN r48804]
2008-09-17 01:08:03 +00:00
5d53e3f837 Changed BOOST_BINARY docs.
[SVN r48641]
2008-09-06 21:51:53 +00:00
e86ce1cb1f Changed wording for BOOST_BINARY docs.
[SVN r48640]
2008-09-06 21:49:49 +00:00
f15c96ffb0 Adding binary literal utility.
[SVN r48637]
2008-09-06 21:11:48 +00:00
a487f72329 Fix result_of to work with const-qualified function pointers. Fixes #1310
[SVN r48620]
2008-09-05 19:58:30 +00:00
9f08ed6de0 minor change in boost/exception.hpp
[SVN r48546]
2008-09-02 21:25:47 +00:00
2077d0dace simplified further
[SVN r48485]
2008-08-31 02:40:42 +00:00
7f2348269b Boost Exception now works with BOOST_NO_RTTI and/or BOOST_NO_TYPEID.
[SVN r48429]
2008-08-28 23:49:55 +00:00
6b6e1c3252 Added value_initialized::swap documentation + test
[SVN r48425]
2008-08-28 19:00:20 +00:00
55f303baec Added value_initialized::swap according to ticket #2243, as agreed with Fernando Cacciola :-)
[SVN r48424]
2008-08-28 18:37:45 +00:00
d264005c11 Extended swap_arrays test, checking that boost::swap does correctly exchange the values of its arguments.
[SVN r48247]
2008-08-20 08:29:54 +00:00
2cde009bb1 Added extra checks, checking that boost::swap does correctly exchange the values of its arguments, as I mentioned at "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141027.php
[SVN r48246]
2008-08-20 08:28:35 +00:00
7bfb7c8a61 Added a data member to swap_test_class and made it EqualityComparable, as I mentioned at "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141027.php
[SVN r48245]
2008-08-20 08:25:23 +00:00
5c42397244 Added explanatory comments, requested by Isaac Dupree, "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141007.php
[SVN r48171]
2008-08-16 08:56:19 +00:00
782c132d99 Fix Windows-1252 dash in UTF-8 document.
[SVN r48133]
2008-08-13 22:00:35 +00:00
36899afa3f added/switched "euclidean" spelling
[SVN r48025]
2008-08-07 20:47:58 +00:00
7e3e326faf Updated documentation to remove references to the 'ADL barrier'
[SVN r47973]
2008-08-04 18:25:45 +00:00
7019e18149 Renamed 'test_adl_barrier.cpp' to 'no_ambiguity_in_boost.cpp' and altered comments to reflect new disambiguation technique.
[SVN r47972]
2008-08-04 18:22:10 +00:00
49faf23433 Updated copyright info.
[SVN r47971]
2008-08-04 18:16:16 +00:00
62836f2928 Changed 'using std::swap;' to 'using namesapce std;' in swap_impl function to work around ADL bugs in some compilers.
[SVN r47967]
2008-08-04 11:21:02 +00:00
1ecf3ceb74 Added swap tests for std types, as discussed at "Re: [boost] [swap] Workaround for ADL failures of MSVC 7.1 and Borland okay?", http://lists.boost.org/Archives/boost/2008/08/140589.php
[SVN r47943]
2008-08-02 11:41:47 +00:00
2aa48414c9 Removed swap_adl_barrier namespace, as discussed at "Re: [boost] [swap] How to fix ADL barrier for XL, Intel, GCC, Sun and Como?", http://lists.boost.org/Archives/boost/2008/07/140511.php
[SVN r47920]
2008-07-31 20:18:04 +00:00
d215f2176c Applied "swap.hpp.patch" by Steven Watanabe, "Re: [boost] [swap] How to fix ADL barrier for XL, Intel, GCC, Sun and Como?", http://lists.boost.org/Archives/boost/2008/07/140482.php
[SVN r47877]
2008-07-30 08:04:34 +00:00
c286d62223 Fixed comment in swap/test/specialized_in_boost_and_other.cpp
[SVN r47840]
2008-07-27 12:46:45 +00:00
3fd0ea6e75 Added specialized_in_boost_and_other to swap/test, as discussed at "[boost] [swap] End-user allowed to add overloads to boost namespace?", http://lists.boost.org/Archives/boost/2008/07/140327.php
[SVN r47839]
2008-07-27 11:35:33 +00:00
b050431638 Added a newline to swap/test/lib_header_1.cpp, hoping to fix Sun 5.x compile issue, "Error: There is extra text on this line"
[SVN r47829]
2008-07-26 17:47:59 +00:00
b311fcefb2 Added test_adl_barrier to swap/test, as discussed with Joseph Gauterin.
[SVN r47808]
2008-07-25 18:48:09 +00:00
899c92420c Fixed silly little typo of mine, in test/swap_arrays.cpp
[SVN r47629]
2008-07-20 12:18:25 +00:00
64a0e0cb20 Added swap_test_class swap functions to test/swap_arrays.cpp. My fault, they should have been there already!
[SVN r47628]
2008-07-20 12:13:33 +00:00
ece6992540 Fixed silly little bug of mine in swap/test/swap_arrays.cpp
[SVN r47626]
2008-07-20 11:05:49 +00:00
6098304ea8 Corrected duplicated file contents
[SVN r47607]
2008-07-19 19:40:12 +00:00
28fff2d821 Remove duplicate content.
[SVN r47360]
2008-07-12 17:56:01 +00:00
0ce3885d59 Added an anonymous unwrapping test.
[SVN r47297]
2008-07-10 23:01:26 +00:00
1823481d96 Added tests for unwrap_ref.
[SVN r47296]
2008-07-10 19:29:02 +00:00
cce5d77d2b Added unwrap_ref.
[SVN r47295]
2008-07-10 19:28:49 +00:00
3c5c2bc107 Moved utility\swap to the trunk, as discussed in trac issue #2056.
[SVN r47093]
2008-07-05 11:16:38 +00:00
177ee78bbb With his kind permission, change Jaakko "Järvi" to "Jarvi"
[SVN r46808]
2008-06-28 13:45:21 +00:00
f1ec0c4d04 Fix a character encoding error.
[SVN r46740]
2008-06-26 19:20:56 +00:00
4a564744fe documentation update, added function exception::diagnostic_information, added std::exception to_string overload, removed tabs from source files
[SVN r46697]
2008-06-25 23:27:56 +00:00
67f3ca090a Fixed value_init test + doc, according to change of boost::initialized_value, revision [45685]
[SVN r45686]
2008-05-23 16:48:10 +00:00
8efae71f4a Changed boost::initialized_value from a class to an instance, to make its use more convenient, as discussed with Fernando.
[SVN r45685]
2008-05-23 16:46:43 +00:00
ad0bcf4a00 result_of implementation that makes use of C++0x decltype, from Daniel Walker. Fixes #862.
[SVN r45256]
2008-05-09 22:08:46 +00:00
f1c86c35c4 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.
........


[SVN r44807]
2008-04-27 07:39:49 +00:00
a5b85eda07 Fix #1846.
[SVN r44705]
2008-04-21 21:42:29 +00:00
bafe37fdab Boost Exception header compilation tests added.
[SVN r44442]
2008-04-15 21:13:24 +00:00
be50b95508 Added test and fix for "convertible to bool" requirement
[SVN r44151]
2008-04-10 14:38:14 +00:00
96d573d6ca Replaced all occurrences of non-ASCII copyright symbol with '(c)' for people using non-ASCII code pages
[SVN r43992]
2008-04-02 01:42:32 +00:00
2412b864d6 Fix some inspection report issues.
[SVN r43633]
2008-03-15 18:41:51 +00:00
94865eabe6 boost exception
[SVN r43485]
2008-03-04 01:41:17 +00:00
50268d1b29 Tested the assignment of value_initialized<T>, for T being a C-style array. Related to the fix of changeset [43308]
[SVN r43309]
2008-02-18 22:13:21 +00:00
ad9108c1dc Fixed the assignment of value_initialized<T> for T being a C-style array. (The previous version would trigger a compile error in this case.)
[SVN r43308]
2008-02-18 22:11:19 +00:00
691e4b6c34 Link to people pages on the website, as they've been removed from the download.
[SVN r43209]
2008-02-10 14:56:22 +00:00
28596e678d value_init: Removed aligned_storage::address() calls, to improve TR1 compatibility, as confirmed by John Maddock. Added internal helper function, wrapper_address(), as discussed with Fernando.
[SVN r43025]
2008-01-30 22:42:23 +00:00
1beca24dd8 Removed local named variable from value_initialized::operator=, as Fernando Cacciola suggested me to avoid unnecessary named variables.
[SVN r42869]
2008-01-19 20:52:04 +00:00
721764937f value_init_test now works around Borland 5.82 bug ("Error E2015: Ambiguity..." when using initialized_value), that is fixed with a newer compiler version
[SVN r42868]
2008-01-19 20:21:18 +00:00
a511007d0f Added test and documentation for convenience class initialized_value, that was added with changeset [42815]
[SVN r42816]
2008-01-16 09:37:25 +00:00
8ce58b1675 Added convenience class initialized_value, as announced at http://article.gmane.org/gmane.comp.lib.boost.devel/169833
[SVN r42815]
2008-01-16 09:35:12 +00:00
9ed68b8321 value_init doc + test: Added revision date.
[SVN r42798]
2008-01-15 19:53:28 +00:00
79bbf71d0d Minor "beautifications" of value_init documentation, inc. placing references in order of appearance
[SVN r42779]
2008-01-14 21:46:20 +00:00
ac93de7c1b Documented value_init workaround to compiler issues, added new introduction, updated to 2003 edition of C++ Standard -- reviewed by Fernando Cacciola
[SVN r42771]
2008-01-14 18:17:30 +00:00
d731b8e1c5 Added value_init tests, testing copy construction and assignment.
[SVN r42278]
2007-12-24 22:00:37 +00:00
ac1567b3fc value_init now uses aligned_storage::address(), instead of "&x", as recommended by Fernando Cacciola (by mail)
[SVN r42277]
2007-12-24 20:42:16 +00:00
c1fd670480 Reduce header dependencies, from Shunsuke Sogame. Fixes #1535
[SVN r42234]
2007-12-21 21:18:17 +00:00
01274cf6ac value_init.hpp now no longer distinguished between workaround and non-workaround, because many compilers don't do value-initialization well. Fixed copy construction and assignment -- discussed with Fernando Cacciola
[SVN r41942]
2007-12-09 22:49:58 +00:00
8080673977 Added value_init tests if a copy function of T is called when value_initialized<T> is copied -- a case I hadn't thought of before...
[SVN r41919]
2007-12-09 11:53:08 +00:00
a470b591fb Added value_init test for an value_initialized<T> object allocated on the heap.
[SVN r41667]
2007-12-03 21:41:59 +00:00
e1a63495b6 Added missing #include to value_init_test.cpp. (My mistake!)
[SVN r41648]
2007-12-03 18:20:19 +00:00
7300ac83f1 Added value_init test for C style array of bytes
[SVN r41647]
2007-12-03 18:14:37 +00:00
882d38c2c7 Added value_init tests, based upon GCC bug report by Jonathan Wakely. Added URL to Borland bug report.
[SVN r41529]
2007-12-01 12:14:37 +00:00
33041ad664 Added tests for two more struct types to value_init_test -- discussed with Fernando Cacciola
[SVN r41436]
2007-11-28 17:19:37 +00:00
6a2aa822f8 Added value_init test for struct as used in MSVC bug report regarding value-initialization.
[SVN r41423]
2007-11-27 21:34:08 +00:00
09ab16bfc1 Checked the result of value_init test function, hoping to pinpoint exactly for what particular type T value_initialized<T> might fail, on some platforms
[SVN r41326]
2007-11-24 11:51:03 +00:00
ec46e40809 Code refactoring: removed private base classes of value_initialized, as suggested by Fernando Cacciola.
[SVN r41216]
2007-11-18 22:11:57 +00:00
b3a971e7e9 Copyright and/or License cleanup
[SVN r40890]
2007-11-07 16:08:09 +00:00
7ddb559887 Fix path to test case.
[SVN r40736]
2007-11-04 12:01:16 +00:00
ea8c99b1d5 Added a sentence with a brief explanation of the intended uses of BOOST_VERIFY.
[SVN r40731]
2007-11-03 22:47:17 +00:00
56b0846099 BOOST_VERIFY added.
[SVN r40728]
2007-11-03 20:55:22 +00:00
42e0001370 Added value_initialized<T> test, having T as aggregate POD struct. In the past, this would have triggered MSVC warning C4345; this warning is now disabled within value_init.hpp, changeset [40088]
[SVN r40089]
2007-10-16 17:06:39 +00:00
cd8f85afee Disabled MSVC warning C4345, in response to Gennadiy Rozental, Boost Developer mailing list, "[utility] value_init warning", October 14, 2007. Push'n'pop reminder from Paul A Bristow taken into account.
[SVN r40088]
2007-10-16 17:00:28 +00:00
bddd52c4b9 Fixed bug preventing compilation on Tru64/CXX.
[SVN r39918]
2007-10-11 07:36:41 +00:00
8f03aeac4e Added unit test to make sure that Visual C++ 7.1 ICE reported by Ralf W. Grosse-Kunstleve (Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround") will not occur anymore.
[SVN r39309]
2007-09-16 09:48:28 +00:00
3bb2568fad Visual C++ 7.1 ICE workaround by Ralf W. Grosse-Kunstleve added to ~const_T_base() as well. See also Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround"
[SVN r39308]
2007-09-16 09:33:34 +00:00
01e91a3799 work around Visual C++ 7.1 internal compiler error
[SVN r39302]
2007-09-15 23:11:50 +00:00
55f3c351a3 Added MSVC workaround to value_initialized, as described by ticket #1217, proposed at the Boost Developers mailing list, and discussed with Fernando Cacciola.
[SVN r39157]
2007-09-07 17:17:09 +00:00
88 changed files with 4866 additions and 569 deletions

View File

@ -85,7 +85,7 @@
<hr> <hr>
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
height="31" width="88"></a></p> height="31" width="88"></a></p>
<p>Revised <p>Revised

View File

@ -509,7 +509,7 @@ Returns the largest size that this Collection can ever have. <A href="#8">[8]</A
<hr> <hr>
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
height="31" width="88"></a></p> height="31" width="88"></a></p>
<p>Revised <p>Revised

View File

@ -160,7 +160,7 @@ t.~T()
<hr> <hr>
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
height="31" width="88"></a></p> height="31" width="88"></a></p>
<p>Revised <p>Revised

View File

@ -185,7 +185,7 @@
<hr> <hr>
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
height="31" width="88"></a></p> height="31" width="88"></a></p>
<p>Revised <p>Revised

View File

@ -70,7 +70,7 @@
<hr> <hr>
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
height="31" width="88"></a></p> height="31" width="88"></a></p>
<p>Revised <p>Revised

View File

@ -145,14 +145,20 @@ objects are is implemented in <a href="../../boost/utility/compare_pointees.hpp"
so direct usage of relational operators with the implied aliasing of shallow semantics so direct usage of relational operators with the implied aliasing of shallow semantics
-as with pointers- should not be used with generic code written for this concept.</p> -as with pointers- should not be used with generic code written for this concept.</p>
<h3>Acknowledgements</h3>
<p>Based on the original concept developed by Augustus Saunders.
<br> <br>
</p>
<HR> <HR>
<TABLE> <TABLE>
<TR valign=top> <TR valign=top>
<TD nowrap>Copyright &copy 2003</TD><TD> <TD nowrap>Copyright &copy 2003</TD><TD>
<A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>, <A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>
based on the original concept developed by Augustus Saunders.
</TD></TR></TABLE> </TD></TR></TABLE>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
</BODY> </BODY>
</HTML> </HTML>

76
addressof_fn_test.cpp Normal file
View File

@ -0,0 +1,76 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
// addressof_fn_test.cpp: addressof( f )
//
// Copyright (c) 2008, 2009 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
void f0()
{
}
void f1(int)
{
}
void f2(int, int)
{
}
void f3(int, int, int)
{
}
void f4(int, int, int, int)
{
}
void f5(int, int, int, int, int)
{
}
void f6(int, int, int, int, int, int)
{
}
void f7(int, int, int, int, int, int, int)
{
}
void f8(int, int, int, int, int, int, int, int)
{
}
void f9(int, int, int, int, int, int, int, int, int)
{
}
int main()
{
BOOST_TEST( boost::addressof( f0 ) == &f0 );
BOOST_TEST( boost::addressof( f1 ) == &f1 );
BOOST_TEST( boost::addressof( f2 ) == &f2 );
BOOST_TEST( boost::addressof( f3 ) == &f3 );
BOOST_TEST( boost::addressof( f4 ) == &f4 );
BOOST_TEST( boost::addressof( f5 ) == &f5 );
BOOST_TEST( boost::addressof( f6 ) == &f6 );
BOOST_TEST( boost::addressof( f7 ) == &f7 );
BOOST_TEST( boost::addressof( f8 ) == &f8 );
BOOST_TEST( boost::addressof( f9 ) == &f9 );
return boost::report_errors();
}

95
addressof_test2.cpp Normal file
View File

@ -0,0 +1,95 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu)
//
// Copyright 2009 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// For more information, see http://www.boost.org
#include <boost/utility/addressof.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{
T* px = new T();
T& x = *px;
BOOST_TEST( boost::addressof(x) == px );
const T& cx = *px;
const T* pcx = boost::addressof(cx);
BOOST_TEST( pcx == px );
volatile T& vx = *px;
volatile T* pvx = boost::addressof(vx);
BOOST_TEST( pvx == px );
const volatile T& cvx = *px;
const volatile T* pcvx = boost::addressof(cvx);
BOOST_TEST( pcvx == px );
delete px;
}
template<class T> void array_test( T * = 0 )
{
T nrg[3] = {1,2,3};
T (*pnrg)[3] = &nrg;
BOOST_TEST( boost::addressof(nrg) == pnrg );
T const cnrg[3] = {1,2,3};
T const (*pcnrg)[3] = &cnrg;
BOOST_TEST( boost::addressof(cnrg) == pcnrg );
}
class convertible {
public:
convertible( int = 0 )
{
}
template<class U> operator U () const
{
return U();
}
};
class convertible2 {
public:
convertible2( int = 0 )
{
}
operator convertible2* () const
{
return 0;
}
};
int main()
{
scalar_test<convertible>();
scalar_test<convertible2>();
array_test<convertible>();
array_test<convertible2>();
return boost::report_errors();
}

View File

@ -47,9 +47,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil
<P>As is the case with <STRONG>&lt;cassert&gt;</STRONG>, <STRONG>&lt;boost/assert.hpp&gt;</STRONG> <P>As is the case with <STRONG>&lt;cassert&gt;</STRONG>, <STRONG>&lt;boost/assert.hpp&gt;</STRONG>
can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT</STRONG> can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT</STRONG>
will be redefined each time as specified above.</P> will be redefined each time as specified above.</P>
<p><STRONG>&lt;boost/assert.hpp&gt;</STRONG> also defines the macro <STRONG>BOOST_VERIFY</STRONG>.
It has exactly the same behavior as <STRONG>BOOST_ASSERT</STRONG>, except that
the expression that is passed to <STRONG>BOOST_VERIFY</STRONG> is always
evaluated. This is useful when the asserted expression has desirable side
effects; it can also help suppress warnings about unused variables when the
only use of the variable is inside an assertion.</p>
<p><br> <p><br>
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version <small>Copyright <20> 2002, 2007 by Peter Dimov. Distributed under the Boost Software
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or License, Version 1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p> or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
</body> </body>
</html> </html>

View File

@ -334,7 +334,7 @@ with the exact pointer type used in <code>switcher</code>'s constructor.</p>
<h3><a name="contributors">Contributors</a></h3> <h3><a name="contributors">Contributors</a></h3>
<dl> <dl>
<dt><a href="../../people/ed_brey.htm">Ed Brey</a> <dt><a href="http://www.boost.org/people/ed_brey.htm">Ed Brey</a>
<dd>Suggested some interface changes. <dd>Suggested some interface changes.
<dt><a href="http://www.moocat.org">R. Samuel Klatchko</a> (<a <dt><a href="http://www.moocat.org">R. Samuel Klatchko</a> (<a
@ -343,7 +343,7 @@ with the exact pointer type used in <code>switcher</code>'s constructor.</p>
<dd>Invented the idiom of how to use a class member for initializing <dd>Invented the idiom of how to use a class member for initializing
a base class. a base class.
<dt><a href="../../people/dietmar_kuehl.htm">Dietmar Kuehl</a> <dt><a href="http://www.boost.org/people/dietmar_kuehl.htm">Dietmar Kuehl</a>
<dd>Popularized the base-from-member idiom in his <dd>Popularized the base-from-member idiom in his
<a href="http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/">IOStream <a href="http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/">IOStream
example classes</a>. example classes</a>.
@ -353,7 +353,7 @@ with the exact pointer type used in <code>switcher</code>'s constructor.</p>
can be controlled and automated with macros. The implementation uses can be controlled and automated with macros. The implementation uses
the <a href="../preprocessor/index.html">Preprocessor library</a>. the <a href="../preprocessor/index.html">Preprocessor library</a>.
<dt><a href="../../people/daryle_walker.html">Daryle Walker</a> <dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a>
<dd>Started the library. Contributed the test file <cite><a <dd>Started the library. Contributed the test file <cite><a
href="base_from_member_test.cpp">base_from_member_test.cpp</a></cite>. href="base_from_member_test.cpp">base_from_member_test.cpp</a></cite>.
</dl> </dl>

View File

@ -281,7 +281,7 @@ object_id_compare::operator ()
} }
else else
{ {
return a.second->before( *b.second ); return a.second->before( *b.second ) != 0;
} }
} }
} }

647
binary_test.cpp Normal file
View File

@ -0,0 +1,647 @@
/*=============================================================================
Copyright (c) 2006, 2007 Matthew Calabrese
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)
==============================================================================*/
#include <boost/test/minimal.hpp>
#include <boost/utility/binary.hpp>
#include <algorithm>
#include <cstddef>
#ifdef BOOST_MSVC
#pragma warning(disable:4996) // warning C4996: 'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
#endif
/*
Note: This file tests every single valid bit-grouping on its own, and some
random combinations of bit-groupings.
*/
std::size_t const num_random_test_values = 32;
// Note: These hex values should all correspond with the binary array below
unsigned int const random_unsigned_ints_hex[num_random_test_values]
= { 0x0103u, 0x77ebu, 0x5f36u, 0x1f18u, 0xc530u, 0xa73au, 0xd6f8u, 0x0919u
, 0xfbb0u, 0x3e7cu, 0xd0e9u, 0x22c8u, 0x724eu, 0x14fau, 0xd98eu, 0x40b5
, 0xeba0u, 0xfe50u, 0x688au, 0x1b05u, 0x5f9cu, 0xe4fcu, 0xa7b8u, 0xd3acu
, 0x1dddu, 0xbf04u, 0x8352u, 0xe89cu, 0x7506u, 0xe767u, 0xf489u, 0xe167
};
unsigned int const random_unsigned_ints_binary[num_random_test_values]
= { BOOST_BINARY( 0 00010000 0011 ), BOOST_BINARY( 0 11101 1111 101011 )
, BOOST_BINARY( 010111 1100110 1 1 0 ), BOOST_BINARY( 000 1 11110 00 11000 )
, BOOST_BINARY( 110 001010 0110 000 ), BOOST_BINARY( 1010 01110011 1010 )
, BOOST_BINARY( 11 010 1 101111 1000 ), BOOST_BINARY( 0000 100100 0110 01 )
, BOOST_BINARY( 1111 101110 11 0000 ), BOOST_BINARY( 00111110 01111100 )
, BOOST_BINARY( 11 010 000111 01001 ), BOOST_BINARY( 00100 010110 01000 )
, BOOST_BINARY( 01 11001001 001110 ), BOOST_BINARY( 0010 1001111 1010 )
, BOOST_BINARY( 1101 1 00110 0 01110 ), BOOST_BINARY( 100 000 01011010 1 )
, BOOST_BINARY( 11 1010 1110 1000 00 ), BOOST_BINARY( 11111 110010 10000 )
, BOOST_BINARY( 01101 00010 001010 ), BOOST_BINARY( 000 11011 000001 01 )
, BOOST_BINARY( 01 01111 1100111 00 ), BOOST_BINARY( 1 110010 0111111 00 )
, BOOST_BINARY( 101 0011 11 01110 00 ), BOOST_BINARY( 110100 1 110101 100 )
, BOOST_BINARY( 00 1110111 011 101 ), BOOST_BINARY( 1011 1111 00000 100 )
, BOOST_BINARY( 1000 00110 101 0010 ), BOOST_BINARY( 1110 10001 001110 0 )
, BOOST_BINARY( 011 1010100 000 110 ), BOOST_BINARY( 1110 0111 01100 111 )
, BOOST_BINARY( 11110 10010 001001 ), BOOST_BINARY( 11 1000010 1100 111 )
};
unsigned int const unsigned_ints_1_bit[2] =
{ BOOST_BINARY( 0 )
, BOOST_BINARY( 1 )
};
unsigned int const unsigned_ints_2_bits[4] =
{ BOOST_BINARY( 00 )
, BOOST_BINARY( 01 )
, BOOST_BINARY( 10 )
, BOOST_BINARY( 11 )
};
unsigned int const unsigned_ints_3_bits[8] =
{ BOOST_BINARY( 000 )
, BOOST_BINARY( 001 )
, BOOST_BINARY( 010 )
, BOOST_BINARY( 011 )
, BOOST_BINARY( 100 )
, BOOST_BINARY( 101 )
, BOOST_BINARY( 110 )
, BOOST_BINARY( 111 )
};
unsigned int const unsigned_ints_4_bits[16] =
{ BOOST_BINARY( 0000 )
, BOOST_BINARY( 0001 )
, BOOST_BINARY( 0010 )
, BOOST_BINARY( 0011 )
, BOOST_BINARY( 0100 )
, BOOST_BINARY( 0101 )
, BOOST_BINARY( 0110 )
, BOOST_BINARY( 0111 )
, BOOST_BINARY( 1000 )
, BOOST_BINARY( 1001 )
, BOOST_BINARY( 1010 )
, BOOST_BINARY( 1011 )
, BOOST_BINARY( 1100 )
, BOOST_BINARY( 1101 )
, BOOST_BINARY( 1110 )
, BOOST_BINARY( 1111 )
};
unsigned int const unsigned_ints_5_bits[32] =
{ BOOST_BINARY( 00000 )
, BOOST_BINARY( 00001 )
, BOOST_BINARY( 00010 )
, BOOST_BINARY( 00011 )
, BOOST_BINARY( 00100 )
, BOOST_BINARY( 00101 )
, BOOST_BINARY( 00110 )
, BOOST_BINARY( 00111 )
, BOOST_BINARY( 01000 )
, BOOST_BINARY( 01001 )
, BOOST_BINARY( 01010 )
, BOOST_BINARY( 01011 )
, BOOST_BINARY( 01100 )
, BOOST_BINARY( 01101 )
, BOOST_BINARY( 01110 )
, BOOST_BINARY( 01111 )
, BOOST_BINARY( 10000 )
, BOOST_BINARY( 10001 )
, BOOST_BINARY( 10010 )
, BOOST_BINARY( 10011 )
, BOOST_BINARY( 10100 )
, BOOST_BINARY( 10101 )
, BOOST_BINARY( 10110 )
, BOOST_BINARY( 10111 )
, BOOST_BINARY( 11000 )
, BOOST_BINARY( 11001 )
, BOOST_BINARY( 11010 )
, BOOST_BINARY( 11011 )
, BOOST_BINARY( 11100 )
, BOOST_BINARY( 11101 )
, BOOST_BINARY( 11110 )
, BOOST_BINARY( 11111 )
};
unsigned int const unsigned_ints_6_bits[64] =
{ BOOST_BINARY( 000000 )
, BOOST_BINARY( 000001 )
, BOOST_BINARY( 000010 )
, BOOST_BINARY( 000011 )
, BOOST_BINARY( 000100 )
, BOOST_BINARY( 000101 )
, BOOST_BINARY( 000110 )
, BOOST_BINARY( 000111 )
, BOOST_BINARY( 001000 )
, BOOST_BINARY( 001001 )
, BOOST_BINARY( 001010 )
, BOOST_BINARY( 001011 )
, BOOST_BINARY( 001100 )
, BOOST_BINARY( 001101 )
, BOOST_BINARY( 001110 )
, BOOST_BINARY( 001111 )
, BOOST_BINARY( 010000 )
, BOOST_BINARY( 010001 )
, BOOST_BINARY( 010010 )
, BOOST_BINARY( 010011 )
, BOOST_BINARY( 010100 )
, BOOST_BINARY( 010101 )
, BOOST_BINARY( 010110 )
, BOOST_BINARY( 010111 )
, BOOST_BINARY( 011000 )
, BOOST_BINARY( 011001 )
, BOOST_BINARY( 011010 )
, BOOST_BINARY( 011011 )
, BOOST_BINARY( 011100 )
, BOOST_BINARY( 011101 )
, BOOST_BINARY( 011110 )
, BOOST_BINARY( 011111 )
, BOOST_BINARY( 100000 )
, BOOST_BINARY( 100001 )
, BOOST_BINARY( 100010 )
, BOOST_BINARY( 100011 )
, BOOST_BINARY( 100100 )
, BOOST_BINARY( 100101 )
, BOOST_BINARY( 100110 )
, BOOST_BINARY( 100111 )
, BOOST_BINARY( 101000 )
, BOOST_BINARY( 101001 )
, BOOST_BINARY( 101010 )
, BOOST_BINARY( 101011 )
, BOOST_BINARY( 101100 )
, BOOST_BINARY( 101101 )
, BOOST_BINARY( 101110 )
, BOOST_BINARY( 101111 )
, BOOST_BINARY( 110000 )
, BOOST_BINARY( 110001 )
, BOOST_BINARY( 110010 )
, BOOST_BINARY( 110011 )
, BOOST_BINARY( 110100 )
, BOOST_BINARY( 110101 )
, BOOST_BINARY( 110110 )
, BOOST_BINARY( 110111 )
, BOOST_BINARY( 111000 )
, BOOST_BINARY( 111001 )
, BOOST_BINARY( 111010 )
, BOOST_BINARY( 111011 )
, BOOST_BINARY( 111100 )
, BOOST_BINARY( 111101 )
, BOOST_BINARY( 111110 )
, BOOST_BINARY( 111111 )
};
unsigned int const unsigned_ints_7_bits[128] =
{ BOOST_BINARY( 0000000 )
, BOOST_BINARY( 0000001 )
, BOOST_BINARY( 0000010 )
, BOOST_BINARY( 0000011 )
, BOOST_BINARY( 0000100 )
, BOOST_BINARY( 0000101 )
, BOOST_BINARY( 0000110 )
, BOOST_BINARY( 0000111 )
, BOOST_BINARY( 0001000 )
, BOOST_BINARY( 0001001 )
, BOOST_BINARY( 0001010 )
, BOOST_BINARY( 0001011 )
, BOOST_BINARY( 0001100 )
, BOOST_BINARY( 0001101 )
, BOOST_BINARY( 0001110 )
, BOOST_BINARY( 0001111 )
, BOOST_BINARY( 0010000 )
, BOOST_BINARY( 0010001 )
, BOOST_BINARY( 0010010 )
, BOOST_BINARY( 0010011 )
, BOOST_BINARY( 0010100 )
, BOOST_BINARY( 0010101 )
, BOOST_BINARY( 0010110 )
, BOOST_BINARY( 0010111 )
, BOOST_BINARY( 0011000 )
, BOOST_BINARY( 0011001 )
, BOOST_BINARY( 0011010 )
, BOOST_BINARY( 0011011 )
, BOOST_BINARY( 0011100 )
, BOOST_BINARY( 0011101 )
, BOOST_BINARY( 0011110 )
, BOOST_BINARY( 0011111 )
, BOOST_BINARY( 0100000 )
, BOOST_BINARY( 0100001 )
, BOOST_BINARY( 0100010 )
, BOOST_BINARY( 0100011 )
, BOOST_BINARY( 0100100 )
, BOOST_BINARY( 0100101 )
, BOOST_BINARY( 0100110 )
, BOOST_BINARY( 0100111 )
, BOOST_BINARY( 0101000 )
, BOOST_BINARY( 0101001 )
, BOOST_BINARY( 0101010 )
, BOOST_BINARY( 0101011 )
, BOOST_BINARY( 0101100 )
, BOOST_BINARY( 0101101 )
, BOOST_BINARY( 0101110 )
, BOOST_BINARY( 0101111 )
, BOOST_BINARY( 0110000 )
, BOOST_BINARY( 0110001 )
, BOOST_BINARY( 0110010 )
, BOOST_BINARY( 0110011 )
, BOOST_BINARY( 0110100 )
, BOOST_BINARY( 0110101 )
, BOOST_BINARY( 0110110 )
, BOOST_BINARY( 0110111 )
, BOOST_BINARY( 0111000 )
, BOOST_BINARY( 0111001 )
, BOOST_BINARY( 0111010 )
, BOOST_BINARY( 0111011 )
, BOOST_BINARY( 0111100 )
, BOOST_BINARY( 0111101 )
, BOOST_BINARY( 0111110 )
, BOOST_BINARY( 0111111 )
, BOOST_BINARY( 1000000 )
, BOOST_BINARY( 1000001 )
, BOOST_BINARY( 1000010 )
, BOOST_BINARY( 1000011 )
, BOOST_BINARY( 1000100 )
, BOOST_BINARY( 1000101 )
, BOOST_BINARY( 1000110 )
, BOOST_BINARY( 1000111 )
, BOOST_BINARY( 1001000 )
, BOOST_BINARY( 1001001 )
, BOOST_BINARY( 1001010 )
, BOOST_BINARY( 1001011 )
, BOOST_BINARY( 1001100 )
, BOOST_BINARY( 1001101 )
, BOOST_BINARY( 1001110 )
, BOOST_BINARY( 1001111 )
, BOOST_BINARY( 1010000 )
, BOOST_BINARY( 1010001 )
, BOOST_BINARY( 1010010 )
, BOOST_BINARY( 1010011 )
, BOOST_BINARY( 1010100 )
, BOOST_BINARY( 1010101 )
, BOOST_BINARY( 1010110 )
, BOOST_BINARY( 1010111 )
, BOOST_BINARY( 1011000 )
, BOOST_BINARY( 1011001 )
, BOOST_BINARY( 1011010 )
, BOOST_BINARY( 1011011 )
, BOOST_BINARY( 1011100 )
, BOOST_BINARY( 1011101 )
, BOOST_BINARY( 1011110 )
, BOOST_BINARY( 1011111 )
, BOOST_BINARY( 1100000 )
, BOOST_BINARY( 1100001 )
, BOOST_BINARY( 1100010 )
, BOOST_BINARY( 1100011 )
, BOOST_BINARY( 1100100 )
, BOOST_BINARY( 1100101 )
, BOOST_BINARY( 1100110 )
, BOOST_BINARY( 1100111 )
, BOOST_BINARY( 1101000 )
, BOOST_BINARY( 1101001 )
, BOOST_BINARY( 1101010 )
, BOOST_BINARY( 1101011 )
, BOOST_BINARY( 1101100 )
, BOOST_BINARY( 1101101 )
, BOOST_BINARY( 1101110 )
, BOOST_BINARY( 1101111 )
, BOOST_BINARY( 1110000 )
, BOOST_BINARY( 1110001 )
, BOOST_BINARY( 1110010 )
, BOOST_BINARY( 1110011 )
, BOOST_BINARY( 1110100 )
, BOOST_BINARY( 1110101 )
, BOOST_BINARY( 1110110 )
, BOOST_BINARY( 1110111 )
, BOOST_BINARY( 1111000 )
, BOOST_BINARY( 1111001 )
, BOOST_BINARY( 1111010 )
, BOOST_BINARY( 1111011 )
, BOOST_BINARY( 1111100 )
, BOOST_BINARY( 1111101 )
, BOOST_BINARY( 1111110 )
, BOOST_BINARY( 1111111 )
};
unsigned int const unsigned_ints_8_bits[256] =
{ BOOST_BINARY( 00000000 )
, BOOST_BINARY( 00000001 )
, BOOST_BINARY( 00000010 )
, BOOST_BINARY( 00000011 )
, BOOST_BINARY( 00000100 )
, BOOST_BINARY( 00000101 )
, BOOST_BINARY( 00000110 )
, BOOST_BINARY( 00000111 )
, BOOST_BINARY( 00001000 )
, BOOST_BINARY( 00001001 )
, BOOST_BINARY( 00001010 )
, BOOST_BINARY( 00001011 )
, BOOST_BINARY( 00001100 )
, BOOST_BINARY( 00001101 )
, BOOST_BINARY( 00001110 )
, BOOST_BINARY( 00001111 )
, BOOST_BINARY( 00010000 )
, BOOST_BINARY( 00010001 )
, BOOST_BINARY( 00010010 )
, BOOST_BINARY( 00010011 )
, BOOST_BINARY( 00010100 )
, BOOST_BINARY( 00010101 )
, BOOST_BINARY( 00010110 )
, BOOST_BINARY( 00010111 )
, BOOST_BINARY( 00011000 )
, BOOST_BINARY( 00011001 )
, BOOST_BINARY( 00011010 )
, BOOST_BINARY( 00011011 )
, BOOST_BINARY( 00011100 )
, BOOST_BINARY( 00011101 )
, BOOST_BINARY( 00011110 )
, BOOST_BINARY( 00011111 )
, BOOST_BINARY( 00100000 )
, BOOST_BINARY( 00100001 )
, BOOST_BINARY( 00100010 )
, BOOST_BINARY( 00100011 )
, BOOST_BINARY( 00100100 )
, BOOST_BINARY( 00100101 )
, BOOST_BINARY( 00100110 )
, BOOST_BINARY( 00100111 )
, BOOST_BINARY( 00101000 )
, BOOST_BINARY( 00101001 )
, BOOST_BINARY( 00101010 )
, BOOST_BINARY( 00101011 )
, BOOST_BINARY( 00101100 )
, BOOST_BINARY( 00101101 )
, BOOST_BINARY( 00101110 )
, BOOST_BINARY( 00101111 )
, BOOST_BINARY( 00110000 )
, BOOST_BINARY( 00110001 )
, BOOST_BINARY( 00110010 )
, BOOST_BINARY( 00110011 )
, BOOST_BINARY( 00110100 )
, BOOST_BINARY( 00110101 )
, BOOST_BINARY( 00110110 )
, BOOST_BINARY( 00110111 )
, BOOST_BINARY( 00111000 )
, BOOST_BINARY( 00111001 )
, BOOST_BINARY( 00111010 )
, BOOST_BINARY( 00111011 )
, BOOST_BINARY( 00111100 )
, BOOST_BINARY( 00111101 )
, BOOST_BINARY( 00111110 )
, BOOST_BINARY( 00111111 )
, BOOST_BINARY( 01000000 )
, BOOST_BINARY( 01000001 )
, BOOST_BINARY( 01000010 )
, BOOST_BINARY( 01000011 )
, BOOST_BINARY( 01000100 )
, BOOST_BINARY( 01000101 )
, BOOST_BINARY( 01000110 )
, BOOST_BINARY( 01000111 )
, BOOST_BINARY( 01001000 )
, BOOST_BINARY( 01001001 )
, BOOST_BINARY( 01001010 )
, BOOST_BINARY( 01001011 )
, BOOST_BINARY( 01001100 )
, BOOST_BINARY( 01001101 )
, BOOST_BINARY( 01001110 )
, BOOST_BINARY( 01001111 )
, BOOST_BINARY( 01010000 )
, BOOST_BINARY( 01010001 )
, BOOST_BINARY( 01010010 )
, BOOST_BINARY( 01010011 )
, BOOST_BINARY( 01010100 )
, BOOST_BINARY( 01010101 )
, BOOST_BINARY( 01010110 )
, BOOST_BINARY( 01010111 )
, BOOST_BINARY( 01011000 )
, BOOST_BINARY( 01011001 )
, BOOST_BINARY( 01011010 )
, BOOST_BINARY( 01011011 )
, BOOST_BINARY( 01011100 )
, BOOST_BINARY( 01011101 )
, BOOST_BINARY( 01011110 )
, BOOST_BINARY( 01011111 )
, BOOST_BINARY( 01100000 )
, BOOST_BINARY( 01100001 )
, BOOST_BINARY( 01100010 )
, BOOST_BINARY( 01100011 )
, BOOST_BINARY( 01100100 )
, BOOST_BINARY( 01100101 )
, BOOST_BINARY( 01100110 )
, BOOST_BINARY( 01100111 )
, BOOST_BINARY( 01101000 )
, BOOST_BINARY( 01101001 )
, BOOST_BINARY( 01101010 )
, BOOST_BINARY( 01101011 )
, BOOST_BINARY( 01101100 )
, BOOST_BINARY( 01101101 )
, BOOST_BINARY( 01101110 )
, BOOST_BINARY( 01101111 )
, BOOST_BINARY( 01110000 )
, BOOST_BINARY( 01110001 )
, BOOST_BINARY( 01110010 )
, BOOST_BINARY( 01110011 )
, BOOST_BINARY( 01110100 )
, BOOST_BINARY( 01110101 )
, BOOST_BINARY( 01110110 )
, BOOST_BINARY( 01110111 )
, BOOST_BINARY( 01111000 )
, BOOST_BINARY( 01111001 )
, BOOST_BINARY( 01111010 )
, BOOST_BINARY( 01111011 )
, BOOST_BINARY( 01111100 )
, BOOST_BINARY( 01111101 )
, BOOST_BINARY( 01111110 )
, BOOST_BINARY( 01111111 )
, BOOST_BINARY( 10000000 )
, BOOST_BINARY( 10000001 )
, BOOST_BINARY( 10000010 )
, BOOST_BINARY( 10000011 )
, BOOST_BINARY( 10000100 )
, BOOST_BINARY( 10000101 )
, BOOST_BINARY( 10000110 )
, BOOST_BINARY( 10000111 )
, BOOST_BINARY( 10001000 )
, BOOST_BINARY( 10001001 )
, BOOST_BINARY( 10001010 )
, BOOST_BINARY( 10001011 )
, BOOST_BINARY( 10001100 )
, BOOST_BINARY( 10001101 )
, BOOST_BINARY( 10001110 )
, BOOST_BINARY( 10001111 )
, BOOST_BINARY( 10010000 )
, BOOST_BINARY( 10010001 )
, BOOST_BINARY( 10010010 )
, BOOST_BINARY( 10010011 )
, BOOST_BINARY( 10010100 )
, BOOST_BINARY( 10010101 )
, BOOST_BINARY( 10010110 )
, BOOST_BINARY( 10010111 )
, BOOST_BINARY( 10011000 )
, BOOST_BINARY( 10011001 )
, BOOST_BINARY( 10011010 )
, BOOST_BINARY( 10011011 )
, BOOST_BINARY( 10011100 )
, BOOST_BINARY( 10011101 )
, BOOST_BINARY( 10011110 )
, BOOST_BINARY( 10011111 )
, BOOST_BINARY( 10100000 )
, BOOST_BINARY( 10100001 )
, BOOST_BINARY( 10100010 )
, BOOST_BINARY( 10100011 )
, BOOST_BINARY( 10100100 )
, BOOST_BINARY( 10100101 )
, BOOST_BINARY( 10100110 )
, BOOST_BINARY( 10100111 )
, BOOST_BINARY( 10101000 )
, BOOST_BINARY( 10101001 )
, BOOST_BINARY( 10101010 )
, BOOST_BINARY( 10101011 )
, BOOST_BINARY( 10101100 )
, BOOST_BINARY( 10101101 )
, BOOST_BINARY( 10101110 )
, BOOST_BINARY( 10101111 )
, BOOST_BINARY( 10110000 )
, BOOST_BINARY( 10110001 )
, BOOST_BINARY( 10110010 )
, BOOST_BINARY( 10110011 )
, BOOST_BINARY( 10110100 )
, BOOST_BINARY( 10110101 )
, BOOST_BINARY( 10110110 )
, BOOST_BINARY( 10110111 )
, BOOST_BINARY( 10111000 )
, BOOST_BINARY( 10111001 )
, BOOST_BINARY( 10111010 )
, BOOST_BINARY( 10111011 )
, BOOST_BINARY( 10111100 )
, BOOST_BINARY( 10111101 )
, BOOST_BINARY( 10111110 )
, BOOST_BINARY( 10111111 )
, BOOST_BINARY( 11000000 )
, BOOST_BINARY( 11000001 )
, BOOST_BINARY( 11000010 )
, BOOST_BINARY( 11000011 )
, BOOST_BINARY( 11000100 )
, BOOST_BINARY( 11000101 )
, BOOST_BINARY( 11000110 )
, BOOST_BINARY( 11000111 )
, BOOST_BINARY( 11001000 )
, BOOST_BINARY( 11001001 )
, BOOST_BINARY( 11001010 )
, BOOST_BINARY( 11001011 )
, BOOST_BINARY( 11001100 )
, BOOST_BINARY( 11001101 )
, BOOST_BINARY( 11001110 )
, BOOST_BINARY( 11001111 )
, BOOST_BINARY( 11010000 )
, BOOST_BINARY( 11010001 )
, BOOST_BINARY( 11010010 )
, BOOST_BINARY( 11010011 )
, BOOST_BINARY( 11010100 )
, BOOST_BINARY( 11010101 )
, BOOST_BINARY( 11010110 )
, BOOST_BINARY( 11010111 )
, BOOST_BINARY( 11011000 )
, BOOST_BINARY( 11011001 )
, BOOST_BINARY( 11011010 )
, BOOST_BINARY( 11011011 )
, BOOST_BINARY( 11011100 )
, BOOST_BINARY( 11011101 )
, BOOST_BINARY( 11011110 )
, BOOST_BINARY( 11011111 )
, BOOST_BINARY( 11100000 )
, BOOST_BINARY( 11100001 )
, BOOST_BINARY( 11100010 )
, BOOST_BINARY( 11100011 )
, BOOST_BINARY( 11100100 )
, BOOST_BINARY( 11100101 )
, BOOST_BINARY( 11100110 )
, BOOST_BINARY( 11100111 )
, BOOST_BINARY( 11101000 )
, BOOST_BINARY( 11101001 )
, BOOST_BINARY( 11101010 )
, BOOST_BINARY( 11101011 )
, BOOST_BINARY( 11101100 )
, BOOST_BINARY( 11101101 )
, BOOST_BINARY( 11101110 )
, BOOST_BINARY( 11101111 )
, BOOST_BINARY( 11110000 )
, BOOST_BINARY( 11110001 )
, BOOST_BINARY( 11110010 )
, BOOST_BINARY( 11110011 )
, BOOST_BINARY( 11110100 )
, BOOST_BINARY( 11110101 )
, BOOST_BINARY( 11110110 )
, BOOST_BINARY( 11110111 )
, BOOST_BINARY( 11111000 )
, BOOST_BINARY( 11111001 )
, BOOST_BINARY( 11111010 )
, BOOST_BINARY( 11111011 )
, BOOST_BINARY( 11111100 )
, BOOST_BINARY( 11111101 )
, BOOST_BINARY( 11111110 )
, BOOST_BINARY( 11111111 )
};
struct left_is_not_one_less_than_right
{
bool operator ()( unsigned int left, unsigned int right ) const
{
return right != left + 1;
}
};
template< std::size_t Size >
bool is_ascending_from_0_array( unsigned int const (&array)[Size] )
{
unsigned int const* const curr = array,
* const end = array + Size;
return ( *curr == 0 )
&& ( std::adjacent_find( curr, end
, left_is_not_one_less_than_right()
)
== end
);
}
std::size_t const unsigned_int_id = 1,
unsigned_long_int_id = 2;
typedef char (&unsigned_int_id_type)[unsigned_int_id];
typedef char (&unsigned_long_int_id_type)[unsigned_long_int_id];
// Note: Functions only used for type checking
unsigned_int_id_type binary_type_checker( unsigned int );
unsigned_long_int_id_type binary_type_checker( unsigned long int );
int test_main( int, char *[] )
{
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_1_bit ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_2_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_3_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_4_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_5_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_6_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_7_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_8_bits ) );
BOOST_CHECK( std::equal( &random_unsigned_ints_hex[0]
, random_unsigned_ints_hex + num_random_test_values
, &random_unsigned_ints_binary[0]
)
);
BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_U( 110100 1010 ) ) )
== unsigned_int_id
);
BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_UL( 11110 ) ) )
== unsigned_long_int_id
);
BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_LU( 10 0001 ) ) )
== unsigned_long_int_id
);
return 0;
}

View File

@ -740,26 +740,16 @@ specialisation).</p>
<p>Revised 01 September 2000</p> <p>Revised 01 September 2000</p>
<p><EFBFBD> Copyright boost.org 2000. Permission to copy, use, modify, <p>
sell and distribute this document is granted provided this Copyright 2000 Steve Cleary, Beman Dawes, Howard
copyright notice appears in all copies. This document is provided Hinnant and John Maddock. <br/>
&quot;as is&quot; without express or implied warranty, and with Use, modification and distribution are subject to the
no claim as to its suitability for any purpose.</p> Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
<p>Based on contributions by Steve Cleary, Beman Dawes, Howard or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Hinnant and John Maddock.</p> http://www.boost.org/LICENSE_1_0.txt
</a>).
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John </p>
Maddock</a>, the latest version of this file can be found at <a
href="http://www.boost.org/">www.boost.org</a>, and the boost
discussion list at <a
href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p>
<p>.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body> </body>
</html> </html>

View File

@ -21,6 +21,10 @@
#include <libs/type_traits/test/test.hpp> #include <libs/type_traits/test/test.hpp>
#include <libs/type_traits/test/check_type.hpp> #include <libs/type_traits/test/check_type.hpp>
#ifdef BOOST_MSVC
#pragma warning(disable:4181) // : warning C4181: qualifier applied to reference type; ignored
#endif
// a way prevent warnings for unused variables // a way prevent warnings for unused variables
template<class T> inline void unused_variable(const T&) {} template<class T> inline void unused_variable(const T&) {}
@ -52,7 +56,8 @@ struct contained
const_reference const_get()const { return v_; } const_reference const_get()const { return v_; }
// pass value: // pass value:
void call(param_type){} void call(param_type){}
private:
contained& operator=(const contained&);
}; };
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
@ -77,6 +82,8 @@ struct contained<T[N]>
reference get() { return v_; } reference get() { return v_; }
const_reference const_get()const { return v_; } const_reference const_get()const { return v_; }
void call(param_type){} void call(param_type){}
private:
contained& operator=(const contained&);
}; };
#endif #endif
@ -197,7 +204,7 @@ struct comparible_UDT
bool operator == (const comparible_UDT& v){ return v.i_ == i_; } bool operator == (const comparible_UDT& v){ return v.i_ == i_; }
}; };
int main(int argc, char *argv[ ]) int main()
{ {
call_traits_checker<comparible_UDT> c1; call_traits_checker<comparible_UDT> c1;
comparible_UDT u; comparible_UDT u;

View File

@ -3,7 +3,7 @@
<title>Header </title> <title>Header </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot"> <meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<boostcompressed_pair.hpp> <boostcompressed_pair.hpp>
</head> </head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080"> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">
@ -59,17 +59,18 @@ public:
empty type, then assigning to that member will produce memory corruption, empty type, then assigning to that member will produce memory corruption,
unless the empty type has a "do nothing" assignment operator defined. This is unless the empty type has a "do nothing" assignment operator defined. This is
due to a bug in the way VC6 generates implicit assignment operators.</p> due to a bug in the way VC6 generates implicit assignment operators.</p>
<hr> <h3>Acknowledgements</h3>
<p>Revised 08 May 2001</p>
<p><EFBFBD> Copyright boost.org 2000. Permission to copy, use, modify, sell and
distribute this document is granted provided this copyright notice appears in
all copies. This document is provided "as is" without express or implied
warranty, and with no claim as to its suitability for any purpose.</p>
<p>Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John <p>Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John
Maddock.</p> Maddock.</p>
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John Maddock</a>, the <p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John Maddock</a>, the
latest version of this file can be found at <a href="http://www.boost.org">www.boost.org</a>, latest version of this file can be found at <a href="http://www.boost.org">www.boost.org</a>,
and the boost discussion list at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p> and the boost discussion list at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p>
<p>&nbsp;</p> <hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->07 November 2007<!--webbot bot="Timestamp" endspan i-checksum="40338" --></p>
<p><EFBFBD> Copyright Beman Dawes, 2000.</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
</body> </body>
</html> </html>

View File

@ -366,17 +366,18 @@ David Vandevoorde and Nicolai&nbsp;M. Josuttis.
<EM>C++ Templates: The Complete Guide</EM>. <EM>C++ Templates: The Complete Guide</EM>.
Addison-Wesley, 2002.</DL> Addison-Wesley, 2002.</DL>
<hr/>
<p>Copyright Jaakko J&auml;rvi, Jeremiah Willcock and Andrew Lumsdaine<BR>
<hr></hr>
<B>Contributed by:</B> <BR>
Jaakko J&auml;rvi, Jeremiah Willcock and Andrew Lumsdaine<BR>
<EM>{jajarvi|jewillco|lums}@osl.iu.edu</EM><BR> <EM>{jajarvi|jewillco|lums}@osl.iu.edu</EM><BR>
Indiana University<BR> Indiana University<BR>
Open Systems Lab Open Systems Lab<br/>
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<!--HTMLFOOT--> <!--HTMLFOOT-->
<!--ENDHTML--> <!--ENDHTML-->
<!--FOOTER--> <!--FOOTER-->

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -146,14 +146,14 @@ int main()
<hr> <hr>
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
height="31" width="88"></a></p> height="31" width="88"></a></p>
<p>Revised <p>Revised
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p> <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
<p><i>Copyright &copy; 2001 <a href= <p><i>Copyright &copy; 2001 <a href=
"../../people/jens_maurer.htm">Jens Maurer</a></i></p> "http://www.boost.org/people/jens_maurer.htm">Jens Maurer</a></i></p>
<p><i>Distributed under the Boost Software License, Version 1.0. (See <p><i>Distributed under the Boost Software License, Version 1.0. (See
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or

View File

@ -99,7 +99,7 @@ directly to the container:</p>
<H2><A NAME="framework"></A>Framework</H2> <H2><A NAME="framework"></A>Framework</H2>
<p> <p>
This library proposes a framework to allow some containers to directly contruct contained objects in-place without requiring This library proposes a framework to allow some containers to directly contruct contained objects in-place without requiring
the entire set of constructor overloads ftom the contained type. It also allows the container to remove the CopyConstuctible the entire set of constructor overloads from the contained type. It also allows the container to remove the CopyConstuctible
requirement from the contained type since objects can be directly constructed in-place without need of a copy.<br> requirement from the contained type since objects can be directly constructed in-place without need of a copy.<br>
The only requirement on the container is that it must provide proper storage (that is, correctly aligned and sized). The only requirement on the container is that it must provide proper storage (that is, correctly aligned and sized).
Naturally, the container will typically support uninitialized storage to avoid the in-place construction to override Naturally, the container will typically support uninitialized storage to avoid the in-place construction to override
@ -117,7 +117,7 @@ The following simplified example shows the basic idea. A complete example follow
<pre>struct C <pre>struct C
{ {
template&lt;class InPlaceFactory&gt; template&lt;class InPlaceFactory&gt;
C ( InPlaceFactory const& aFactoty ) C ( InPlaceFactory const& aFactory )
: :
contained_ ( uninitialized_storage() ) contained_ ( uninitialized_storage() )
{ {
@ -293,4 +293,4 @@ the latest version of this file can be found at <A
HREF="http://www.boost.org">www.boost.org</A>, and the boost HREF="http://www.boost.org">www.boost.org</A>, and the boost
<A HREF="http://www.boost.org/more/mailing_lists.htm#main">discussion lists</A></P> <A HREF="http://www.boost.org/more/mailing_lists.htm#main">discussion lists</A></P>
</BODY> </BODY>
</HTML> </HTML>

View File

@ -2,6 +2,7 @@
// boost/assert.hpp - BOOST_ASSERT(expr) // boost/assert.hpp - BOOST_ASSERT(expr)
// //
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2007 Peter Dimov
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@ -35,3 +36,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
# define BOOST_ASSERT(expr) assert(expr) # define BOOST_ASSERT(expr) assert(expr)
#endif #endif
#undef BOOST_VERIFY
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
# define BOOST_VERIFY(expr) ((void)(expr))
#else
# define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
#endif

View File

@ -92,7 +92,7 @@ struct call_traits<T&>
typedef T& param_type; // hh removed const typedef T& param_type; // hh removed const
}; };
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 ) ) #if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 )
// these are illegal specialisations; cv-qualifies applied to // these are illegal specialisations; cv-qualifies applied to
// references have no effect according to [8.3.2p1], // references have no effect according to [8.3.2p1],
// C++ Builder requires them though as it treats cv-qualified // C++ Builder requires them though as it treats cv-qualified

View File

@ -0,0 +1,11 @@
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//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)
#ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492
#define UUID_1D94A7C6054E11DB9804B622A1EF5492
#error The header <boost/exception.hpp> has been deprecated. Please #include <boost/exception/all.hpp> instead.
#endif

View File

@ -8,6 +8,9 @@
// See http://www.boost.org/libs/utility/operators.htm for documentation. // See http://www.boost.org/libs/utility/operators.htm for documentation.
// Revision History // Revision History
// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey)
// 03 Apr 08 Make sure "convertible to bool" is sufficient
// for T::operator<, etc. (Daniel Frey)
// 24 May 07 Changed empty_base to depend on T, see // 24 May 07 Changed empty_base to depend on T, see
// http://svn.boost.org/trac/boost/ticket/979 // http://svn.boost.org/trac/boost/ticket/979
// 21 Oct 02 Modified implementation of operators to allow compilers with a // 21 Oct 02 Modified implementation of operators to allow compilers with a
@ -124,34 +127,34 @@ namespace boost
template <class T, class U, class B = ::boost::detail::empty_base<T> > template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct less_than_comparable2 : B struct less_than_comparable2 : B
{ {
friend bool operator<=(const T& x, const U& y) { return !(x > y); } friend bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
friend bool operator>=(const T& x, const U& y) { return !(x < y); } friend bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
friend bool operator>(const U& x, const T& y) { return y < x; } friend bool operator>(const U& x, const T& y) { return y < x; }
friend bool operator<(const U& x, const T& y) { return y > x; } friend bool operator<(const U& x, const T& y) { return y > x; }
friend bool operator<=(const U& x, const T& y) { return !(y < x); } friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
friend bool operator>=(const U& x, const T& y) { return !(y > x); } friend bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
struct less_than_comparable1 : B struct less_than_comparable1 : B
{ {
friend bool operator>(const T& x, const T& y) { return y < x; } friend bool operator>(const T& x, const T& y) { return y < x; }
friend bool operator<=(const T& x, const T& y) { return !(y < x); } friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
friend bool operator>=(const T& x, const T& y) { return !(x < y); } friend bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
}; };
template <class T, class U, class B = ::boost::detail::empty_base<T> > template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct equality_comparable2 : B struct equality_comparable2 : B
{ {
friend bool operator==(const U& y, const T& x) { return x == y; } friend bool operator==(const U& y, const T& x) { return x == y; }
friend bool operator!=(const U& y, const T& x) { return !(x == y); } friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
friend bool operator!=(const T& y, const U& x) { return !(y == x); } friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
struct equality_comparable1 : B struct equality_comparable1 : B
{ {
friend bool operator!=(const T& x, const T& y) { return !(x == y); } friend bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
}; };
// A macro which produces "name_2left" from "name". // A macro which produces "name_2left" from "name".
@ -356,7 +359,7 @@ struct equivalent2 : B
{ {
friend bool operator==(const T& x, const U& y) friend bool operator==(const T& x, const U& y)
{ {
return !(x < y) && !(x > y); return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
} }
}; };
@ -365,7 +368,7 @@ struct equivalent1 : B
{ {
friend bool operator==(const T&x, const T&y) friend bool operator==(const T&x, const T&y)
{ {
return !(x < y) && !(y < x); return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
} }
}; };
@ -373,17 +376,17 @@ template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct partially_ordered2 : B struct partially_ordered2 : B
{ {
friend bool operator<=(const T& x, const U& y) friend bool operator<=(const T& x, const U& y)
{ return (x < y) || (x == y); } { return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const U& y) friend bool operator>=(const T& x, const U& y)
{ return (x > y) || (x == y); } { return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
friend bool operator>(const U& x, const T& y) friend bool operator>(const U& x, const T& y)
{ return y < x; } { return y < x; }
friend bool operator<(const U& x, const T& y) friend bool operator<(const U& x, const T& y)
{ return y > x; } { return y > x; }
friend bool operator<=(const U& x, const T& y) friend bool operator<=(const U& x, const T& y)
{ return (y > x) || (y == x); } { return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
friend bool operator>=(const U& x, const T& y) friend bool operator>=(const U& x, const T& y)
{ return (y < x) || (y == x); } { return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
@ -392,9 +395,9 @@ struct partially_ordered1 : B
friend bool operator>(const T& x, const T& y) friend bool operator>(const T& x, const T& y)
{ return y < x; } { return y < x; }
friend bool operator<=(const T& x, const T& y) friend bool operator<=(const T& x, const T& y)
{ return (x < y) || (x == y); } { return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const T& y) friend bool operator>=(const T& x, const T& y)
{ return (y < x) || (x == y); } { return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
}; };
// Combined operator classes (contributed by Daryle Walker) ----------------// // Combined operator classes (contributed by Daryle Walker) ----------------//
@ -580,7 +583,35 @@ struct ordered_euclidian_ring_operators1
: totally_ordered1<T : totally_ordered1<T
, euclidian_ring_operators1<T, B , euclidian_ring_operators1<T, B
> > {}; > > {};
template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct euclidean_ring_operators2
: ring_operators2<T, U
, dividable2<T, U
, dividable2_left<T, U
, modable2<T, U
, modable2_left<T, U, B
> > > > > {};
template <class T, class B = ::boost::detail::empty_base<T> >
struct euclidean_ring_operators1
: ring_operators1<T
, dividable1<T
, modable1<T, B
> > > {};
template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct ordered_euclidean_ring_operators2
: totally_ordered2<T, U
, euclidean_ring_operators2<T, U, B
> > {};
template <class T, class B = ::boost::detail::empty_base<T> >
struct ordered_euclidean_ring_operators1
: totally_ordered1<T
, euclidean_ring_operators1<T, B
> > {};
template <class T, class P, class B = ::boost::detail::empty_base<T> > template <class T, class P, class B = ::boost::detail::empty_base<T> >
struct input_iteratable struct input_iteratable
: equality_comparable1<T : equality_comparable1<T
@ -837,6 +868,8 @@ BOOST_OPERATOR_TEMPLATE(field_operators)
BOOST_OPERATOR_TEMPLATE(ordered_field_operators) BOOST_OPERATOR_TEMPLATE(ordered_field_operators)
BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators) BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators)
BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators) BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators)
BOOST_OPERATOR_TEMPLATE(euclidean_ring_operators)
BOOST_OPERATOR_TEMPLATE(ordered_euclidean_ring_operators)
BOOST_OPERATOR_TEMPLATE2(input_iteratable) BOOST_OPERATOR_TEMPLATE2(input_iteratable)
BOOST_OPERATOR_TEMPLATE1(output_iteratable) BOOST_OPERATOR_TEMPLATE1(output_iteratable)
BOOST_OPERATOR_TEMPLATE2(forward_iteratable) BOOST_OPERATOR_TEMPLATE2(forward_iteratable)

View File

@ -15,7 +15,7 @@
// //
// ref.hpp - ref/cref, useful helper functions // ref.hpp - ref/cref, useful helper functions
// //
// Copyright (C) 1999, 2000 Jaakko J<EFBFBD>rvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2001, 2002 Peter Dimov // Copyright (C) 2001, 2002 Peter Dimov
// Copyright (C) 2002 David Abrahams // Copyright (C) 2002 David Abrahams
// //
@ -173,6 +173,17 @@ class unwrap_reference
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T> inline typename unwrap_reference<T>::type&
unwrap_ref(T& t)
{
return t;
}
template<class T> inline T* get_pointer( reference_wrapper<T> const & r )
{
return r.get_pointer();
}
} // namespace boost } // namespace boost
#endif // #ifndef BOOST_REF_HPP_INCLUDED #endif // #ifndef BOOST_REF_HPP_INCLUDED

12
include/boost/swap.hpp Normal file
View File

@ -0,0 +1,12 @@
// Copyright (C) 2007 Joseph Gauterin
//
// 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)
#ifndef BOOST_SWAP_HPP
#define BOOST_SWAP_HPP
#include "boost/utility/swap.hpp"
#endif

View File

@ -10,7 +10,8 @@
#define BOOST_UTILITY_HPP #define BOOST_UTILITY_HPP
#include <boost/utility/addressof.hpp> #include <boost/utility/addressof.hpp>
#include <boost/utility/base_from_member.hpp> #include <boost/utility/base_from_member.hpp>
#include <boost/utility/binary.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/checked_delete.hpp> #include <boost/checked_delete.hpp>
#include <boost/next_prior.hpp> #include <boost/next_prior.hpp>

View File

@ -1,6 +1,7 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com) // Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu) // Douglas Gregor (gregod@cs.rpi.edu)
// Peter Dimov //
// Copyright (C) 2002, 2008 Peter Dimov
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@ -14,32 +15,75 @@
# include <boost/config.hpp> # include <boost/config.hpp>
# include <boost/detail/workaround.hpp> # include <boost/detail/workaround.hpp>
namespace boost { namespace boost
{
// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov) namespace detail
{
// VC7 strips const from nested classes unless we add indirection here template<class T> struct addr_impl_ref
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) {
T & v_;
template<class T> struct _addp inline addr_impl_ref( T & v ): v_( v ) {}
inline operator T& () const { return v_; }
private:
addr_impl_ref & operator=(const addr_impl_ref &);
};
template<class T> struct addressof_impl
{
static inline T * f( T & v, long )
{
return reinterpret_cast<T*>(
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
static inline T * f( T * v, int )
{
return v;
}
};
} // namespace detail
template<class T> T * addressof( T & v )
{
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) )
return boost::detail::addressof_impl<T>::f( v, 0 );
#else
return boost::detail::addressof_impl<T>::f( boost::detail::addr_impl_ref<T>( v ), 0 );
#endif
}
#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) )
namespace detail
{
template<class T> struct addressof_addp
{ {
typedef T * type; typedef T * type;
}; };
template <typename T> typename _addp<T>::type
# else } // namespace detail
template <typename T> T*
# endif template< class T, std::size_t N >
addressof(T& v) typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
{ {
return reinterpret_cast<T*>( return &t;
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
} }
#endif
// Borland doesn't like casting an array reference to a char reference // Borland doesn't like casting an array reference to a char reference
// but these overloads work around the problem. // but these overloads work around the problem.
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) #if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template<typename T,std::size_t N> template<typename T,std::size_t N>
T (*addressof(T (&t)[N]))[N] T (*addressof(T (&t)[N]))[N]
{ {
@ -51,8 +95,8 @@ const T (*addressof(const T (&t)[N]))[N]
{ {
return reinterpret_cast<const T(*)[N]>(&t); return reinterpret_cast<const T(*)[N]>(&t);
} }
# endif #endif
} } // namespace boost
#endif // BOOST_UTILITY_ADDRESSOF_HPP #endif // BOOST_UTILITY_ADDRESSOF_HPP

View File

@ -0,0 +1,708 @@
/*=============================================================================
Copyright (c) 2005 Matthew Calabrese
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)
==============================================================================*/
#ifndef BOOST_UTILITY_BINARY_HPP
#define BOOST_UTILITY_BINARY_HPP
/*=============================================================================
Binary Literal Utility
______________________
The following code works by converting the input bit pattern into a
Boost.Preprocessor sequence, then converting groupings of 3 bits each into
the corresponding octal digit, and finally concatenating all of the digits
together along with a leading zero. This yields a standard octal literal
with the desired value as specified in bits.
==============================================================================*/
#include <boost/preprocessor/control/deduce_d.hpp>
#include <boost/preprocessor/facilities/identity.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/cat.hpp>
#include <boost/preprocessor/seq/transform.hpp>
#include <boost/preprocessor/arithmetic/mod.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#include <boost/preprocessor/control/while.hpp>
#define BOOST_BINARY( bit_groupings ) \
BOOST_BINARY_LITERAL_D( BOOST_PP_DEDUCE_D(), bit_groupings )
#define BOOST_BINARY_U( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, U )
#define BOOST_BINARY_L( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, L )
#define BOOST_BINARY_UL( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, UL )
#define BOOST_BINARY_LU( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LU )
#define BOOST_BINARY_LL( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LL )
#define BOOST_BINARY_ULL( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, ULL )
#define BOOST_BINARY_LLU( bit_groupings ) \
BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LLU )
#define BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, suffix ) \
BOOST_SUFFIXED_BINARY_LITERAL_D( BOOST_PP_DEDUCE_D(), bit_groupings, suffix )
#define BOOST_SUFFIXED_BINARY_LITERAL_D( d, bit_groupings, suffix ) \
BOOST_PP_CAT( BOOST_BINARY_LITERAL_D( d, bit_groupings ), suffix )
#define BOOST_BINARY_LITERAL_D( d, bit_groupings ) \
BOOST_PP_SEQ_CAT \
( (0) BOOST_DETAIL_CREATE_BINARY_LITERAL_OCTAL_SEQUENCE( d, bit_groupings ) \
)
#define BOOST_DETAIL_CREATE_BINARY_LITERAL_OCTAL_SEQUENCE( d, bit_groupings ) \
BOOST_PP_SEQ_TRANSFORM \
( BOOST_DETAIL_TRIPLE_TO_OCTAL_OPERATION \
, BOOST_PP_NIL \
, BOOST_PP_IDENTITY( BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_TRIPLE_SEQUENCE )()\
( BOOST_DETAIL_COMPLETE_TRIPLE_SEQUENCE \
( \
d \
, BOOST_DETAIL_CREATE_BINARY_LITERAL_BIT_SEQUENCE( d, bit_groupings ) \
) \
) \
)
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_TRIPLE_SEQUENCE( bit_sequence ) \
BOOST_PP_CAT \
( BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1 bit_sequence \
, END_BIT \
)
#define BOOST_DETAIL_BITS_PER_OCTIT 3
#define BOOST_DETAIL_COMPLETE_TRIPLE_SEQUENCE( d, incomplete_nibble_sequence ) \
BOOST_PP_CAT \
( BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_ \
, BOOST_PP_MOD_D( d \
, BOOST_PP_SEQ_SIZE( incomplete_nibble_sequence ) \
, BOOST_DETAIL_BITS_PER_OCTIT \
) \
) \
incomplete_nibble_sequence
#define BOOST_DETAIL_FIXED_COMPL( bit ) \
BOOST_PP_CAT( BOOST_DETAIL_FIXED_COMPL_, bit )
#define BOOST_DETAIL_FIXED_COMPL_0 1
#define BOOST_DETAIL_FIXED_COMPL_1 0
#define BOOST_DETAIL_CREATE_BINARY_LITERAL_BIT_SEQUENCE( d, bit_groupings ) \
BOOST_PP_EMPTY \
BOOST_PP_CAT( BOOST_PP_WHILE_, d ) \
( BOOST_DETAIL_BINARY_LITERAL_PREDICATE \
, BOOST_DETAIL_BINARY_LITERAL_OPERATION \
, bit_groupings () \
)
#define BOOST_DETAIL_BINARY_LITERAL_PREDICATE( d, state ) \
BOOST_DETAIL_FIXED_COMPL( BOOST_DETAIL_IS_NULLARY_ARGS( state ) )
#define BOOST_DETAIL_BINARY_LITERAL_OPERATION( d, state ) \
BOOST_DETAIL_SPLIT_AND_SWAP \
( BOOST_PP_CAT( BOOST_DETAIL_BINARY_LITERAL_ELEMENT_, state ) )
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_OPERATION( s, dummy_param, tuple ) \
BOOST_DETAIL_TERNARY_TRIPLE_TO_OCTAL tuple
#define BOOST_DETAIL_TERNARY_TRIPLE_TO_OCTAL( bit2, bit1, bit0 ) \
BOOST_DETAIL_TRIPLE_TO_OCTAL_ ## bit2 ## bit1 ## bit0
#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_1 (0)(0)
#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_2 (0)
#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_0
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1END_BIT
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1( bit ) \
( ( bit, BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_2
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_2( bit ) \
bit, BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_3
#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_3( bit ) \
bit ) ) BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1
#define BOOST_DETAIL_SPLIT_AND_SWAP( params ) \
BOOST_PP_IDENTITY( BOOST_DETAIL_SPLIT_AND_SWAP_PARAMS )()( params )
#define BOOST_DETAIL_SPLIT_AND_SWAP_PARAMS( first_param, second_param ) \
second_param first_param
#define BOOST_DETAIL_LEFT_OF_COMMA( params ) \
BOOST_PP_IDENTITY( BOOST_DETAIL_FIRST_MACRO_PARAM )()( params )
#define BOOST_DETAIL_FIRST_MACRO_PARAM( first_param, second_param ) \
first_param
/* Begin derived concepts from Chaos by Paul Mensonides */
#define BOOST_DETAIL_IS_NULLARY_ARGS( param ) \
BOOST_DETAIL_LEFT_OF_COMMA \
( BOOST_PP_CAT( BOOST_DETAIL_IS_NULLARY_ARGS_R_ \
, BOOST_DETAIL_IS_NULLARY_ARGS_C param \
) \
)
#define BOOST_DETAIL_IS_NULLARY_ARGS_C() \
1
#define BOOST_DETAIL_IS_NULLARY_ARGS_R_1 \
1, BOOST_PP_NIL
#define BOOST_DETAIL_IS_NULLARY_ARGS_R_BOOST_DETAIL_IS_NULLARY_ARGS_C \
0, BOOST_PP_NIL
/* End derived concepts from Chaos by Paul Mensonides */
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_000 0
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_001 1
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_010 2
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_011 3
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_100 4
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_101 5
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_110 6
#define BOOST_DETAIL_TRIPLE_TO_OCTAL_111 7
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0 (0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1 (1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00 (0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01 (0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10 (1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11 (1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00 (0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01 (0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10 (1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11 (1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000 (0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001 (0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010 (0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011 (0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100 (1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101 (1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110 (1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111 (1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000 (0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001 (0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010 (0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011 (0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100 (0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101 (0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110 (0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111 (0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000 (1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001 (1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010 (1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011 (1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100 (1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101 (1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110 (1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111 (1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000 (0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001 (0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010 (0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011 (0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100 (0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101 (0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110 (0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111 (0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000 (0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001 (0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010 (0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011 (0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100 (0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101 (0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110 (0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111 (0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000 (1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001 (1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010 (1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011 (1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100 (1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101 (1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110 (1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111 (1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000 (1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001 (1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010 (1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011 (1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100 (1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101 (1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110 (1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111 (1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000000 (0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000001 (0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000010 (0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000011 (0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000100 (0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000101 (0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000110 (0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000111 (0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001000 (0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001001 (0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001010 (0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001011 (0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001100 (0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001101 (0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001110 (0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001111 (0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010000 (0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010001 (0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010010 (0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010011 (0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010100 (0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010101 (0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010110 (0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010111 (0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011000 (0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011001 (0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011010 (0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011011 (0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011100 (0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011101 (0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011110 (0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011111 (0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100000 (1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100001 (1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100010 (1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100011 (1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100100 (1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100101 (1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100110 (1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100111 (1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101000 (1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101001 (1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101010 (1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101011 (1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101100 (1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101101 (1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101110 (1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101111 (1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110000 (1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110001 (1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110010 (1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110011 (1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110100 (1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110101 (1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110110 (1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110111 (1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111000 (1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111001 (1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111010 (1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111011 (1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111100 (1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111101 (1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111110 (1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111111 (1)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000000 (0)(0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000001 (0)(0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000010 (0)(0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000011 (0)(0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000100 (0)(0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000101 (0)(0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000110 (0)(0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000111 (0)(0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001000 (0)(0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001001 (0)(0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001010 (0)(0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001011 (0)(0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001100 (0)(0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001101 (0)(0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001110 (0)(0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001111 (0)(0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010000 (0)(0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010001 (0)(0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010010 (0)(0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010011 (0)(0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010100 (0)(0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010101 (0)(0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010110 (0)(0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010111 (0)(0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011000 (0)(0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011001 (0)(0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011010 (0)(0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011011 (0)(0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011100 (0)(0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011101 (0)(0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011110 (0)(0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011111 (0)(0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100000 (0)(1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100001 (0)(1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100010 (0)(1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100011 (0)(1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100100 (0)(1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100101 (0)(1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100110 (0)(1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100111 (0)(1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101000 (0)(1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101001 (0)(1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101010 (0)(1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101011 (0)(1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101100 (0)(1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101101 (0)(1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101110 (0)(1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101111 (0)(1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110000 (0)(1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110001 (0)(1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110010 (0)(1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110011 (0)(1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110100 (0)(1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110101 (0)(1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110110 (0)(1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110111 (0)(1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111000 (0)(1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111001 (0)(1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111010 (0)(1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111011 (0)(1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111100 (0)(1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111101 (0)(1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111110 (0)(1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111111 (0)(1)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000000 (1)(0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000001 (1)(0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000010 (1)(0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000011 (1)(0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000100 (1)(0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000101 (1)(0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000110 (1)(0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000111 (1)(0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001000 (1)(0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001001 (1)(0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001010 (1)(0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001011 (1)(0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001100 (1)(0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001101 (1)(0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001110 (1)(0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001111 (1)(0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010000 (1)(0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010001 (1)(0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010010 (1)(0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010011 (1)(0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010100 (1)(0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010101 (1)(0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010110 (1)(0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010111 (1)(0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011000 (1)(0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011001 (1)(0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011010 (1)(0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011011 (1)(0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011100 (1)(0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011101 (1)(0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011110 (1)(0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011111 (1)(0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100000 (1)(1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100001 (1)(1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100010 (1)(1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100011 (1)(1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100100 (1)(1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100101 (1)(1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100110 (1)(1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100111 (1)(1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101000 (1)(1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101001 (1)(1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101010 (1)(1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101011 (1)(1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101100 (1)(1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101101 (1)(1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101110 (1)(1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101111 (1)(1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110000 (1)(1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110001 (1)(1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110010 (1)(1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110011 (1)(1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110100 (1)(1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110101 (1)(1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110110 (1)(1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110111 (1)(1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111000 (1)(1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111001 (1)(1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111010 (1)(1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111011 (1)(1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111100 (1)(1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111101 (1)(1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111110 (1)(1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111111 (1)(1)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000000 (0)(0)(0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000001 (0)(0)(0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000010 (0)(0)(0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000011 (0)(0)(0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000100 (0)(0)(0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000101 (0)(0)(0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000110 (0)(0)(0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000111 (0)(0)(0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001000 (0)(0)(0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001001 (0)(0)(0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001010 (0)(0)(0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001011 (0)(0)(0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001100 (0)(0)(0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001101 (0)(0)(0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001110 (0)(0)(0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001111 (0)(0)(0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010000 (0)(0)(0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010001 (0)(0)(0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010010 (0)(0)(0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010011 (0)(0)(0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010100 (0)(0)(0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010101 (0)(0)(0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010110 (0)(0)(0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010111 (0)(0)(0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011000 (0)(0)(0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011001 (0)(0)(0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011010 (0)(0)(0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011011 (0)(0)(0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011100 (0)(0)(0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011101 (0)(0)(0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011110 (0)(0)(0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011111 (0)(0)(0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100000 (0)(0)(1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100001 (0)(0)(1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100010 (0)(0)(1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100011 (0)(0)(1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100100 (0)(0)(1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100101 (0)(0)(1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100110 (0)(0)(1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100111 (0)(0)(1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101000 (0)(0)(1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101001 (0)(0)(1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101010 (0)(0)(1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101011 (0)(0)(1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101100 (0)(0)(1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101101 (0)(0)(1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101110 (0)(0)(1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101111 (0)(0)(1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110000 (0)(0)(1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110001 (0)(0)(1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110010 (0)(0)(1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110011 (0)(0)(1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110100 (0)(0)(1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110101 (0)(0)(1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110110 (0)(0)(1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110111 (0)(0)(1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111000 (0)(0)(1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111001 (0)(0)(1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111010 (0)(0)(1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111011 (0)(0)(1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111100 (0)(0)(1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111101 (0)(0)(1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111110 (0)(0)(1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111111 (0)(0)(1)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000000 (0)(1)(0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000001 (0)(1)(0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000010 (0)(1)(0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000011 (0)(1)(0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000100 (0)(1)(0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000101 (0)(1)(0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000110 (0)(1)(0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000111 (0)(1)(0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001000 (0)(1)(0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001001 (0)(1)(0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001010 (0)(1)(0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001011 (0)(1)(0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001100 (0)(1)(0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001101 (0)(1)(0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001110 (0)(1)(0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001111 (0)(1)(0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010000 (0)(1)(0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010001 (0)(1)(0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010010 (0)(1)(0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010011 (0)(1)(0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010100 (0)(1)(0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010101 (0)(1)(0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010110 (0)(1)(0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010111 (0)(1)(0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011000 (0)(1)(0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011001 (0)(1)(0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011010 (0)(1)(0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011011 (0)(1)(0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011100 (0)(1)(0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011101 (0)(1)(0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011110 (0)(1)(0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011111 (0)(1)(0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100000 (0)(1)(1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100001 (0)(1)(1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100010 (0)(1)(1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100011 (0)(1)(1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100100 (0)(1)(1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100101 (0)(1)(1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100110 (0)(1)(1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100111 (0)(1)(1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101000 (0)(1)(1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101001 (0)(1)(1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101010 (0)(1)(1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101011 (0)(1)(1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101100 (0)(1)(1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101101 (0)(1)(1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101110 (0)(1)(1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101111 (0)(1)(1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110000 (0)(1)(1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110001 (0)(1)(1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110010 (0)(1)(1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110011 (0)(1)(1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110100 (0)(1)(1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110101 (0)(1)(1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110110 (0)(1)(1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110111 (0)(1)(1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111000 (0)(1)(1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111001 (0)(1)(1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111010 (0)(1)(1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111011 (0)(1)(1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111100 (0)(1)(1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111101 (0)(1)(1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111110 (0)(1)(1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111111 (0)(1)(1)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000000 (1)(0)(0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000001 (1)(0)(0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000010 (1)(0)(0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000011 (1)(0)(0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000100 (1)(0)(0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000101 (1)(0)(0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000110 (1)(0)(0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000111 (1)(0)(0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001000 (1)(0)(0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001001 (1)(0)(0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001010 (1)(0)(0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001011 (1)(0)(0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001100 (1)(0)(0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001101 (1)(0)(0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001110 (1)(0)(0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001111 (1)(0)(0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010000 (1)(0)(0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010001 (1)(0)(0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010010 (1)(0)(0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010011 (1)(0)(0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010100 (1)(0)(0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010101 (1)(0)(0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010110 (1)(0)(0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010111 (1)(0)(0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011000 (1)(0)(0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011001 (1)(0)(0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011010 (1)(0)(0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011011 (1)(0)(0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011100 (1)(0)(0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011101 (1)(0)(0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011110 (1)(0)(0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011111 (1)(0)(0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100000 (1)(0)(1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100001 (1)(0)(1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100010 (1)(0)(1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100011 (1)(0)(1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100100 (1)(0)(1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100101 (1)(0)(1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100110 (1)(0)(1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100111 (1)(0)(1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101000 (1)(0)(1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101001 (1)(0)(1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101010 (1)(0)(1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101011 (1)(0)(1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101100 (1)(0)(1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101101 (1)(0)(1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101110 (1)(0)(1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101111 (1)(0)(1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110000 (1)(0)(1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110001 (1)(0)(1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110010 (1)(0)(1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110011 (1)(0)(1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110100 (1)(0)(1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110101 (1)(0)(1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110110 (1)(0)(1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110111 (1)(0)(1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111000 (1)(0)(1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111001 (1)(0)(1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111010 (1)(0)(1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111011 (1)(0)(1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111100 (1)(0)(1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111101 (1)(0)(1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111110 (1)(0)(1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111111 (1)(0)(1)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000000 (1)(1)(0)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000001 (1)(1)(0)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000010 (1)(1)(0)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000011 (1)(1)(0)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000100 (1)(1)(0)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000101 (1)(1)(0)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000110 (1)(1)(0)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000111 (1)(1)(0)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001000 (1)(1)(0)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001001 (1)(1)(0)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001010 (1)(1)(0)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001011 (1)(1)(0)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001100 (1)(1)(0)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001101 (1)(1)(0)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001110 (1)(1)(0)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001111 (1)(1)(0)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010000 (1)(1)(0)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010001 (1)(1)(0)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010010 (1)(1)(0)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010011 (1)(1)(0)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010100 (1)(1)(0)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010101 (1)(1)(0)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010110 (1)(1)(0)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010111 (1)(1)(0)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011000 (1)(1)(0)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011001 (1)(1)(0)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011010 (1)(1)(0)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011011 (1)(1)(0)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011100 (1)(1)(0)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011101 (1)(1)(0)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011110 (1)(1)(0)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011111 (1)(1)(0)(1)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100000 (1)(1)(1)(0)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100001 (1)(1)(1)(0)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100010 (1)(1)(1)(0)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100011 (1)(1)(1)(0)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100100 (1)(1)(1)(0)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100101 (1)(1)(1)(0)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100110 (1)(1)(1)(0)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100111 (1)(1)(1)(0)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101000 (1)(1)(1)(0)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101001 (1)(1)(1)(0)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101010 (1)(1)(1)(0)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101011 (1)(1)(1)(0)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101100 (1)(1)(1)(0)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101101 (1)(1)(1)(0)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101110 (1)(1)(1)(0)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101111 (1)(1)(1)(0)(1)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110000 (1)(1)(1)(1)(0)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110001 (1)(1)(1)(1)(0)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110010 (1)(1)(1)(1)(0)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110011 (1)(1)(1)(1)(0)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110100 (1)(1)(1)(1)(0)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110101 (1)(1)(1)(1)(0)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110110 (1)(1)(1)(1)(0)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110111 (1)(1)(1)(1)(0)(1)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111000 (1)(1)(1)(1)(1)(0)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111001 (1)(1)(1)(1)(1)(0)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111010 (1)(1)(1)(1)(1)(0)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111011 (1)(1)(1)(1)(1)(0)(1)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111100 (1)(1)(1)(1)(1)(1)(0)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111101 (1)(1)(1)(1)(1)(1)(0)(1),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111110 (1)(1)(1)(1)(1)(1)(1)(0),
#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111111 (1)(1)(1)(1)(1)(1)(1)(1),
#endif

View File

@ -20,10 +20,69 @@
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)> struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
: boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {}; : mpl::if_<
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
, boost::detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)>
, boost::detail::tr1_result_of_impl<
F,
F(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)> >::type { };
#endif #endif
#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE)
// As of N2588, C++0x result_of only supports function call
// expressions of the form f(x). This precludes support for member
// function pointers, which are invoked with expressions of the form
// o->*f(x). This implementation supports both.
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
: mpl::if_<
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
, detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
>
, detail::cpp0x_result_of_impl<
F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))
>
>::type
{};
namespace detail {
# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \
static T ## n t ## n; \
/**/
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
class cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
{
static F f;
BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _)
public:
typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type;
};
} // namespace detail
#else // defined(BOOST_NO_DECLTYPE)
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)>
: tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
#endif
#endif // defined(BOOST_NO_DECLTYPE)
#undef BOOST_RESULT_OF_ARGS #undef BOOST_RESULT_OF_ARGS
#if BOOST_PP_ITERATION() >= 1 #if BOOST_PP_ITERATION() >= 1
@ -32,14 +91,14 @@ namespace detail {
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false> struct tr1_result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
{ {
typedef R type; typedef R type;
}; };
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false> struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
{ {
typedef R type; typedef R type;
}; };
@ -47,7 +106,7 @@ struct result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of_impl<R (T0::*) struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)), (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
FArgs, false> FArgs, false>
{ {
@ -56,7 +115,7 @@ struct result_of_impl<R (T0::*)
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of_impl<R (T0::*) struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)) (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
const, const,
FArgs, false> FArgs, false>
@ -66,7 +125,7 @@ struct result_of_impl<R (T0::*)
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of_impl<R (T0::*) struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)) (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
volatile, volatile,
FArgs, false> FArgs, false>
@ -76,7 +135,7 @@ struct result_of_impl<R (T0::*)
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of_impl<R (T0::*) struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)) (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
const volatile, const volatile,
FArgs, false> FArgs, false>

View File

@ -1,12 +1,12 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jaakko J<EFBFBD>rvi (jajarvi at osl.iu.edu) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu)

View File

@ -10,13 +10,18 @@
#define BOOST_RESULT_OF_HPP #define BOOST_RESULT_OF_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/type_traits/ice.hpp> #include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/type.hpp> #include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor.hpp> #include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp> #include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/type_traits/remove_cv.hpp>
#ifndef BOOST_RESULT_OF_NUM_ARGS #ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 10 # define BOOST_RESULT_OF_NUM_ARGS 10
@ -25,13 +30,15 @@
namespace boost { namespace boost {
template<typename F> struct result_of; template<typename F> struct result_of;
template<typename F> struct tr1_result_of; // a TR1-style implementation of result_of
#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail { namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl; template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
template<typename F> struct cpp0x_result_of_impl;
template<typename F> template<typename F>
struct result_of_void_impl struct result_of_void_impl
@ -51,8 +58,13 @@ struct result_of_void_impl<R (&)(void)>
typedef R type; typedef R type;
}; };
// Determine the return type of a function pointer or pointer to member.
template<typename F, typename FArgs> template<typename F, typename FArgs>
struct result_of_impl<F, FArgs, true> struct result_of_pointer
: tr1_result_of_impl<typename remove_cv<F>::type, FArgs, false> { };
template<typename F, typename FArgs>
struct tr1_result_of_impl<F, FArgs, true>
{ {
typedef typename F::result_type type; typedef typename F::result_type type;
}; };
@ -68,10 +80,10 @@ struct result_of_nested_result : F::template result<FArgs>
{}; {};
template<typename F, typename FArgs> template<typename F, typename FArgs>
struct result_of_impl<F, FArgs, false> struct tr1_result_of_impl<F, FArgs, false>
: mpl::if_<is_function_with_no_args<FArgs>, : mpl::if_<is_function_with_no_args<FArgs>,
result_of_void_impl<F>, result_of_void_impl<F>,
result_of_nested_result<F, FArgs> >::type result_of_nested_result<F, FArgs> >::type
{}; {};
} // end namespace detail } // end namespace detail

View File

@ -0,0 +1,55 @@
// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker
//
// 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)
// For more information, see http://www.boost.org
#ifndef BOOST_UTILITY_SWAP_HPP
#define BOOST_UTILITY_SWAP_HPP
// Note: the implementation of this utility contains various workarounds:
// - swap_impl is put outside the boost namespace, to avoid infinite
// recursion (causing stack overflow) when swapping objects of a primitive
// type.
// - swap_impl has a using-directive, rather than a using-declaration,
// because some compilers (including MSVC 7.1, Borland 5.9.3, and
// Intel 8.1) don't do argument-dependent lookup when it has a
// using-declaration instead.
// - boost::swap has two template arguments, instead of one, to
// avoid ambiguity when swapping objects of a Boost type that does
// not have its own boost::swap overload.
#include <algorithm> //for std::swap
#include <cstddef> //for std::size_t
namespace boost_swap_impl
{
template<class T>
void swap_impl(T& left, T& right)
{
using namespace std;//use std::swap if argument dependent lookup fails
swap(left,right);
}
template<class T, std::size_t N>
void swap_impl(T (& left)[N], T (& right)[N])
{
for (std::size_t i = 0; i < N; ++i)
{
::boost_swap_impl::swap_impl(left[i], right[i]);
}
}
}
namespace boost
{
template<class T1, class T2>
void swap(T1& left, T2& right)
{
::boost_swap_impl::swap_impl(left, right);
}
}
#endif

View File

@ -54,8 +54,8 @@ public:
void* apply (void* address, std::size_t n) const void* apply (void* address, std::size_t n) const
{ {
for(char* next = address = this->apply(address); !! --n;) for(void* next = address = this->apply(address); !! --n;)
this->apply(next = next+sizeof(T)); this->apply(next = static_cast<char *>(next) + sizeof(T));
return address; return address;
} }

View File

@ -1,81 +1,258 @@
// (C) 2002, Fernando Luis Cacciola Carballal. // (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
// 21 Ago 2002 (Created) Fernando Cacciola // 21 Ago 2002 (Created) Fernando Cacciola
// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker
// 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola
// 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola
// 20 Feb 2009 (Fixed logical const-ness issues) Niels Dekker, Fernando Cacciola
// 03 Apr 2010 (Added initialized<T>, suggested by Jeffrey Hellrung, fixing #3472) Niels Dekker
// 30 May 2010 (Made memset call conditional, fixing #3869) Niels Dekker
// //
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
#include <boost/detail/select_type.hpp> // Note: The implementation of boost::value_initialized had to deal with the
#include <boost/type_traits/cv_traits.hpp> // fact that various compilers haven't fully implemented value-initialization.
// The constructor of boost::value_initialized<T> works around these compiler
// issues, by clearing the bytes of T, before constructing the T object it
// contains. More details on these issues are at libs/utility/value_init.htm
#include <boost/aligned_storage.hpp>
#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/swap.hpp>
#include <cstring>
#include <new>
#ifdef BOOST_MSVC
#pragma warning(push)
#if _MSC_VER >= 1310
// It is safe to ignore the following warning from MSVC 7.1 or higher:
// "warning C4351: new behavior: elements of array will be default initialized"
#pragma warning(disable: 4351)
// It is safe to ignore the following MSVC warning, which may pop up when T is
// a const type: "warning C4512: assignment operator could not be generated".
#pragma warning(disable: 4512)
#endif
#endif
#ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION
// Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
// suggests that a workaround should be applied, because of compiler issues
// regarding value-initialization.
#define BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
#endif
// Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND
// switches the value-initialization workaround either on or off.
#ifndef BOOST_DETAIL_VALUE_INIT_WORKAROUND
#ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
#define BOOST_DETAIL_VALUE_INIT_WORKAROUND 1
#else
#define BOOST_DETAIL_VALUE_INIT_WORKAROUND 0
#endif
#endif
namespace boost { namespace boost {
namespace vinit_detail {
template<class T> template<class T>
class const_T_base class initialized
{ {
protected : private :
struct wrapper
const_T_base() : x() {} {
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
T x ; typename
} ;
template<class T>
struct non_const_T_base
{
protected :
non_const_T_base() : x() {}
mutable T x ;
} ;
template<class T>
struct select_base
{
typedef
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
typename
#endif #endif
::boost::detail::if_true< ::boost::is_const<T>::value > remove_const<T>::type data;
::template then< const_T_base<T>, non_const_T_base<T> >::type type ;
} ;
} // namespace vinit_detail wrapper()
:
data()
{
}
wrapper(T const & arg)
:
data(arg)
{
}
};
mutable
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
typename
#endif
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
wrapper * wrapper_address() const
{
return static_cast<wrapper *>( static_cast<void*>(&x));
}
template<class T>
class value_initialized : private vinit_detail::select_base<T>::type
{
public : public :
value_initialized() {} initialized()
{
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
std::memset(&x, 0, sizeof(x));
#endif
new (wrapper_address()) wrapper();
}
operator T&() const { return this->x ; } initialized(initialized const & arg)
{
new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
}
T& data() const { return this->x ; } explicit initialized(T const & arg)
{
new (wrapper_address()) wrapper(arg);
}
initialized & operator=(initialized const & arg)
{
// Assignment is only allowed when T is non-const.
BOOST_STATIC_ASSERT( ! is_const<T>::value );
*wrapper_address() = static_cast<wrapper const &>(*(arg.wrapper_address()));
return *this;
}
~initialized()
{
wrapper_address()->wrapper::~wrapper();
}
T const & data() const
{
return wrapper_address()->data;
}
T& data()
{
return wrapper_address()->data;
}
void swap(initialized & arg)
{
::boost::swap( this->data(), arg.data() );
}
operator T const &() const
{
return wrapper_address()->data;
}
operator T&()
{
return wrapper_address()->data;
}
} ; } ;
template<class T>
T const& get ( initialized<T> const& x )
{
return x.data() ;
}
template<class T>
T& get ( initialized<T>& x )
{
return x.data() ;
}
template<class T>
void swap ( initialized<T> & lhs, initialized<T> & rhs )
{
lhs.swap(rhs) ;
}
template<class T>
class value_initialized
{
private :
// initialized<T> does value-initialization by default.
initialized<T> m_data;
public :
value_initialized()
:
m_data()
{ }
T const & data() const
{
return m_data.data();
}
T& data()
{
return m_data.data();
}
void swap(value_initialized & arg)
{
m_data.swap(arg.m_data);
}
operator T const &() const
{
return m_data;
}
operator T&()
{
return m_data;
}
} ;
template<class T> template<class T>
T const& get ( value_initialized<T> const& x ) T const& get ( value_initialized<T> const& x )
{ {
return x.data() ; return x.data() ;
} }
template<class T> template<class T>
T& get ( value_initialized<T>& x ) T& get ( value_initialized<T>& x )
{ {
return x.data() ; return x.data() ;
} }
template<class T>
void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs )
{
lhs.swap(rhs) ;
}
class initialized_value_t
{
public :
template <class T> operator T() const
{
return initialized<T>().data();
}
};
initialized_value_t const initialized_value = {} ;
} // namespace boost } // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif #endif
#endif

View File

@ -21,14 +21,16 @@
<a href="compressed_pair.htm">compressed_pair</a><br> <a href="compressed_pair.htm">compressed_pair</a><br>
<a href="current_function.html">current_function</a><br> <a href="current_function.html">current_function</a><br>
<a href="enable_if.html">enable_if</a><br> <a href="enable_if.html">enable_if</a><br>
<a href="iterator_adaptors.htm">iterator_adaptors</a><br> <a href="iterator_adaptors.htm">iterator_adaptors</a><br>
<a href="generator_iterator.htm">generator iterator adaptors</a><br>
<a href="operators.htm">operators</a><br> <a href="operators.htm">operators</a><br>
<a href="swap.html">swap</a><br>
<a href="throw_exception.html">throw_exception</a><br> <a href="throw_exception.html">throw_exception</a><br>
<a href="utility.htm">utility</a><br> <a href="utility.htm">utility</a><br>
<a href="value_init.htm">value_init</a></p> <a href="value_init.htm">value_init</a></p>
</blockquote> </blockquote>
<hr> <hr>
<p><EFBFBD> Copyright Beman Dawes, 2001</p> <p>&copy; Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See <p>Distributed under the Boost Software License, Version 1.0. (See
accompanying file <a href="../../LICENSE_1_0.txt"> accompanying file <a href="../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at LICENSE_1_0.txt</a> or copy at

116
initialized_test.cpp Normal file
View File

@ -0,0 +1,116 @@
// Copyright 2010, Niels Dekker.
//
// 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)
//
// Test program for boost::initialized<T>.
//
// 2 May 2010 (Created) Niels Dekker
#include <boost/utility/value_init.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
namespace
{
// Typical use case for boost::initialized<T>: A generic class that
// holds a value of type T, which must be initialized by either
// value-initialization or direct-initialization.
template <class T> class key_value_pair
{
std::string m_key;
boost::initialized<T> m_value;
public:
// Value-initializes the object held by m_value.
key_value_pair() { }
// Value-initializes the object held by m_value.
explicit key_value_pair(const std::string& key)
:
m_key(key)
{
}
// Direct-initializes the object held by m_value.
key_value_pair(const std::string& key, const T& value)
:
m_key(key), m_value(value)
{
}
const T& get_value() const
{
return m_value;
}
};
// Tells whether the argument is value-initialized.
bool is_value_initialized(const int& arg)
{
return arg == 0;
}
// Tells whether the argument is value-initialized.
bool is_value_initialized(const std::string& arg)
{
return arg.empty();
}
struct foo
{
int data;
};
bool operator==(const foo& lhs, const foo& rhs)
{
return lhs.data == rhs.data;
}
// Tells whether the argument is value-initialized.
bool is_value_initialized(const foo& arg)
{
return arg.data == 0;
}
template <class T>
void test_key_value_pair(const T& magic_value)
{
// The value component of a default key_value_pair must be value-initialized.
key_value_pair<T> default_key_value_pair;
BOOST_TEST( is_value_initialized(default_key_value_pair.get_value() ) );
// The value component of a key_value_pair that only has its key explicitly specified
// must also be value-initialized.
BOOST_TEST( is_value_initialized(key_value_pair<T>("key").get_value()) );
// However, the value component of the following key_value_pair must be
// "magic_value", as it must be direct-initialized.
BOOST_TEST( key_value_pair<T>("key", magic_value).get_value() == magic_value );
}
}
// Tests boost::initialize for a fundamental type, a type with a
// user-defined constructor, and a user-defined type without
// a user-defined constructor.
int main()
{
const int magic_number = 42;
test_key_value_pair(magic_number);
const std::string magic_string = "magic value";
test_key_value_pair(magic_string);
const foo magic_foo = { 42 };
test_key_value_pair(magic_foo);
return boost::report_errors();
}

View File

@ -0,0 +1,33 @@
// Copyright 2010, Niels Dekker.
//
// 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)
//
// Test program for boost::initialized<T>. Must fail to compile.
//
// Initial: 2 May 2010
#include <boost/utility/value_init.hpp>
namespace
{
void direct_initialize_from_int()
{
// Okay: initialized<T> supports direct-initialization from T.
boost::initialized<int> direct_initialized_int(1);
}
void copy_initialize_from_int()
{
// The following line should not compile, because initialized<T>
// was not intended to supports copy-initialization from T.
boost::initialized<int> copy_initialized_int = 1;
}
}
int main()
{
// This should fail to compile, so there is no need to call any function.
return 0;
}

View File

@ -0,0 +1,37 @@
// Copyright 2010, Niels Dekker.
//
// 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)
//
// Test program for boost::initialized<T>. Must fail to compile.
//
// Initial: 2 May 2010
#include <boost/utility/value_init.hpp>
namespace
{
void from_value_initialized_to_initialized()
{
boost::value_initialized<int> value_initialized_int;
// Okay: initialized<T> can be initialized by value_initialized<T>.
boost::initialized<int> initialized_int(value_initialized_int);
}
void from_initialized_to_value_initialized()
{
boost::initialized<int> initialized_int(13);
// The following line should not compile, because initialized<T>
// should not be convertible to value_initialized<T>.
boost::value_initialized<int> value_initialized_int(initialized_int);
}
}
int main()
{
// This should fail to compile, so there is no need to call any function.
return 0;
}

View File

@ -132,18 +132,18 @@
class MyInt class MyInt
: boost::operators&lt;MyInt&gt; : boost::operators&lt;MyInt&gt;
{ {
bool operator&lt;(const MyInt&amp; x) const; bool operator&lt;(const MyInt&amp; x) const;
bool operator==(const MyInt&amp; x) const; bool operator==(const MyInt&amp; x) const;
MyInt&amp; operator+=(const MyInt&amp; x); MyInt&amp; operator+=(const MyInt&amp; x);
MyInt&amp; operator-=(const MyInt&amp; x); MyInt&amp; operator-=(const MyInt&amp; x);
MyInt&amp; operator*=(const MyInt&amp; x); MyInt&amp; operator*=(const MyInt&amp; x);
MyInt&amp; operator/=(const MyInt&amp; x); MyInt&amp; operator/=(const MyInt&amp; x);
MyInt&amp; operator%=(const MyInt&amp; x); MyInt&amp; operator%=(const MyInt&amp; x);
MyInt&amp; operator|=(const MyInt&amp; x); MyInt&amp; operator|=(const MyInt&amp; x);
MyInt&amp; operator&amp;=(const MyInt&amp; x); MyInt&amp; operator&amp;=(const MyInt&amp; x);
MyInt&amp; operator^=(const MyInt&amp; x); MyInt&amp; operator^=(const MyInt&amp; x);
MyInt&amp; operator++(); MyInt&amp; operator++();
MyInt&amp; operator--(); MyInt&amp; operator--();
}; };
</pre> </pre>
</blockquote> </blockquote>
@ -345,7 +345,7 @@ class MyInt
</ul> </ul>
<p>As Daniel Kr&uuml;gler pointed out, this technique violates 14.6.5/2 <p>As Daniel Kr&uuml;gler pointed out, this technique violates 14.6.5/2
and is thus non-portable. The reasoning is, that the operators injected and is thus non-portable. The reasoning is, that the operators injected
by the instantiation of e.g. by the instantiation of e.g.
<code>less_than_comparable&lt;myclass&gt;</code> can not be found <code>less_than_comparable&lt;myclass&gt;</code> can not be found
by ADL according to the rules given by 3.4.2/2, since myclass is by ADL according to the rules given by 3.4.2/2, since myclass is
@ -445,6 +445,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
optional template parameter <code>B</code>, which is not shown, for the optional template parameter <code>B</code>, which is not shown, for the
<a href="#chaining">base class chaining</a> technique.</p> <a href="#chaining">base class chaining</a> technique.</p>
<p>The primary operand type <code>T</code> needs to be of class type,
built-in types are not supported.</p>
<table cellpadding="5" border="1" align="center"> <table cellpadding="5" border="1" align="center">
<caption> <caption>
Simple Arithmetic Operator Template Classes Simple Arithmetic Operator Template Classes
@ -917,7 +920,7 @@ T operator+( const T&amp; lhs, const T&amp; rhs )
created, <code>operator+=</code> is called on it and it is copied to the created, <code>operator+=</code> is called on it and it is copied to the
function return value (which is another unnamed object of type function return value (which is another unnamed object of type
<code>T</code>). The standard doesn't generally allow the intermediate <code>T</code>). The standard doesn't generally allow the intermediate
object to be optimized away: object to be optimized away:
<blockquote> <blockquote>
3.7.2/2: Automatic storage duration<br> 3.7.2/2: Automatic storage duration<br>
@ -928,7 +931,7 @@ T operator+( const T&amp; lhs, const T&amp; rhs )
unused, except that a class object or its copy may be eliminated as unused, except that a class object or its copy may be eliminated as
specified in 12.8. specified in 12.8.
</blockquote> </blockquote>
The reference to 12.8 is important for us: The reference to 12.8 is important for us:
<blockquote> <blockquote>
12.8/15: Copying class objects<br> 12.8/15: Copying class objects<br>
@ -942,7 +945,7 @@ T operator+( const T&amp; lhs, const T&amp; rhs )
</blockquote> </blockquote>
This optimization is known as the named return value optimization (NRVO), This optimization is known as the named return value optimization (NRVO),
which leads us to the following implementation for which leads us to the following implementation for
<code>operator+</code>: <code>operator+</code>:
<pre> <pre>
T operator+( const T&amp; lhs, const T&amp; rhs ) T operator+( const T&amp; lhs, const T&amp; rhs )
{ {
@ -956,7 +959,7 @@ T operator+( const T&amp; lhs, const T&amp; rhs )
even implement it in an incorrect way which makes it useless here. even implement it in an incorrect way which makes it useless here.
Without the NRVO, the NRVO-friendly code is no worse than the original Without the NRVO, the NRVO-friendly code is no worse than the original
code showed above, but there is another possible implementation, which code showed above, but there is another possible implementation, which
has some very special properties: has some very special properties:
<pre> <pre>
T operator+( T lhs, const T&amp; rhs ) T operator+( T lhs, const T&amp; rhs )
{ {
@ -982,7 +985,7 @@ T operator+( T lhs, const T&amp; rhs )
will force the NRVO-friendly implementation to be used even for compilers will force the NRVO-friendly implementation to be used even for compilers
that don't implement the NRVO. <br> that don't implement the NRVO. <br>
<br> <br>
<h3><a name="grpd_oprs">Grouped Arithmetic Operators</a></h3> <h3><a name="grpd_oprs">Grouped Arithmetic Operators</a></h3>
<p>The following templates provide common groups of related operations. <p>The following templates provide common groups of related operations.
@ -1420,9 +1423,9 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"euclidian_ring_operators1">euclidian_ring_operators&lt;T&gt;</a></code><br> "euclidean_ring_operators1">euclidean_ring_operators&lt;T&gt;</a></code><br>
<code>euclidian_ring_operators1&lt;T&gt;</code></td> <code>euclidean_ring_operators1&lt;T&gt;</code></td>
<td> <td>
<ul> <ul>
@ -1439,9 +1442,9 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"euclidian_ring_operators2">euclidian_ring_operators&lt;T, "euclidean_ring_operators2">euclidean_ring_operators&lt;T,
U&gt;</a></code><br> U&gt;</a></code><br>
<code>euclidian_ring_operators2&lt;T, U&gt;</code></td> <code>euclidean_ring_operators2&lt;T, U&gt;</code></td>
<td> <td>
<ul> <ul>
@ -1464,14 +1467,14 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"ordered_euclidian_ring_operators1">ordered_euclidian_ring_operators&lt;T&gt;</a></code><br> "ordered_euclidean_ring_operators1">ordered_euclidean_ring_operators&lt;T&gt;</a></code><br>
<code>ordered_euclidian_ring_operators1&lt;T&gt;</code></td> <code>ordered_euclidean_ring_operators1&lt;T&gt;</code></td>
<td> <td>
<ul> <ul>
<li><code><a href= <li><code><a href=
"#euclidian_ring_operators1">euclidian_ring_operators&lt;T&gt;</a></code></li> "#euclidean_ring_operators1">euclidean_ring_operators&lt;T&gt;</a></code></li>
<li><code><a href= <li><code><a href=
"#totally_ordered1">totally_ordered&lt;T&gt;</a></code></li> "#totally_ordered1">totally_ordered&lt;T&gt;</a></code></li>
@ -1481,14 +1484,14 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"ordered_euclidian_ring_operators2">ordered_euclidian_ring_operators&lt;T, "ordered_euclidean_ring_operators2">ordered_euclidean_ring_operators&lt;T,
U&gt;</a></code><br> U&gt;</a></code><br>
<code>ordered_euclidian_ring_operators2&lt;T, U&gt;</code></td> <code>ordered_euclidean_ring_operators2&lt;T, U&gt;</code></td>
<td> <td>
<ul> <ul>
<li><code><a href= <li><code><a href=
"#euclidian_ring_operators2">euclidian_ring_operators&lt;T, "#euclidean_ring_operators2">euclidean_ring_operators&lt;T,
U&gt;</a></code></li> U&gt;</a></code></li>
<li><code><a href="#totally_ordered2">totally_ordered&lt;T, <li><code><a href="#totally_ordered2">totally_ordered&lt;T,
@ -1498,6 +1501,15 @@ T operator+( T lhs, const T&amp; rhs )
</tr> </tr>
</table> </table>
<h4>Spelling: euclidean vs. euclidian</h4>
<p>Older versions of the Boost.Operators library used
&quot;<code>euclidian</code>&quot;, but it was pointed out that
&quot;<code>euclidean</code>&quot; is the more common spelling.
To be compatible with older version, the library now supports
both spellings.
</p>
<h3><a name="ex_oprs">Example</a> Templates</h3> <h3><a name="ex_oprs">Example</a> Templates</h3>
<p>The arithmetic operator class templates <code><a href= <p>The arithmetic operator class templates <code><a href=
@ -1576,9 +1588,8 @@ T operator+( T lhs, const T&amp; rhs )
<p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite> <p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite>
program demonstrates the use of the arithmetic operator templates, and program demonstrates the use of the arithmetic operator templates, and
can also be used to verify correct operation. Check the <a href= can also be used to verify correct operation. Check the compiler status
"../../status/compiler_status.html">compiler status report</a> for the report for the test results with selected platforms.</p>
test results with selected platforms.</p>
<h2><a name="deref">Dereference</a> Operators and Iterator Helpers</h2> <h2><a name="deref">Dereference</a> Operators and Iterator Helpers</h2>
@ -1856,7 +1867,7 @@ T operator+( T lhs, const T&amp; rhs )
V, D, P, R&gt;</a></code></td> V, D, P, R&gt;</a></code></td>
<td> <td>
Supports the operations and has the requirements of Supports the operations and has the requirements of
<ul> <ul>
<li><code><a href="#input_iteratable">input_iteratable&lt;T, <li><code><a href="#input_iteratable">input_iteratable&lt;T,
@ -1870,7 +1881,7 @@ T operator+( T lhs, const T&amp; rhs )
"output_iterator_helper">output_iterator_helper&lt;T&gt;</a></code></td> "output_iterator_helper">output_iterator_helper&lt;T&gt;</a></code></td>
<td> <td>
Supports the operations and has the requirements of Supports the operations and has the requirements of
<ul> <ul>
<li><code><a href= <li><code><a href=
@ -1886,7 +1897,7 @@ T operator+( T lhs, const T&amp; rhs )
R&gt;</a></code></td> R&gt;</a></code></td>
<td> <td>
Supports the operations and has the requirements of Supports the operations and has the requirements of
<ul> <ul>
<li><code><a href="#forward_iteratable">forward_iteratable&lt;T, <li><code><a href="#forward_iteratable">forward_iteratable&lt;T,
@ -1901,7 +1912,7 @@ T operator+( T lhs, const T&amp; rhs )
V, D, P, R&gt;</a></code></td> V, D, P, R&gt;</a></code></td>
<td> <td>
Supports the operations and has the requirements of Supports the operations and has the requirements of
<ul> <ul>
<li><code><a href= <li><code><a href=
@ -1917,7 +1928,7 @@ T operator+( T lhs, const T&amp; rhs )
V, D, P, R&gt;</a></code></td> V, D, P, R&gt;</a></code></td>
<td> <td>
Supports the operations and has the requirements of Supports the operations and has the requirements of
<ul> <ul>
<li><code><a href= <li><code><a href=
@ -1968,8 +1979,8 @@ struct function_output_iterator
template&lt;typename T&gt; template&lt;typename T&gt;
function_output_iterator&amp; operator=(T const&amp; value) function_output_iterator&amp; operator=(T const&amp; value)
{ {
this-&gt;func(value); this-&gt;func(value);
return *this; return *this;
} }
private: private:
@ -2022,20 +2033,20 @@ public:
</pre> </pre>
</blockquote> </blockquote>
<p>Check the <a href="../../status/compiler_status.html">compiler status <p>Check the <a href="http://www.boost.org/development/testing.html">compiler status
report</a> for the test results with selected platforms.</p> report</a> for the test results with selected platforms.</p>
<hr> <hr>
<h2><a name="contributors">Contributors</a></h2> <h2><a name="contributors">Contributors</a></h2>
<dl> <dl>
<dt><a href="../../people/dave_abrahams.htm">Dave Abrahams</a></dt> <dt><a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a></dt>
<dd>Started the library and contributed the arithmetic operators in <dd>Started the library and contributed the arithmetic operators in
<cite><a href= <cite><a href=
"../../boost/operators.hpp">boost/operators.hpp</a></cite>.</dd> "../../boost/operators.hpp">boost/operators.hpp</a></cite>.</dd>
<dt><a href="../../people/jeremy_siek.htm">Jeremy Siek</a></dt> <dt><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a></dt>
<dd>Contributed the <a href="#deref">dereference operators and iterator <dd>Contributed the <a href="#deref">dereference operators and iterator
helpers</a> in <cite><a href= helpers</a> in <cite><a href=
@ -2043,19 +2054,19 @@ public:
contributed <cite><a href= contributed <cite><a href=
"iterators_test.cpp">iterators_test.cpp</a></cite>.</dd> "iterators_test.cpp">iterators_test.cpp</a></cite>.</dd>
<dt><a href="../../people/aleksey_gurtovoy.htm">Aleksey <dt><a href="http://www.boost.org/people/aleksey_gurtovoy.htm">Aleksey
Gurtovoy</a></dt> Gurtovoy</a></dt>
<dd>Contributed the code to support <a href="#chaining">base class <dd>Contributed the code to support <a href="#chaining">base class
chaining</a> while remaining backward-compatible with old versions of chaining</a> while remaining backward-compatible with old versions of
the library.</dd> the library.</dd>
<dt><a href="../../people/beman_dawes.html">Beman Dawes</a></dt> <dt><a href="http://www.boost.org/people/beman_dawes.html">Beman Dawes</a></dt>
<dd>Contributed <cite><a href= <dd>Contributed <cite><a href=
"operators_test.cpp">operators_test.cpp</a></cite>.</dd> "operators_test.cpp">operators_test.cpp</a></cite>.</dd>
<dt><a href="../../people/daryle_walker.html">Daryle Walker</a></dt> <dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a></dt>
<dd>Contributed classes for the shift operators, equivalence, partial <dd>Contributed classes for the shift operators, equivalence, partial
ordering, and arithmetic conversions. Added the grouped operator ordering, and arithmetic conversions. Added the grouped operator
@ -2119,11 +2130,11 @@ public:
backward-compatible.</p> backward-compatible.</p>
<hr> <hr>
<p>Revised: 29 Oct 2004</p> <p>Revised: 7 Aug 2008</p>
<p>Copyright &copy; Beman Dawes, David Abrahams, 1999-2001.</p> <p>Copyright &copy; Beman Dawes, David Abrahams, 1999-2001.</p>
<p>Copyright &copy; Daniel Frey, 2002-2004.</p> <p>Copyright &copy; Daniel Frey, 2002-2009.</p>
<p>Use, modification, and distribution is subject to the Boost Software <p>Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file License, Version 1.0. (See accompanying file
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
<a href="http://www.boost.org/LICENSE_1_0.txt"> <a href="http://www.boost.org/LICENSE_1_0.txt">

View File

@ -7,6 +7,7 @@
// See http://www.boost.org/libs/utility for documentation. // See http://www.boost.org/libs/utility for documentation.
// Revision History // Revision History
// 03 Apr 08 Added convertible_to_bool (Daniel Frey)
// 01 Oct 01 Added tests for "left" operators // 01 Oct 01 Added tests for "left" operators
// and new grouped operators. (Helmut Zeisel) // and new grouped operators. (Helmut Zeisel)
// 20 May 01 Output progress messages. Added tests for new operator // 20 May 01 Output progress messages. Added tests for new operator
@ -43,6 +44,23 @@ namespace
unsigned char true_value(unsigned char x) { return x; } unsigned char true_value(unsigned char x) { return x; }
unsigned short true_value(unsigned short x) { return x; } unsigned short true_value(unsigned short x) { return x; }
// verify the minimum requirements for some operators
class convertible_to_bool
{
private:
bool _value;
typedef bool convertible_to_bool::*unspecified_bool_type;
void operator!() const;
public:
convertible_to_bool( const bool value ) : _value( value ) {}
operator unspecified_bool_type() const
{ return _value ? &convertible_to_bool::_value : 0; }
};
// The use of operators<> here tended to obscure // The use of operators<> here tended to obscure
// interactions with certain compiler bugs // interactions with certain compiler bugs
template <class T> template <class T>
@ -54,8 +72,10 @@ namespace
explicit Wrapped1( T v = T() ) : _value(v) {} explicit Wrapped1( T v = T() ) : _value(v) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped1& x) const { return _value < x._value; } convertible_to_bool operator<(const Wrapped1& x) const
bool operator==(const Wrapped1& x) const { return _value == x._value; } { return _value < x._value; }
convertible_to_bool operator==(const Wrapped1& x) const
{ return _value == x._value; }
Wrapped1& operator+=(const Wrapped1& x) Wrapped1& operator+=(const Wrapped1& x)
{ _value += x._value; return *this; } { _value += x._value; return *this; }
@ -97,8 +117,10 @@ namespace
explicit Wrapped2( T v = T() ) : _value(v) {} explicit Wrapped2( T v = T() ) : _value(v) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped2& x) const { return _value < x._value; } convertible_to_bool operator<(const Wrapped2& x) const
bool operator==(const Wrapped2& x) const { return _value == x._value; } { return _value < x._value; }
convertible_to_bool operator==(const Wrapped2& x) const
{ return _value == x._value; }
Wrapped2& operator+=(const Wrapped2& x) Wrapped2& operator+=(const Wrapped2& x)
{ _value += x._value; return *this; } { _value += x._value; return *this; }
@ -123,9 +145,13 @@ namespace
Wrapped2& operator++() { ++_value; return *this; } Wrapped2& operator++() { ++_value; return *this; }
Wrapped2& operator--() { --_value; return *this; } Wrapped2& operator--() { --_value; return *this; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(U u) const
bool operator>(U u) const { return _value > u; } { return _value < u; }
bool operator==(U u) const { return _value == u; } convertible_to_bool operator>(U u) const
{ return _value > u; }
convertible_to_bool operator==(U u) const
{ return _value == u; }
Wrapped2& operator+=(U u) { _value += u; return *this; } Wrapped2& operator+=(U u) { _value += u; return *this; }
Wrapped2& operator-=(U u) { _value -= u; return *this; } Wrapped2& operator-=(U u) { _value -= u; return *this; }
Wrapped2& operator*=(U u) { _value *= u; return *this; } Wrapped2& operator*=(U u) { _value *= u; return *this; }
@ -153,7 +179,8 @@ namespace
explicit Wrapped3( T v = T() ) : _value(v) {} explicit Wrapped3( T v = T() ) : _value(v) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped3& x) const { return _value < x._value; } convertible_to_bool operator<(const Wrapped3& x) const
{ return _value < x._value; }
private: private:
T _value; T _value;
@ -174,10 +201,13 @@ namespace
explicit Wrapped4( T v = T() ) : _value(v) {} explicit Wrapped4( T v = T() ) : _value(v) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped4& x) const { return _value < x._value; } convertible_to_bool operator<(const Wrapped4& x) const
{ return _value < x._value; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(U u) const
bool operator>(U u) const { return _value > u; } { return _value < u; }
convertible_to_bool operator>(U u) const
{ return _value > u; }
private: private:
T _value; T _value;
@ -198,11 +228,18 @@ namespace
Wrapped5(U u) : _value(u) {} Wrapped5(U u) : _value(u) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped5& x) const { return _value < x._value; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(const Wrapped5& x) const
bool operator>(U u) const { return _value > u; } { return _value < x._value; }
bool operator==(const Wrapped5& u) const { return _value == u._value; } convertible_to_bool operator<(U u) const
bool operator==(U u) const { return _value == u; } { return _value < u; }
convertible_to_bool operator>(U u) const
{ return _value > u; }
convertible_to_bool operator==(const Wrapped5& u) const
{ return _value == u._value; }
convertible_to_bool operator==(U u) const
{ return _value == u; }
Wrapped5& operator/=(const Wrapped5& u) { _value /= u._value; return *this;} Wrapped5& operator/=(const Wrapped5& u) { _value /= u._value; return *this;}
Wrapped5& operator/=(U u) { _value /= u; return *this;} Wrapped5& operator/=(U u) { _value /= u; return *this;}
Wrapped5& operator*=(const Wrapped5& u) { _value *= u._value; return *this;} Wrapped5& operator*=(const Wrapped5& u) { _value *= u._value; return *this;}
@ -221,8 +258,8 @@ namespace
// U must be convertible to T // U must be convertible to T
template <class T, class U> template <class T, class U>
class Wrapped6 class Wrapped6
: boost::ordered_euclidian_ring_operators2<Wrapped6<T, U>, U> : boost::ordered_euclidean_ring_operators2<Wrapped6<T, U>, U>
, boost::ordered_euclidian_ring_operators1<Wrapped6<T, U> > , boost::ordered_euclidean_ring_operators1<Wrapped6<T, U> >
{ {
public: public:
explicit Wrapped6( T v = T() ) : _value(v) {} explicit Wrapped6( T v = T() ) : _value(v) {}
@ -231,11 +268,18 @@ namespace
Wrapped6(U u) : _value(u) {} Wrapped6(U u) : _value(u) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped6& x) const { return _value < x._value; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(const Wrapped6& x) const
bool operator>(U u) const { return _value > u; } { return _value < x._value; }
bool operator==(const Wrapped6& u) const { return _value == u._value; } convertible_to_bool operator<(U u) const
bool operator==(U u) const { return _value == u; } { return _value < u; }
convertible_to_bool operator>(U u) const
{ return _value > u; }
convertible_to_bool operator==(const Wrapped6& u) const
{ return _value == u._value; }
convertible_to_bool operator==(U u) const
{ return _value == u; }
Wrapped6& operator%=(const Wrapped6& u) { _value %= u._value; return *this;} Wrapped6& operator%=(const Wrapped6& u) { _value %= u._value; return *this;}
Wrapped6& operator%=(U u) { _value %= u; return *this;} Wrapped6& operator%=(U u) { _value %= u; return *this;}
Wrapped6& operator/=(const Wrapped6& u) { _value /= u._value; return *this;} Wrapped6& operator/=(const Wrapped6& u) { _value /= u._value; return *this;}
@ -276,10 +320,10 @@ namespace
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{ {
BOOST_CHECK( (x1 < y1) == (x2 < y2) ); BOOST_CHECK( static_cast<bool>(x1 < y1) == static_cast<bool>(x2 < y2) );
BOOST_CHECK( (x1 <= y1) == (x2 <= y2) ); BOOST_CHECK( static_cast<bool>(x1 <= y1) == static_cast<bool>(x2 <= y2) );
BOOST_CHECK( (x1 >= y1) == (x2 >= y2) ); BOOST_CHECK( static_cast<bool>(x1 >= y1) == static_cast<bool>(x2 >= y2) );
BOOST_CHECK( (x1 > y1) == (x2 > y2) ); BOOST_CHECK( static_cast<bool>(x1 > y1) == static_cast<bool>(x2 > y2) );
} }
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
@ -293,8 +337,8 @@ namespace
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{ {
BOOST_CHECK( (x1 == y1) == (x2 == y2) ); BOOST_CHECK( static_cast<bool>(x1 == y1) == static_cast<bool>(x2 == y2) );
BOOST_CHECK( (x1 != y1) == (x2 != y2) ); BOOST_CHECK( static_cast<bool>(x1 != y1) == static_cast<bool>(x2 != y2) );
} }
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
@ -614,14 +658,14 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) ); PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) );
BOOST_CHECK( i2 == i ); BOOST_CHECK( static_cast<bool>(i2 == i) );
BOOST_CHECK( i1 != i2 ); BOOST_CHECK( static_cast<bool>(i1 != i2) );
BOOST_CHECK( i1 < i2 ); BOOST_CHECK( static_cast<bool>(i1 < i2) );
BOOST_CHECK( i1 <= i2 ); BOOST_CHECK( static_cast<bool>(i1 <= i2) );
BOOST_CHECK( i <= i2 ); BOOST_CHECK( static_cast<bool>(i <= i2) );
BOOST_CHECK( i2 > i1 ); BOOST_CHECK( static_cast<bool>(i2 > i1) );
BOOST_CHECK( i2 >= i1 ); BOOST_CHECK( static_cast<bool>(i2 >= i1) );
BOOST_CHECK( i2 >= i ); BOOST_CHECK( static_cast<bool>(i2 >= i) );
PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) ); PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) );
PRIVATE_EXPR_TEST( (i = i + i2), (i.value() == 5) ); PRIVATE_EXPR_TEST( (i = i + i2), (i.value() == 5) );
@ -653,78 +697,78 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) );
BOOST_CHECK( j2 == j ); BOOST_CHECK( static_cast<bool>(j2 == j) );
BOOST_CHECK( 2 == j ); BOOST_CHECK( static_cast<bool>(2 == j) );
BOOST_CHECK( j2 == 2 ); BOOST_CHECK( static_cast<bool>(j2 == 2) );
BOOST_CHECK( j == j2 ); BOOST_CHECK( static_cast<bool>(j == j2) );
BOOST_CHECK( j1 != j2 ); BOOST_CHECK( static_cast<bool>(j1 != j2) );
BOOST_CHECK( j1 != 2 ); BOOST_CHECK( static_cast<bool>(j1 != 2) );
BOOST_CHECK( 1 != j2 ); BOOST_CHECK( static_cast<bool>(1 != j2) );
BOOST_CHECK( j1 < j2 ); BOOST_CHECK( static_cast<bool>(j1 < j2) );
BOOST_CHECK( 1 < j2 ); BOOST_CHECK( static_cast<bool>(1 < j2) );
BOOST_CHECK( j1 < 2 ); BOOST_CHECK( static_cast<bool>(j1 < 2) );
BOOST_CHECK( j1 <= j2 ); BOOST_CHECK( static_cast<bool>(j1 <= j2) );
BOOST_CHECK( 1 <= j2 ); BOOST_CHECK( static_cast<bool>(1 <= j2) );
BOOST_CHECK( j1 <= j ); BOOST_CHECK( static_cast<bool>(j1 <= j) );
BOOST_CHECK( j <= j2 ); BOOST_CHECK( static_cast<bool>(j <= j2) );
BOOST_CHECK( 2 <= j2 ); BOOST_CHECK( static_cast<bool>(2 <= j2) );
BOOST_CHECK( j <= 2 ); BOOST_CHECK( static_cast<bool>(j <= 2) );
BOOST_CHECK( j2 > j1 ); BOOST_CHECK( static_cast<bool>(j2 > j1) );
BOOST_CHECK( 2 > j1 ); BOOST_CHECK( static_cast<bool>(2 > j1) );
BOOST_CHECK( j2 > 1 ); BOOST_CHECK( static_cast<bool>(j2 > 1) );
BOOST_CHECK( j2 >= j1 ); BOOST_CHECK( static_cast<bool>(j2 >= j1) );
BOOST_CHECK( 2 >= j1 ); BOOST_CHECK( static_cast<bool>(2 >= j1) );
BOOST_CHECK( j2 >= 1 ); BOOST_CHECK( static_cast<bool>(j2 >= 1) );
BOOST_CHECK( j2 >= j ); BOOST_CHECK( static_cast<bool>(j2 >= j) );
BOOST_CHECK( 2 >= j ); BOOST_CHECK( static_cast<bool>(2 >= j) );
BOOST_CHECK( j2 >= 2 ); BOOST_CHECK( static_cast<bool>(j2 >= 2) );
BOOST_CHECK( (j1 + 2) == 3 ); BOOST_CHECK( static_cast<bool>((j1 + 2) == 3) );
BOOST_CHECK( (1 + j2) == 3 ); BOOST_CHECK( static_cast<bool>((1 + j2) == 3) );
PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) ); PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) );
BOOST_CHECK( (j + 2) == 5 ); BOOST_CHECK( static_cast<bool>((j + 2) == 5) );
BOOST_CHECK( (3 + j2) == 5 ); BOOST_CHECK( static_cast<bool>((3 + j2) == 5) );
PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) ); PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) );
BOOST_CHECK( (j - 1) == 4 ); BOOST_CHECK( static_cast<bool>((j - 1) == 4) );
PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) );
BOOST_CHECK( (j * 2) == 8 ); BOOST_CHECK( static_cast<bool>((j * 2) == 8) );
BOOST_CHECK( (4 * j2) == 8 ); BOOST_CHECK( static_cast<bool>((4 * j2) == 8) );
PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) ); PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) );
BOOST_CHECK( (j / 2) == 4 ); BOOST_CHECK( static_cast<bool>((j / 2) == 4) );
PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) );
BOOST_CHECK( (j % 3) == 1 ); BOOST_CHECK( static_cast<bool>((j % 3) == 1) );
PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) ); PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) );
PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) );
BOOST_CHECK( (1 | j2 | j) == 7 ); BOOST_CHECK( static_cast<bool>((1 | j2 | j) == 7) );
BOOST_CHECK( (j1 | 2 | j) == 7 ); BOOST_CHECK( static_cast<bool>((j1 | 2 | j) == 7) );
BOOST_CHECK( (j1 | j2 | 4) == 7 ); BOOST_CHECK( static_cast<bool>((j1 | j2 | 4) == 7) );
PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) ); PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) );
BOOST_CHECK( (7 & j2) == 2 ); BOOST_CHECK( static_cast<bool>((7 & j2) == 2) );
BOOST_CHECK( (j & 2) == 2 ); BOOST_CHECK( static_cast<bool>((j & 2) == 2) );
PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) );
PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) ); PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) );
BOOST_CHECK( (3 ^ j1) == 2 ); BOOST_CHECK( static_cast<bool>((3 ^ j1) == 2) );
BOOST_CHECK( (j ^ 1) == 2 ); BOOST_CHECK( static_cast<bool>((j ^ 1) == 2) );
PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) );
PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) ); PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) );
BOOST_CHECK( (j1 << 2) == 4 ); BOOST_CHECK( static_cast<bool>((j1 << 2) == 4) );
BOOST_CHECK( (j2 << 1) == 4 ); BOOST_CHECK( static_cast<bool>((j2 << 1) == 4) );
PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) );
BOOST_CHECK( (j >> 2) == 1 ); BOOST_CHECK( static_cast<bool>((j >> 2) == 1) );
BOOST_CHECK( (j2 >> 1) == 1 ); BOOST_CHECK( static_cast<bool>((j2 >> 1) == 1) );
PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) ); PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) );
cout << "Performed tests on MyLong objects.\n"; cout << "Performed tests on MyLong objects.\n";
@ -741,14 +785,14 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) ); PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) );
BOOST_CHECK( k2 == k ); BOOST_CHECK( static_cast<bool>(k2 == k) );
BOOST_CHECK( k1 != k2 ); BOOST_CHECK( static_cast<bool>(k1 != k2) );
BOOST_CHECK( k1 < k2 ); BOOST_CHECK( static_cast<bool>(k1 < k2) );
BOOST_CHECK( k1 <= k2 ); BOOST_CHECK( static_cast<bool>(k1 <= k2) );
BOOST_CHECK( k <= k2 ); BOOST_CHECK( static_cast<bool>(k <= k2) );
BOOST_CHECK( k2 > k1 ); BOOST_CHECK( static_cast<bool>(k2 > k1) );
BOOST_CHECK( k2 >= k1 ); BOOST_CHECK( static_cast<bool>(k2 >= k1) );
BOOST_CHECK( k2 >= k ); BOOST_CHECK( static_cast<bool>(k2 >= k) );
cout << "Performed tests on MyChar objects.\n"; cout << "Performed tests on MyChar objects.\n";
@ -764,31 +808,31 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) ); PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) );
BOOST_CHECK( l2 == l ); BOOST_CHECK( static_cast<bool>(l2 == l) );
BOOST_CHECK( 2 == l ); BOOST_CHECK( static_cast<bool>(2 == l) );
BOOST_CHECK( l2 == 2 ); BOOST_CHECK( static_cast<bool>(l2 == 2) );
BOOST_CHECK( l == l2 ); BOOST_CHECK( static_cast<bool>(l == l2) );
BOOST_CHECK( l1 != l2 ); BOOST_CHECK( static_cast<bool>(l1 != l2) );
BOOST_CHECK( l1 != 2 ); BOOST_CHECK( static_cast<bool>(l1 != 2) );
BOOST_CHECK( 1 != l2 ); BOOST_CHECK( static_cast<bool>(1 != l2) );
BOOST_CHECK( l1 < l2 ); BOOST_CHECK( static_cast<bool>(l1 < l2) );
BOOST_CHECK( 1 < l2 ); BOOST_CHECK( static_cast<bool>(1 < l2) );
BOOST_CHECK( l1 < 2 ); BOOST_CHECK( static_cast<bool>(l1 < 2) );
BOOST_CHECK( l1 <= l2 ); BOOST_CHECK( static_cast<bool>(l1 <= l2) );
BOOST_CHECK( 1 <= l2 ); BOOST_CHECK( static_cast<bool>(1 <= l2) );
BOOST_CHECK( l1 <= l ); BOOST_CHECK( static_cast<bool>(l1 <= l) );
BOOST_CHECK( l <= l2 ); BOOST_CHECK( static_cast<bool>(l <= l2) );
BOOST_CHECK( 2 <= l2 ); BOOST_CHECK( static_cast<bool>(2 <= l2) );
BOOST_CHECK( l <= 2 ); BOOST_CHECK( static_cast<bool>(l <= 2) );
BOOST_CHECK( l2 > l1 ); BOOST_CHECK( static_cast<bool>(l2 > l1) );
BOOST_CHECK( 2 > l1 ); BOOST_CHECK( static_cast<bool>(2 > l1) );
BOOST_CHECK( l2 > 1 ); BOOST_CHECK( static_cast<bool>(l2 > 1) );
BOOST_CHECK( l2 >= l1 ); BOOST_CHECK( static_cast<bool>(l2 >= l1) );
BOOST_CHECK( 2 >= l1 ); BOOST_CHECK( static_cast<bool>(2 >= l1) );
BOOST_CHECK( l2 >= 1 ); BOOST_CHECK( static_cast<bool>(l2 >= 1) );
BOOST_CHECK( l2 >= l ); BOOST_CHECK( static_cast<bool>(l2 >= l) );
BOOST_CHECK( 2 >= l ); BOOST_CHECK( static_cast<bool>(2 >= l) );
BOOST_CHECK( l2 >= 2 ); BOOST_CHECK( static_cast<bool>(l2 >= 2) );
cout << "Performed tests on MyShort objects.\n"; cout << "Performed tests on MyShort objects.\n";
@ -807,37 +851,37 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) ); PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) );
BOOST_CHECK( di2 == di ); BOOST_CHECK( static_cast<bool>(di2 == di) );
BOOST_CHECK( 2 == di ); BOOST_CHECK( static_cast<bool>(2 == di) );
BOOST_CHECK( di == 2 ); BOOST_CHECK( static_cast<bool>(di == 2) );
BOOST_CHECK( di1 < di2 ); BOOST_CHECK( static_cast<bool>(di1 < di2) );
BOOST_CHECK( 1 < di2 ); BOOST_CHECK( static_cast<bool>(1 < di2) );
BOOST_CHECK( di1 <= di2 ); BOOST_CHECK( static_cast<bool>(di1 <= di2) );
BOOST_CHECK( 1 <= di2 ); BOOST_CHECK( static_cast<bool>(1 <= di2) );
BOOST_CHECK( di2 > di1 ); BOOST_CHECK( static_cast<bool>(di2 > di1) );
BOOST_CHECK( di2 > 1 ); BOOST_CHECK( static_cast<bool>(di2 > 1) );
BOOST_CHECK( di2 >= di1 ); BOOST_CHECK( static_cast<bool>(di2 >= di1) );
BOOST_CHECK( di2 >= 1 ); BOOST_CHECK( static_cast<bool>(di2 >= 1) );
BOOST_CHECK( di1 / di2 == half ); BOOST_CHECK( static_cast<bool>(di1 / di2 == half) );
BOOST_CHECK( di1 / 2 == half ); BOOST_CHECK( static_cast<bool>(di1 / 2 == half) );
BOOST_CHECK( 1 / di2 == half ); BOOST_CHECK( static_cast<bool>(1 / di2 == half) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=2) == half) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=2) == half) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=di2) == half) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=di2) == half) );
BOOST_CHECK( di1 * di2 == di2 ); BOOST_CHECK( static_cast<bool>(di1 * di2 == di2) );
BOOST_CHECK( di1 * 2 == di2 ); BOOST_CHECK( static_cast<bool>(di1 * 2 == di2) );
BOOST_CHECK( 1 * di2 == di2 ); BOOST_CHECK( static_cast<bool>(1 * di2 == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=2) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=2) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=di2) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=di2) == di2) );
BOOST_CHECK( di2 - di1 == di1 ); BOOST_CHECK( static_cast<bool>(di2 - di1 == di1) );
BOOST_CHECK( di2 - 1 == di1 ); BOOST_CHECK( static_cast<bool>(di2 - 1 == di1) );
BOOST_CHECK( 2 - di1 == di1 ); BOOST_CHECK( static_cast<bool>(2 - di1 == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=1) == di1) ); PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=1) == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=di1) == di1) ); PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=di1) == di1) );
BOOST_CHECK( di1 + di1 == di2 ); BOOST_CHECK( static_cast<bool>(di1 + di1 == di2) );
BOOST_CHECK( di1 + 1 == di2 ); BOOST_CHECK( static_cast<bool>(di1 + 1 == di2) );
BOOST_CHECK( 1 + di1 == di2 ); BOOST_CHECK( static_cast<bool>(1 + di1 == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=1) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=1) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=di1) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=di1) == di2) );
cout << "Performed tests on MyDoubleInt objects.\n"; cout << "Performed tests on MyDoubleInt objects.\n";
@ -854,42 +898,42 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) ); PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) );
BOOST_CHECK( li2 == li ); BOOST_CHECK( static_cast<bool>(li2 == li) );
BOOST_CHECK( 2 == li ); BOOST_CHECK( static_cast<bool>(2 == li) );
BOOST_CHECK( li == 2 ); BOOST_CHECK( static_cast<bool>(li == 2) );
BOOST_CHECK( li1 < li2 ); BOOST_CHECK( static_cast<bool>(li1 < li2) );
BOOST_CHECK( 1 < li2 ); BOOST_CHECK( static_cast<bool>(1 < li2) );
BOOST_CHECK( li1 <= li2 ); BOOST_CHECK( static_cast<bool>(li1 <= li2) );
BOOST_CHECK( 1 <= li2 ); BOOST_CHECK( static_cast<bool>(1 <= li2) );
BOOST_CHECK( li2 > li1 ); BOOST_CHECK( static_cast<bool>(li2 > li1) );
BOOST_CHECK( li2 > 1 ); BOOST_CHECK( static_cast<bool>(li2 > 1) );
BOOST_CHECK( li2 >= li1 ); BOOST_CHECK( static_cast<bool>(li2 >= li1) );
BOOST_CHECK( li2 >= 1 ); BOOST_CHECK( static_cast<bool>(li2 >= 1) );
BOOST_CHECK( li1 % li2 == li1 ); BOOST_CHECK( static_cast<bool>(li1 % li2 == li1) );
BOOST_CHECK( li1 % 2 == li1 ); BOOST_CHECK( static_cast<bool>(li1 % 2 == li1) );
BOOST_CHECK( 1 % li2 == li1 ); BOOST_CHECK( static_cast<bool>(1 % li2 == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=2) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=2) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=li2) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=li2) == li1) );
BOOST_CHECK( li1 / li2 == 0 ); BOOST_CHECK( static_cast<bool>(li1 / li2 == 0) );
BOOST_CHECK( li1 / 2 == 0 ); BOOST_CHECK( static_cast<bool>(li1 / 2 == 0) );
BOOST_CHECK( 1 / li2 == 0 ); BOOST_CHECK( static_cast<bool>(1 / li2 == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=2) == 0) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=2) == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=li2) == 0) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=li2) == 0) );
BOOST_CHECK( li1 * li2 == li2 ); BOOST_CHECK( static_cast<bool>(li1 * li2 == li2) );
BOOST_CHECK( li1 * 2 == li2 ); BOOST_CHECK( static_cast<bool>(li1 * 2 == li2) );
BOOST_CHECK( 1 * li2 == li2 ); BOOST_CHECK( static_cast<bool>(1 * li2 == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=2) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=2) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=li2) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=li2) == li2) );
BOOST_CHECK( li2 - li1 == li1 ); BOOST_CHECK( static_cast<bool>(li2 - li1 == li1) );
BOOST_CHECK( li2 - 1 == li1 ); BOOST_CHECK( static_cast<bool>(li2 - 1 == li1) );
BOOST_CHECK( 2 - li1 == li1 ); BOOST_CHECK( static_cast<bool>(2 - li1 == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=1) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=1) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=li1) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=li1) == li1) );
BOOST_CHECK( li1 + li1 == li2 ); BOOST_CHECK( static_cast<bool>(li1 + li1 == li2) );
BOOST_CHECK( li1 + 1 == li2 ); BOOST_CHECK( static_cast<bool>(li1 + 1 == li2) );
BOOST_CHECK( 1 + li1 == li2 ); BOOST_CHECK( static_cast<bool>(1 + li1 == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=1) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=1) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=li1) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=li1) == li2) );
cout << "Performed tests on MyLongInt objects.\n"; cout << "Performed tests on MyLongInt objects.\n";

View File

@ -68,11 +68,54 @@ struct ref_wrapper
} }
}; };
struct copy_counter {
static int count_;
copy_counter(copy_counter const& /*other*/) {
++count_;
}
copy_counter() {}
static void reset() { count_ = 0; }
static int count() { return copy_counter::count_; }
};
int copy_counter::count_ = 0;
} // namespace unnamed } // namespace unnamed
template <class T>
void do_unwrap(T t) {
/* typename unwrap_reference<T>::type& lt = */
unwrap_ref(t);
}
void unwrap_test() {
int i = 3;
const int ci = 2;
do_unwrap(i);
do_unwrap(ci);
do_unwrap(ref(i));
do_unwrap(cref(ci));
do_unwrap(ref(ci));
copy_counter cc;
BOOST_CHECK(cc.count() == 0);
do_unwrap(cc);
do_unwrap(ref(cc));
do_unwrap(cref(cc));
BOOST_CHECK(cc.count() == 1);
BOOST_CHECK(unwrap_ref(ref(cc)).count() == 1);
}
int test_main(int, char * []) int test_main(int, char * [])
{ {
ref_wrapper<int>::test(1); ref_wrapper<int>::test(1);
ref_wrapper<int const>::test(1); ref_wrapper<int const>::test(1);
unwrap_test();
return 0; return 0;
} }

View File

@ -315,7 +315,7 @@ Last modified: Mon Aug 11 11:27:03 EST 2003
<p><EFBFBD> Copyright 2003 The Trustees of Indiana University. <p><EFBFBD> Copyright 2003 The Trustees of Indiana University.
Use, modification and distribution is subject to the Boost Software Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http:www.boost.org/LICENSE_1_0.txt)</p> http://www.boost.org/LICENSE_1_0.txt)</p>
</body> </body>

98
swap.html Normal file
View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Boost: Swap Documentation</title>
</head>
<body>
<!-- Page header -->
<h2>
<img src="../../boost.png" alt="C++ Boost" align="middle" width="277" height="86"/>
Header &lt;<a href="../../boost/swap.hpp">boost/swap.hpp</a>&gt;
</h2>
<h1>Swap</h1>
<p>
<tt>template&lt;class T&gt; void swap(T&amp; <em>left</em>, T&amp; <em>right</em>);</tt>
</p>
<!-- Introduction -->
<p>
The template function <tt>boost::swap</tt> allows the values of two variables to be swapped, using argument dependent lookup to select a specialized swap function if available. If no specialized swap function is available, <tt>std::swap</tt> is used.
</p>
<!-- Rationale -->
<h2>Rationale</h2>
<p>
The generic <tt>std::swap</tt> function requires that the elements to be swapped are assignable and copy constructible. It is usually implemented using one copy construction and two assignments - this is often both unnecessarily restrictive and unnecessarily slow. In addition, where the generic swap implementation provides only the basic guarantee, specialized swap functions are often able to provide the no-throw exception guarantee (and it is considered best practice to do so where possible<sup><a href="#ref1">1</a></sup>).</p>
<p>
The alternative to using argument dependent lookup in this situation is to provide a template specialization of <tt>std::swap</tt> for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces.
</p>
<p>
<tt>boost::swap</tt> also supports swapping built-in arrays. Note that <tt>std::swap</tt> originally did not do so, but a request to add an overload of <tt>std::swap</tt> for built-in arrays has been accepted by the C++ Standards Committee<sup><a href="#ref2">2</a></sup>.
</p>
<!-- Exception Safety -->
<h2>Exception Safety</h2>
<p>
<tt>boost::swap</tt> provides the same exception guarantee as the underlying swap function used, with one exception; for an array of type <tt>T[n]</tt>, where <tt>n > 1</tt> and the underlying swap function for <tt>T</tt> provides the strong exception guarantee, <tt>boost::swap</tt> provides only the basic exception guarantee.
</p>
<!-- Requirements -->
<h2>Requirements</h2>
<p>Either:</p>
<ul>
<li>T must be assignable</li>
<li>T must be copy constructible</li>
</ul>
<p>Or:</p>
<ul>
<li>A function with the signature <tt>swap(T&amp;,T&amp;)</tt> is available via argument dependent lookup</li>
</ul>
<p>Or:</p>
<ul>
<li>A template specialization of <tt>std::swap</tt> exists for T</li>
</ul>
<p>Or:</p>
<ul>
<li>T is a built-in array of swappable elements</li>
</ul>
<!-- Portability -->
<h2>Portability</h2>
<p>
Several older compilers do not support argument dependent lookup &#x2012; on these compilers <tt>boost::swap</tt> will call <tt>std::swap</tt>, ignoring any specialized swap functions that could be found as a result of argument dependent lookup.
</p>
<!-- Credits -->
<h2>Credits</h2>
<ul>
<li>
<em>Niels Dekker</em> - for implementing and documenting support for built-in arrays
</li>
<li>
<em><a href="mailto:Joseph.Gauterin@googlemail.com">Joseph Gauterin</a></em> - for the initial idea, implementation, tests, and documentation
</li>
<li>
<em>Steven Watanabe</em> - for the idea to make <tt>boost::swap</tt> less specialized than <tt>std::swap</tt>, thereby allowing the function to have the name 'swap' without introducing ambiguity
</li>
</ul>
<!-- References -->
<hr/>
<p><sup><a id="ref1"/>[1]</sup>Scott Meyers, Effective C++ Third Edition, Item 25: "Consider support for a non-throwing swap"</p>
<p><sup><a id="ref2"/>[2]</sup><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#809">LWG Defect Report 809 (std::swap should be overloaded for array types)</a></p>
<!-- Copyright info -->
<hr/>
<p>Revised: 08 September 2009</p>
<p>
Copyright 2007 - 2009 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0.
(See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at &lt;<a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>&gt;.)
</p>
</body>
</html>

37
swap/test/Jamfile.v2 Normal file
View File

@ -0,0 +1,37 @@
# Copyright (c) 2007, 2008 Joseph Gauterin
#
# 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)
# bring in rules for testing
import testing ;
test-suite utility/swap
:
[ compile root_header_1.cpp ]
[ compile root_header_2.cpp ]
[ compile lib_header_1.cpp ]
[ compile lib_header_2.cpp ]
[ compile mixed_headers_1.cpp ]
[ compile mixed_headers_2.cpp ]
[ run primitive.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run specialized_in_boost_and_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_bitset.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_dateorder.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_string.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_typeinfo_ptr.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_vector_of_boost.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run no_ambiguity_in_boost.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_array_of_class.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_array_of_int.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_class.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_int.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_template.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
;

View File

@ -0,0 +1,69 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in the global namespace
#include "./swap_test_class.hpp"
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
//Provide swap function in both the namespace of swap_test_class
//(which is the global namespace), and the std namespace.
//It's common to provide a swap function for a class in both
//namespaces. Scott Meyers recommends doing so: Effective C++,
//Third Edition, item 25, "Consider support for a non-throwing swap".
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
namespace std
{
template <>
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
const std::size_t first_dimension = 3;
const std::size_t second_dimension = 4;
const std::size_t number_of_elements = first_dimension * second_dimension;
swap_test_class array1[first_dimension][second_dimension];
swap_test_class array2[first_dimension][second_dimension];
swap_test_class* const ptr1 = array1[0];
swap_test_class* const ptr2 = array2[0];
for (std::size_t i = 0; i < number_of_elements; ++i)
{
ptr1[i].set_data( static_cast<int>(i) );
ptr2[i].set_data( static_cast<int>(i + number_of_elements) );
}
boost::swap(array1, array2);
for (std::size_t i = 0; i < number_of_elements; ++i)
{
BOOST_CHECK_EQUAL(ptr1[i].get_data(), static_cast<int>(i + number_of_elements) );
BOOST_CHECK_EQUAL(ptr2[i].get_data(), static_cast<int>(i) );
}
BOOST_CHECK_EQUAL(swap_test_class::swap_count(), number_of_elements);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0);
return 0;
}

View File

@ -0,0 +1,42 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping an array of arrays of integers by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
int test_main(int, char*[])
{
const std::size_t first_dimension = 3;
const std::size_t second_dimension = 4;
const std::size_t number_of_elements = first_dimension * second_dimension;
int array1[first_dimension][second_dimension];
int array2[first_dimension][second_dimension];
int* const ptr1 = array1[0];
int* const ptr2 = array2[0];
for (std::size_t i = 0; i < number_of_elements; ++i)
{
ptr1[i] = static_cast<int>(i);
ptr2[i] = static_cast<int>(i + number_of_elements);
}
boost::swap(array1, array2);
for (std::size_t i = 0; i < number_of_elements; ++i)
{
BOOST_CHECK_EQUAL(ptr1[i], static_cast<int>(i + number_of_elements) );
BOOST_CHECK_EQUAL(ptr2[i], static_cast<int>(i) );
}
return 0;
}

View File

@ -0,0 +1,61 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in the global namespace
#include "./swap_test_class.hpp"
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
//Provide swap function in both the namespace of swap_test_class
//(which is the global namespace), and the std namespace.
//It's common to provide a swap function for a class in both
//namespaces. Scott Meyers recommends doing so: Effective C++,
//Third Edition, item 25, "Consider support for a non-throwing swap".
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
namespace std
{
template <>
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
const std::size_t array_size = 2;
const swap_test_class initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) };
const swap_test_class initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) };
swap_test_class array1[array_size];
swap_test_class array2[array_size];
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
swap_test_class::reset();
boost::swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));
BOOST_CHECK_EQUAL(swap_test_class::swap_count(), array_size);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0);
return 0;
}

View File

@ -0,0 +1,35 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping an array of integers by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
int test_main(int, char*[])
{
const std::size_t array_size = 3;
const int initial_array1[array_size] = { 1, 2, 3 };
const int initial_array2[array_size] = { 4, 5, 6 };
int array1[array_size];
int array2[array_size];
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
boost::swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));
return 0;
}

View File

@ -0,0 +1,71 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping an array of swap_test_template<int> objects by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in the global namespace
#include "./swap_test_class.hpp"
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
template <class T>
class swap_test_template
{
public:
typedef T template_argument;
swap_test_class swap_test_object;
};
template <class T>
inline bool operator==(const swap_test_template<T> & lhs, const swap_test_template<T> & rhs)
{
return lhs.swap_test_object == rhs.swap_test_object;
}
template <class T>
inline bool operator!=(const swap_test_template<T> & lhs, const swap_test_template<T> & rhs)
{
return !(lhs == rhs);
}
//Provide swap function in the namespace of swap_test_template
//(which is the global namespace). Note that it isn't allowed to put
//an overload of this function within the std namespace.
template <class T>
void swap(swap_test_template<T>& left, swap_test_template<T>& right)
{
left.swap_test_object.swap(right.swap_test_object);
}
int test_main(int, char*[])
{
const std::size_t array_size = 2;
const swap_test_template<int> initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) };
const swap_test_template<int> initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) };
swap_test_template<int> array1[array_size];
swap_test_template<int> array2[array_size];
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
swap_test_class::reset();
boost::swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));
BOOST_CHECK_EQUAL(swap_test_class::swap_count(), array_size);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0);
return 0;
}

View File

@ -0,0 +1,10 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap header compiles as a standalone translation unit
#include <boost/utility/swap.hpp>

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap header include guards work correctly
#include <boost/utility/swap.hpp>
#include <boost/utility/swap.hpp>

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap headers work when both are included
#include <boost/swap.hpp>
#include <boost/utility/swap.hpp>

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap headers work when both are included
#include <boost/utility/swap.hpp>
#include <boost/swap.hpp>

View File

@ -0,0 +1,44 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// boost::swap internally does an unqualified function call to swap.
// This could have led to ambiguity or infinite recursion, when the
// objects to be swapped would themselves be from the boost namespace.
// If so, boost::swap itself might be found by argument dependent lookup.
// The implementation of boost::swap resolves this issue by giving
// boost::swap two template argumetns, thereby making it less specialized
// than std::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in namespace boost
namespace boost
{
#include "./swap_test_class.hpp"
}
int test_main(int, char*[])
{
const boost::swap_test_class initial_value1(1);
const boost::swap_test_class initial_value2(2);
boost::swap_test_class object1 = initial_value1;
boost::swap_test_class object2 = initial_value2;
boost::swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),0);
BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),3);
return 0;
}

23
swap/test/primitive.cpp Normal file
View File

@ -0,0 +1,23 @@
// Copyright (c) 2007 Joseph Gauterin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
int test_main(int, char*[])
{
int object1 = 1;
int object2 = 2;
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1,2);
BOOST_CHECK_EQUAL(object2,1);
return 0;
}

View File

@ -0,0 +1,10 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap header compiles as a standalone translation unit
#include <boost/swap.hpp>

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap header include guards work correctly
#include <boost/swap.hpp>
#include <boost/swap.hpp>

View File

@ -0,0 +1,45 @@
// Copyright (c) 2007 Joseph Gauterin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in namespace boost
namespace boost
{
#include "./swap_test_class.hpp"
}
//Provide swap function in namespace boost
namespace boost
{
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
const boost::swap_test_class initial_value1(1);
const boost::swap_test_class initial_value2(2);
boost::swap_test_class object1 = initial_value1;
boost::swap_test_class object2 = initial_value2;
boost::swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,64 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests whether instances of a class from a namespace other than boost are
// properly swapped, when both boost and the other namespace have a custom
// swap function for that class. Note that it shouldn't be necessary for a class
// in an other namespace to have a custom swap function in boost, because the
// boost::swap utility should find the swap function in the other namespace, by
// argument dependent lookup (ADL). Unfortunately ADL isn't fully implemented
// by some specific compiler versions, including Intel C++ 8.1, MSVC 7.1, and
// Borland 5.9.3. Users of those compilers might consider adding a swap overload
// to the boost namespace.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in namespace other
namespace other
{
#include "./swap_test_class.hpp"
}
//Provide swap function in namespace boost
namespace boost
{
void swap(::other::swap_test_class& left, ::other::swap_test_class& right)
{
left.swap(right);
}
}
//Provide swap function in namespace other
namespace other
{
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
const other::swap_test_class initial_value1(1);
const other::swap_test_class initial_value2(2);
other::swap_test_class object1 = initial_value1;
other::swap_test_class object2 = initial_value2;
other::swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,39 @@
// Copyright (c) 2007 Joseph Gauterin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in the global namespace
#include "./swap_test_class.hpp"
//Provide swap function in gloabl namespace
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
int test_main(int, char*[])
{
const swap_test_class initial_value1(1);
const swap_test_class initial_value2(2);
swap_test_class object1 = initial_value1;
swap_test_class object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,45 @@
// Copyright (c) 2007 Joseph Gauterin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in namespace other
namespace other
{
#include "./swap_test_class.hpp"
}
//Provide swap function in namespace other
namespace other
{
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
const other::swap_test_class initial_value1(1);
const other::swap_test_class initial_value2(2);
other::swap_test_class object1 = initial_value1;
other::swap_test_class object2 = initial_value2;
other::swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,44 @@
// Copyright (c) 2007 Joseph Gauterin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//Put test class in the global namespace
#include "./swap_test_class.hpp"
//Provide swap function in namespace std
namespace std
{
template <>
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
const swap_test_class initial_value1(1);
const swap_test_class initial_value2(2);
swap_test_class object1 = initial_value1;
swap_test_class object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);
return 0;
}

33
swap/test/std_bitset.cpp Normal file
View File

@ -0,0 +1,33 @@
// Copyright (c) 2008 - 2010 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::bitset<T> objects by means of boost::swap.
// Unlike most other Standard C++ Library template classes,
// std::bitset<T> does not have its own std::swap overload.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <bitset>
int test_main(int, char*[])
{
typedef std::bitset<8> bitset_type;
const bitset_type initial_value1 = 1;
const bitset_type initial_value2 = 2;
bitset_type object1 = initial_value1;
bitset_type object2 = initial_value2;
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1,initial_value2);
BOOST_CHECK_EQUAL(object2,initial_value1);
return 0;
}

View File

@ -0,0 +1,32 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::time_base::dateorder objects by means of boost::swap.
// std::time_base::dateorder is an enumerated type. It does not have an
// std::swap overload or template specialization.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <locale>
int test_main(int, char*[])
{
const std::time_base::dateorder initial_value1 = std::time_base::dmy;
const std::time_base::dateorder initial_value2 = std::time_base::mdy;
std::time_base::dateorder object1 = initial_value1;
std::time_base::dateorder object2 = initial_value2;
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1,initial_value2);
BOOST_CHECK_EQUAL(object2,initial_value1);
return 0;
}

31
swap/test/std_string.cpp Normal file
View File

@ -0,0 +1,31 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::string objects by means of boost::swap.
// std::string has its own std::swap overload.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <string>
int test_main(int, char*[])
{
const std::string initial_value1 = "one";
const std::string initial_value2 = "two";
std::string object1 = initial_value1;
std::string object2 = initial_value2;
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1,initial_value2);
BOOST_CHECK_EQUAL(object2,initial_value1);
return 0;
}

View File

@ -0,0 +1,32 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::type_info pointers by means of boost::swap.
// There is no std::swap overload or template specialization
// for std::type_info pointers.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <typeinfo>
int test_main(int, char*[])
{
const std::type_info * const initial_value1 = 0;
const std::type_info * const initial_value2 = &typeid(double);
const std::type_info * ptr1 = initial_value1;
const std::type_info * ptr2 = initial_value2;
boost::swap(ptr1,ptr2);
BOOST_CHECK_EQUAL(ptr1,initial_value2);
BOOST_CHECK_EQUAL(ptr2,initial_value1);
return 0;
}

View File

@ -0,0 +1,60 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::vector objects by means of boost::swap,
// having boost::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <vector>
//Put test class in namespace boost
namespace boost
{
#include "./swap_test_class.hpp"
}
//Provide swap function in namespace boost
namespace boost
{
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
typedef boost::swap_test_class swap_test_class_type;
typedef std::vector<swap_test_class_type> vector_type;
const vector_type::size_type initial_size1 = 1;
const vector_type::size_type initial_size2 = 2;
const vector_type initial_value1(initial_size1, swap_test_class_type(1));
const vector_type initial_value2(initial_size2, swap_test_class_type(2));
vector_type object1 = initial_value1;
vector_type object2 = initial_value2;
swap_test_class_type::reset();
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
BOOST_CHECK_EQUAL(object2.size(),initial_size1);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0);
BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,53 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::vector objects by means of boost::swap,
// having ::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <vector>
//Put test class in the global namespace
#include "./swap_test_class.hpp"
//Provide swap function in the global namespace
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
int test_main(int, char*[])
{
typedef std::vector<swap_test_class> vector_type;
const vector_type::size_type initial_size1 = 1;
const vector_type::size_type initial_size2 = 2;
const vector_type initial_value1(initial_size1, swap_test_class(1));
const vector_type initial_value2(initial_size2, swap_test_class(2));
vector_type object1 = initial_value1;
vector_type object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
BOOST_CHECK_EQUAL(object2.size(),initial_size1);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class::swap_count(),0);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,60 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// 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)
// Tests swapping std::vector objects by means of boost::swap,
// having other::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <vector>
//Put test class in namespace other
namespace other
{
#include "./swap_test_class.hpp"
}
//Provide swap function in namespace other
namespace other
{
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
}
}
int test_main(int, char*[])
{
typedef other::swap_test_class swap_test_class_type;
typedef std::vector<swap_test_class_type> vector_type;
const vector_type::size_type initial_size1 = 1;
const vector_type::size_type initial_size2 = 2;
const vector_type initial_value1(initial_size1, swap_test_class_type(1));
const vector_type initial_value2(initial_size2, swap_test_class_type(2));
vector_type object1 = initial_value1;
vector_type object2 = initial_value2;
swap_test_class_type::reset();
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
BOOST_CHECK_EQUAL(object2.size(),initial_size1);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0);
BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0);
return 0;
}

View File

@ -0,0 +1,114 @@
// Copyright (c) 2007-2008 Joseph Gauterin
//
// 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)
// Tests class used by the Boost.Swap tests
#ifndef BOOST_UTILITY_SWAP_TEST_CLASS_HPP
#define BOOST_UTILITY_SWAP_TEST_CLASS_HPP
class swap_test_class
{
int m_data;
public:
explicit swap_test_class(int arg = 0)
:
m_data(arg)
{
++constructCount();
}
~swap_test_class()
{
++destructCount();
}
swap_test_class(const swap_test_class& arg)
:
m_data(arg.m_data)
{
++copyCount();
++destructCount();
}
swap_test_class& operator=(const swap_test_class& arg)
{
m_data = arg.m_data;
++copyCount();
return *this;
}
void swap(swap_test_class& other)
{
const int temp = m_data;
m_data = other.m_data;
other.m_data = temp;
++swapCount();
}
int get_data() const
{
return m_data;
}
void set_data(int arg)
{
m_data = arg;
}
static unsigned int swap_count(){ return swapCount(); }
static unsigned int copy_count(){ return copyCount(); }
static unsigned int construct_count(){ return constructCount(); }
static unsigned int destruct_count(){ return destructCount(); }
static void reset()
{
swapCount() = 0;
copyCount() = 0;
constructCount() = 0;
destructCount() = 0;
}
private:
static unsigned int& swapCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& copyCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& constructCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& destructCount()
{
static unsigned int value = 0;
return value;
}
};
inline bool operator==(const swap_test_class & lhs, const swap_test_class & rhs)
{
return lhs.get_data() == rhs.get_data();
}
inline bool operator!=(const swap_test_class & lhs, const swap_test_class & rhs)
{
return !(lhs == rhs);
}
#endif

View File

@ -1,8 +1,7 @@
# Copyright David Abrahams 2003. Permission to copy, use, # Copyright David Abrahams 2003.
# modify, sell and distribute this software is granted provided this
# copyright notice appears in all copies. This software is provided # Distributed under the Boost Software License, Version 1.0.
# "as is" without express or implied warranty, and with no claim as # See http://www.boost.org/LICENSE_1_0.txt
# to its suitability for any purpose.
# For more information, see http://www.boost.org/ # For more information, see http://www.boost.org/
@ -12,10 +11,13 @@ import testing ;
# Please keep the tests ordered by filename # Please keep the tests ordered by filename
test-suite utility test-suite utility
: :
[ run ../addressof_fn_test.cpp ]
[ run ../addressof_test.cpp ] [ run ../addressof_test.cpp ]
[ run ../addressof_test2.cpp ]
[ run ../assert_test.cpp ] [ run ../assert_test.cpp ]
[ run ../base_from_member_test.cpp ] [ run ../base_from_member_test.cpp ]
[ run ../binary_search_test.cpp ] [ run ../binary_search_test.cpp ]
[ run ../binary_test.cpp ]
[ run ../call_traits_test.cpp : -u ] [ run ../call_traits_test.cpp : -u ]
[ compile-fail ../checked_delete_test.cpp ] [ compile-fail ../checked_delete_test.cpp ]
[ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/<link>static : -u ] [ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/<link>static : -u ]
@ -30,7 +32,12 @@ test-suite utility
[ compile result_of_test.cpp ] [ compile result_of_test.cpp ]
[ run ../shared_iterator_test.cpp ] [ run ../shared_iterator_test.cpp ]
[ run ../value_init_test.cpp ] [ run ../value_init_test.cpp ]
[ run ../initialized_test.cpp ]
[ compile-fail ../value_init_test_fail1.cpp ] [ compile-fail ../value_init_test_fail1.cpp ]
[ compile-fail ../value_init_test_fail2.cpp ] [ compile-fail ../value_init_test_fail2.cpp ]
[ compile-fail ../value_init_test_fail3.cpp ] [ compile-fail ../value_init_test_fail3.cpp ]
[ compile-fail ../initialized_test_fail1.cpp ]
[ compile-fail ../initialized_test_fail2.cpp ]
[ run ../verify_test.cpp ]
; ;

0
test/next_prior_test.cpp Executable file → Normal file
View File

View File

@ -5,41 +5,109 @@
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_RESULT_OF_USE_DECLTYPE
// For more information, see http://www.boost.org/libs/utility // For more information, see http://www.boost.org/libs/utility
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <utility> #include <utility>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
struct int_result_type { typedef int result_type; }; struct int_result_type
{
typedef int result_type;
result_type operator()(float);
};
struct int_result_of struct int_result_of
{ {
template<typename F> struct result { typedef int type; }; template<typename F> struct result { typedef int type; };
result<int_result_of(double)>::type operator()(double);
result<const int_result_of(double)>::type operator()(double) const;
result<int_result_of()>::type operator()();
result<volatile int_result_of()>::type operator()() volatile;
}; };
struct int_result_type_and_float_result_of struct int_result_type_and_float_result_of_and_char_return
{ {
typedef int result_type; typedef int result_type;
template<typename F> struct result { typedef float type; }; template<typename F> struct result { typedef float type; };
char operator()(char);
}; };
template<typename T> template<typename T>
struct int_result_type_template { typedef int result_type; }; struct int_result_type_template
{
typedef int result_type;
result_type operator()(float);
};
template<typename T> template<typename T>
struct int_result_of_template struct int_result_of_template
{ {
template<typename F> struct result; template<typename F> struct result;
template<typename This, typename That> struct result<This(That)> { typedef int type; }; template<typename This, typename That> struct result<This(That)> { typedef int type; };
typename result<int_result_of_template<T>(double)>::type operator()(double);
typename result<const int_result_of_template<T>(double)>::type operator()(double) const;
typename result<int_result_of_template<T>(double)>::type operator()();
typename result<volatile int_result_of_template<T>(double)>::type operator()() volatile;
}; };
template<typename T> template<typename T>
struct int_result_type_and_float_result_of_template struct int_result_type_and_float_result_of_and_char_return_template
{ {
typedef int result_type; typedef int result_type;
template<typename F> struct result; template<typename F> struct result;
template<typename This, typename That> struct result<This(That)> { typedef float type; }; template<typename This, typename That> struct result<This(That)> { typedef float type; };
char operator()(char);
};
struct result_of_member_function_template
{
template<typename F> struct result;
template<typename This, typename That> struct result<This(That)> { typedef That type; };
template<class T> typename result<result_of_member_function_template(T)>::type operator()(T);
template<typename This, typename That> struct result<const This(That)> { typedef const That type; };
template<class T> typename result<const result_of_member_function_template(T)>::type operator()(T) const;
template<typename This, typename That> struct result<volatile This(That)> { typedef volatile That type; };
template<class T> typename result<volatile result_of_member_function_template(T)>::type operator()(T) volatile;
template<typename This, typename That> struct result<const volatile This(That)> { typedef const volatile That type; };
template<class T> typename result<const volatile result_of_member_function_template(T)>::type operator()(T) const volatile;
template<typename This, typename That> struct result<This(That &, That)> { typedef That & type; };
template<class T> typename result<result_of_member_function_template(T &, T)>::type operator()(T &, T);
template<typename This, typename That> struct result<This(That const &, That)> { typedef That const & type; };
template<class T> typename result<result_of_member_function_template(T const &, T)>::type operator()(T const &, T);
template<typename This, typename That> struct result<This(That volatile &, That)> { typedef That volatile & type; };
template<class T> typename result<result_of_member_function_template(T volatile &, T)>::type operator()(T volatile &, T);
template<typename This, typename That> struct result<This(That const volatile &, That)> { typedef That const volatile & type; };
template<class T> typename result<result_of_member_function_template(T const volatile &, T)>::type operator()(T const volatile &, T);
};
struct no_result_type_or_result_of
{
int operator()(double);
short operator()(double) const;
unsigned int operator()();
unsigned short operator()() volatile;
const unsigned short operator()() const volatile;
};
template<typename T>
struct no_result_type_or_result_of_template
{
int operator()(double);
short operator()(double) const;
unsigned int operator()();
unsigned short operator()() volatile;
const unsigned short operator()() const volatile;
}; };
struct X {}; struct X {};
@ -60,16 +128,52 @@ int main()
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_type(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<const int_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_type_template<void>(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<const int_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<volatile int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
// Prior to decltype, result_of could not deduce the return type
// nullary function objects unless they exposed a result_type.
#if !defined(BOOST_NO_DECLTYPE)
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, int>::value));
#else
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value)); BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value)); #endif
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, int>::value));
// Prior to decltype, result_of ignored a nested result<> if
// result_type was defined. After decltype, result_of deduces the
// actual return type of the function object, ignoring both
// result<> and result_type.
#if !defined(BOOST_NO_DECLTYPE)
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, char>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, char>::value));
#else
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, int>::value));
#endif
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
@ -81,5 +185,54 @@ int main()
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<func_ptr(char, float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<func_ref(char, float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<func_ptr_0()>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<func_ref_0()>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<mem_func_ptr(X,char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<mem_func_ptr_c(X,char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<mem_func_ptr_v(X,char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<mem_func_ptr_cv(X,char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<mem_func_ptr_0(X)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<func_ptr(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(double)>::type, double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const result_of_member_function_template(double)>::type, const double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile result_of_member_function_template(double)>::type, volatile double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const volatile result_of_member_function_template(double)>::type, const volatile double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int &, int)>::type, int &>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const &, int)>::type, int const &>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int volatile &, int)>::type, int volatile &>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const volatile &, int)>::type, int const volatile &>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<result_of_member_function_template(double)>::type, double>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<const result_of_member_function_template(double)>::type, const double>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<volatile result_of_member_function_template(double)>::type, volatile double>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<const volatile result_of_member_function_template(double)>::type, const volatile double>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<result_of_member_function_template(int &, int)>::type, int &>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<result_of_member_function_template(int const &, int)>::type, int const &>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<result_of_member_function_template(int volatile &, int)>::type, int volatile &>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<result_of_member_function_template(int const volatile &, int)>::type, int const volatile &>::value));
typedef int (*pf_t)(int);
BOOST_STATIC_ASSERT((is_same<result_of<pf_t(int)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<pf_t const(int)>::type,int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<pf_t(int)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<tr1_result_of<pf_t const(int)>::type,int>::value));
#if !defined(BOOST_NO_DECLTYPE)
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(void)>::type, unsigned int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of(double)>::type, short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of(void)>::type, unsigned short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of(void)>::type, const unsigned short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(void)>::type, unsigned int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of_template<void>(double)>::type, short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of_template<void>(void)>::type, unsigned short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
#endif
return 0; return 0;
} }

View File

@ -1,58 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<title>Boost: throw_exception.hpp documentation</title> <meta http-equiv=refresh content="0; URL=../exception/doc/throw_exception.html">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Automatic redirection</title>
</head> </head>
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%"> <body>
<table border="0" width="100%"> Automatic redirection failed, please go to
<tr> <a href="../exception/doc/throw_exception.html">throw_exception.html</a>.&nbsp;<hr>
<td width="277"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A> <p><EFBFBD> Copyright Beman Dawes, 2001</p>
</td> <p>Distributed under the Boost Software License, Version 1.0. (See accompanying
<td align="center"> file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
<h1>throw_exception.hpp</h1> at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
</td> </body>
</tr>
<tr>
<td colspan="2" height="64">&nbsp;</td>
</tr>
</table>
<p>
The header <STRONG>&lt;boost/throw_exception.hpp&gt;</STRONG> defines the
helper function <STRONG>boost::throw_exception</STRONG>. It is intended to be
used in Boost libraries that need to throw exceptions, but support
configurations and platforms where exceptions aren't available, as indicated by
the presence of the <STRONG>BOOST_NO_EXCEPTIONS</STRONG> <A href="../config/config.htm#macro_ref">
configuration macro</A>.
</p>
<P>When <STRONG>BOOST_NO_EXCEPTIONS</STRONG> is not defined, <tt>boost::throw_exception(e)</tt>
is equivalent to <tt>throw e</tt>. Otherwise, the function is left undefined,
and the user is expected to supply an appropriate definition. Callers of <tt>throw_exception</tt>
are allowed to assume that the function never returns; therefore, if the
user-defined <tt>throw_exception</tt> returns, the behavior is undefined.</P>
<h3><a name="Synopsis">Synopsis</a></h3>
<pre>
namespace boost
{
#ifdef BOOST_NO_EXCEPTIONS
void throw_exception(std::exception const &amp; e); // user defined
#else
template&lt;class E&gt; void throw_exception(E const &amp; e)
{
throw e;
}
#endif
}
</pre>
<p><br>
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
</body>
</html> </html>

View File

@ -23,6 +23,8 @@
<li> <li>
Function template <a href="#addressof">addressof()</a></li> Function template <a href="#addressof">addressof()</a></li>
<li>Class template <a href="#result_of">result_of</a></li> <li>Class template <a href="#result_of">result_of</a></li>
<li>
Macro <a href="#BOOST_BINARY">BOOST_BINARY</a></li>
<li><a href="index.html">Other utilities not part of <code>utility.hpp</code></a></li> <li><a href="index.html">Other utilities not part of <code>utility.hpp</code></a></li>
</ul> </ul>
<h2> <h2>
@ -68,7 +70,7 @@ const std::list&lt;T&gt;::iterator next = boost::next(prev, 2);</pre>
<p>The distance from the given iterator should be supplied as an absolute value. For <p>The distance from the given iterator should be supplied as an absolute value. For
example, the iterator four iterators prior to the given iterator <code>p</code> example, the iterator four iterators prior to the given iterator <code>p</code>
may be obtained by <code>prior(p, 4)</code>.</p> may be obtained by <code>prior(p, 4)</code>.</p>
<p>Contributed by <a href="../../people/dave_abrahams.htm">Dave Abrahams</a>. Two-argument versions by Daniel Walker.</p> <p>Contributed by <a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a>. Two-argument versions by Daniel Walker.</p>
<h2><a name="Class_noncopyable">Class noncopyable</a></h2> <h2><a name="Class_noncopyable">Class noncopyable</a></h2>
<p>Class <strong>noncopyable</strong> is a base class.&nbsp; Derive your own class <p>Class <strong>noncopyable</strong> is a base class.&nbsp; Derive your own class
from <strong>noncopyable</strong> when you want to prohibit copy construction from <strong>noncopyable</strong> when you want to prohibit copy construction
@ -89,7 +91,7 @@ const std::list&lt;T&gt;::iterator next = boost::next(prev, 2);</pre>
to verify class <b>noncopyable</b> works as expected. It has have been run to verify class <b>noncopyable</b> works as expected. It has have been run
successfully under GCC 2.95, Metrowerks CodeWarrior 5.0, and Microsoft Visual successfully under GCC 2.95, Metrowerks CodeWarrior 5.0, and Microsoft Visual
C++ 6.0 sp 3.</p> C++ 6.0 sp 3.</p>
<p>Contributed by <a href="../../people/dave_abrahams.htm">Dave Abrahams</a>.</p> <p>Contributed by <a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a>.</p>
<h3>Example</h3> <h3>Example</h3>
<blockquote> <blockquote>
<pre>// inside one of your own headers ... <pre>// inside one of your own headers ...
@ -152,11 +154,13 @@ void f() {
...,t<em>N</em>)</code>. The implementation permits ...,t<em>N</em>)</code>. The implementation permits
the type <code>F</code> to be a function pointer, the type <code>F</code> to be a function pointer,
function reference, member function pointer, or class function reference, member function pointer, or class
type. When <code>F</code> is a class type with a type.</p> <p>If your compiler does not support
member type <code>result_type</code>, <code>decltype</code>, then when <code>F</code> is a
class type with a member type <code>result_type</code>,
<code>result_of&lt;F(T1, T2, ..., <code>result_of&lt;F(T1, T2, ...,
T<em>N</em>)&gt;</code> is T<em>N</em>)&gt;</code> is
<code>F::result_type</code>. Otherwise, <code>F::result_type</code>. When <code>F</code>
does not contain <code>result_type</code>,
<code>result_of&lt;F(T1, T2, ..., <code>result_of&lt;F(T1, T2, ...,
T<em>N</em>)&gt;</code> is <code>F::result&lt;F(T1, T<em>N</em>)&gt;</code> is <code>F::result&lt;F(T1,
T2, ..., T<em>N</em>)&gt;::type</code> when T2, ..., T<em>N</em>)&gt;::type</code> when
@ -181,14 +185,68 @@ void f() {
<h2>Class templates for the Base-from-Member Idiom</h2> <h2>Class templates for the Base-from-Member Idiom</h2>
<p>See <a href="base_from_member.html">separate documentation</a>.</p> <p>See <a href="base_from_member.html">separate documentation</a>.</p>
<h2><a name="BOOST_BINARY">Macro BOOST_BINARY</a></h2>
<p>The macro <code>BOOST_BINARY</code> is used for the
representation of binary literals. It takes as an argument
a binary number arranged as an arbitrary amount of 1s and 0s in
groupings of length 1 to 8, with groups separated
by spaces. The type of the literal yielded is determined by
the same rules as those of hex and octal
literals (<i>2.13.1p1</i>). By implementation, this macro
expands directly to an octal literal during preprocessing, so
there is no overhead at runtime and the result is useable in
any place that an octal literal would be.</p>
<p>In order to directly support binary literals with suffixes,
additional macros of the form BOOST_BINARY_XXX are also
provided, where XXX is a standard integer suffix in all capital
letters. In addition, LL and ULL suffixes may be used for representing
long long and unsigned long long types in compilers which provide
them as an extension.</p>
<p>The BOOST_BINARY family of macros resides in the header
<a
href="../../boost/utility/binary.hpp">&lt;boost/utility/binary.hpp&gt;</a>
which is automatically included by
<a
href="../../boost/utility.hpp">&lt;boost/utility.hpp&gt;</a>.
<p>Contributed by Matt Calabrese.</p><p>
</p><h3>Example</h3>
<blockquote>
<pre>
void foo( int );
void foo( unsigned long );
void bar()
{
int value1 = BOOST_BINARY( 100 111000 01 1 110 );
unsigned long value2 = BOOST_BINARY_UL( 100 001 ); // unsigned long
long long value3 = BOOST_BINARY_LL( 11 000 ); // long long if supported
assert( BOOST_BINARY( 10010 )
& BOOST_BINARY( 11000 )
== BOOST_BINARY( 10000 )
);
foo( BOOST_BINARY( 1010 ) ); // calls the first foo
foo( BOOST_BINARY_LU( 1010 ) ); // calls the second foo
}
</pre></blockquote>
<hr> <hr>
<p>Revised&nbsp; <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan <p>Revised&nbsp; <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan
-->02 May, 2004<!--webbot bot="Timestamp" endspan i-checksum="38582" -->04 September, 2008<!--webbot bot="Timestamp" endspan i-checksum="39369"
--> -->
</p> </p>
<p>&copy; Copyright boost.org 1999-2003. Permission to copy, use, modify, sell and distribute <p>&copy; Copyright Beman Dawes 1999-2003.</p>
this document is granted provided this copyright notice appears in all copies. <p>Distributed under the Boost Software License, Version 1.0. See
This document is provided &quot;as is&quot; without express or implied <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
warranty, and with no claim as to its suitability for any purpose.</p>
</body> </body>
</html> </html>

View File

@ -17,20 +17,24 @@
<dl> <dl>
<dt><a href="#rationale">Rationale</a></dt> <dt><a href="#rationale">Rationale</a></dt>
<dt><a href="#intro">Introduction</a></dt> <dt><a href="#intro">Introduction</a></dt>
<dt><a href="#details">Details</a></dt>
</dl> </dl>
<ul> <ul>
<li><a href="#valueinit">value-initialization</a></li> <li><a href="#valueinit">value-initialization</a></li>
<li><a href="#valueinitsyn">value-initialization syntax</a></li> <li><a href="#valueinitsyn">value-initialization syntax</a></li>
<li><a href="#compiler_issues">compiler issues</a></li>
</ul> </ul>
<dl class="page-index"> <dl class="page-index">
<dt><a href="#types">Types</a></dt> <dt><a href="#types">Types and objects</a></dt>
</dl> </dl>
<ul> <ul>
<li><a href="#val_init"><code>value_initialized&lt;&gt;</code></a></li> <li><a href="#val_init"><code>template class value_initialized&lt;T&gt;</code></a></li>
<li><a href="#initialized"><code>template class initialized&lt;T&gt;</code></a></li>
<li><a href="#initialized_value"><code>initialized_value</code></a></li>
</ul> </ul>
<a href="#acknowledgements">Acknowledgements</a><br> <a href="#acknowledgements">Acknowledgements</a><br>
@ -44,24 +48,110 @@
for initialization. Depending on the type, the value of a newly constructed for initialization. Depending on the type, the value of a newly constructed
object can be zero-initialized (logically 0), default-constructed (using object can be zero-initialized (logically 0), default-constructed (using
the default constructor), or indeterminate. When writing generic code, the default constructor), or indeterminate. When writing generic code,
this problem must be addressed. <code>value_initialized</code> provides this problem must be addressed. The template <code>value_initialized</code> provides
a solution with consistent syntax for value initialization of scalar, a solution with consistent syntax for value initialization of scalar,
union and class types. <br> union and class types.
Moreover, <code>value_initialized</code> offers a workaround to various
compiler issues regarding value-initialization.
Furthermore, a <code>const</code> object, <code>initialized_value</code> is provided,
to avoid repeating the type name when retrieving the value from a
<code>value_initialized&lt;T&gt;</code> object.
<br>
</p> </p>
<h2><a name="intro"></a>Introduction</h2> <h2><a name="intro"></a>Introduction</h2>
<p>The C++ standard [<a href="#references">1</a>] contains the definitions <p>
There are various ways to initialize a variable, in C++. The following
declarations all <em>may</em> have a local variable initialized to its default
value:
<pre>
T1 var1;
T2 var2 = 0;
T3 var3 = {};
T4 var4 = T4();
</pre>
Unfortunately, whether or not any of those declarations correctly
initialize the variable very much depends on its type. The first
declaration is valid for any <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">
DefaultConstructible</a> type (by definition).
However, it does not always do an initialization!
It correctly initializes the variable when it's an instance of a
class, and the author of the class has provided a proper default
constructor. On the other hand, the value of <code>var1</code> is <em>indeterminate</em> when
its type is an arithmetic type, like <code>int</code>, <code>float</code>, or <code>char</code>.
An arithmetic variable
is of course initialized properly by the second declaration, <code>T2
var2 = 0</code>. But this initialization form usually won't work for a
class type (unless the class was especially written to support being
initialized that way). The third form, <code>T3 var3 = {}</code>
initializes an aggregate, typically a "C-style" <code>struct</code> or a "C-style" array.
However, the syntax is not allowed for a class that has an explicitly declared
constructor. (But watch out for an upcoming C++ language change,
by Bjarne Stroustrup et al [<a href="#references">1</a>]!)
The fourth form is the most generic form of them, as it
can be used to initialize arithmetic types, class types, aggregates, pointers, and
other types. The declaration, <code>T4 var4 = T4()</code>, should be read
as follows: First a temporary object is created, by <code>T4()</code>.
This object is <a href="#valueinit">value-initialized</a>. Next the temporary
object is copied to the named variable, <code>var4</code>. Afterwards, the temporary
is destroyed. While the copying and the destruction are likely to
be optimized away, C++ still requires the type <code>T4</code> to be
<a href="CopyConstructible.html">CopyConstructible</a>.
(So <code>T4</code> needs to be <em>both</em> DefaultConstructible <em>and</em> CopyConstructible.)
A class may not be CopyConstructible, for example because it may have a
private and undefined copy constructor,
or because it may be derived from <a href="utility.htm#Class_noncopyable">boost::noncopyable</a>.
Scott Meyers [<a href="#references">2</a>] explains why a class would be defined like that.
</p>
<p>
There is another, less obvious disadvantage to the fourth form, <code>T4 var4 = T4()</code>:
It suffers from various <a href="#compiler_issues">compiler issues</a>, causing
a variable to be left uninitialized in some compiler specific cases.
</p>
<p>
The template <a href="#val_init"><code>value_initialized</code></a>
offers a generic way to initialize
an object, like <code>T4 var4 = T4()</code>, but without requiring its type
to be CopyConstructible. And it offers a workaround to those compiler issues
regarding value-initialization as well! It allows getting an initialized
variable of any type; it <em>only</em> requires the type to be DefaultConstructible.
A properly <em>value-initialized</em> object of type <code>T</code> is
constructed by the following declaration:
<pre>
value_initialized&lt;T&gt; var;
</pre>
</p>
<p>
The template <a href="#initialized"><code>initialized</code></a>
offers both value-initialization and direct-initialization.
It is especially useful as a data member type, allowing the very same object
to be either direct-initialized or value-initialized.
</p>
<p>
The <code>const</code> object <a href="#initialized_value"><code>initialized_value</code></a>
allows value-initializing a variable as follows:
<pre>
T var = initialized_value ;
</pre>
This form of initialization is semantically equivalent to <code>T4 var4 = T4()</code>,
but robust against the aforementioned compiler issues.
</p>
<h2><a name="details"></a>Details</h2>
<p>The C++ standard [<a href="#references">3</a>] contains the definitions
of <code>zero-initialization</code> and <code>default-initialization</code>. of <code>zero-initialization</code> and <code>default-initialization</code>.
Informally, zero-initialization means that the object is given the initial Informally, zero-initialization means that the object is given the initial
value 0 (converted to the type) and default-initialization means that value 0 (converted to the type) and default-initialization means that
POD [<a href="#references">2</a>] types are zero-initialized, while class POD [<a href="#references">4</a>] types are zero-initialized, while non-POD class
types are initialized with their corresponding default constructors. A types are initialized with their corresponding default constructors. A
<i>declaration</i> can contain an <i>initializer</i>, which specifies the <i>declaration</i> can contain an <i>initializer</i>, which specifies the
object's initial value. The initializer can be just '()', which states that object's initial value. The initializer can be just '()', which states that
the object shall be default-initialized (but see below). However, if a <i>declaration</i> the object shall be value-initialized (but see below). However, if a <i>declaration</i>
has no <i>initializer</i> and it is of a non-<code>const</code>, non-<code>static</code> has no <i>initializer</i> and it is of a non-<code>const</code>, non-<code>static</code>
POD type, the initial value is indeterminate:<cite>(see &sect;8.5 for the POD type, the initial value is indeterminate: <cite>(see &sect;8.5, [dcl.init], for the
accurate definitions).</cite></p> accurate definitions).</cite></p>
<pre>int x ; // no initializer. x value is indeterminate.<br>std::string s ; // no initializer, s is default-constructed.<br><br>int y = int() ; <br>// y is initialized using copy-initialization<br>// but the temporary uses an empty set of parentheses as the initializer,<br>// so it is default-constructed.<br>// A default constructed POD type is zero-initialized,<br>// therefore, y == 0.<br><br>void foo ( std::string ) ;<br>foo ( std::string() ) ; <br>// the temporary string is default constructed <br>// as indicated by the initializer () </pre> <pre>int x ; // no initializer. x value is indeterminate.<br>std::string s ; // no initializer, s is default-constructed.<br><br>int y = int() ; <br>// y is initialized using copy-initialization<br>// but the temporary uses an empty set of parentheses as the initializer,<br>// so it is default-constructed.<br>// A default constructed POD type is zero-initialized,<br>// therefore, y == 0.<br><br>void foo ( std::string ) ;<br>foo ( std::string() ) ; <br>// the temporary string is default constructed <br>// as indicated by the initializer () </pre>
@ -87,14 +177,11 @@ the object shall be default-initialized (but see below). However, if a <i>decla
<p>In order to specify value-initialization of an object we need to use the <p>In order to specify value-initialization of an object we need to use the
empty-set initializer: (). </p> empty-set initializer: (). </p>
<p><i>(but recall that the current C++ Standard states that '()' invokes default-initialization,
not value-initialization)</i></p>
<p>As before, a declaration with no intializer specifies default-initialization, <p>As before, a declaration with no intializer specifies default-initialization,
and a declaration with a non-empty initializer specifies copy (=xxx) or and a declaration with a non-empty initializer specifies copy (=xxx) or
direct (xxx) initialization. </p> direct (xxx) initialization. </p>
<pre>template&lt;class T&gt; void eat(T);<br>int x ; // indeterminate initial value.<br>std::string s; // default-initialized.<br>eat ( int() ) ; // value-initialized<br>eat ( std::string() ) ; // value-initialied</pre> <pre>template&lt;class T&gt; void eat(T);<br>int x ; // indeterminate initial value.<br>std::string s; // default-initialized.<br>eat ( int() ) ; // value-initialized<br>eat ( std::string() ) ; // value-initialized</pre>
<h4><a name="valueinitsyn">value-initialization</a> syntax</h4> <h4><a name="valueinitsyn">value-initialization</a> syntax</h4>
@ -102,7 +189,7 @@ not value-initialization)</i></p>
parentheses is not permitted by the syntax of initializers because it is parentheses is not permitted by the syntax of initializers because it is
parsed as the declaration of a function taking no arguments: </p> parsed as the declaration of a function taking no arguments: </p>
<pre>int x() ; // declares function int(*)()<br>int y ( int() ) ; // decalares function int(*)( int(*)() )</pre> <pre>int x() ; // declares function int(*)()</pre>
<p>Thus, the empty () must be put in some other initialization context.</p> <p>Thus, the empty () must be put in some other initialization context.</p>
@ -124,14 +211,110 @@ data member:</p>
<pre>template&lt;class T&gt; <br>struct W <br>{<br> // value-initialization of 'data' here.<br> W() : data() {}<br> T data ;<br>} ;<br>W&lt;int&gt; w ;<br>// w.data is value-initialized for any type. </pre> <pre>template&lt;class T&gt; <br>struct W <br>{<br> // value-initialization of 'data' here.<br> W() : data() {}<br> T data ;<br>} ;<br>W&lt;int&gt; w ;<br>// w.data is value-initialized for any type. </pre>
<p><code>This is the solution supplied by the value_initialized&lt;&gt; template <p>This is the solution as it was supplied by earlier versions of the
class.</code></p> <code>value_initialized&lt;T&gt;</code> template
class. Unfortunately this approach suffered from various compiler issues.</p>
<h4><a name="compiler_issues">compiler issues</a> </h4>
Various compilers haven't yet fully implemented value-initialization.
So when an object should be <em>value-initialized</em> (according to the C++ Standard),
it <em>may</em> in practice still be left uninitialized, because of those
compiler issues! It's hard to make a general statement on what those issues
are like, because they depend on the compiler you are using, its version number,
and the type of object you would like to have value-initialized.
All compilers we have tested so far support value-initialization for arithmetic types properly.
However, various compilers may leave some types of <em>aggregates</em> uninitialized, when they
should be value-initialized. Value-initialization of objects of a pointer-to-member type may also
go wrong on various compilers.
</p>
<p>
At the moment of writing, May 2010, the following reported issues regarding
value-initialization are still there in current compiler releases:
<ul>
<li>
<a href="https://connect.microsoft.com/VisualStudio/feedback/details/100744">
Microsoft Visual Studio Feedback ID 100744, Value-initialization in new-expression</a>
<br>Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005
</li><li>
<a href="http://connect.microsoft.com/VisualStudio/feedback/details/484295">
Microsoft Visual Studio Feedback ID 484295, VC++ does not value-initialize members of derived classes without user-declared constructor</a>
<br>Reported by Sylvester Hesp, 2009
</li><li>
<a href="https://connect.microsoft.com/VisualStudio/feedback/details/499606">
Microsoft Visual Studio Feedback ID 499606, Presence of copy constructor breaks member class initialization</a>
<br>Reported by Alex Vakulenko, 2009
</li><li>
<a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=83751">
Embarcadero/C++Builder Report 83751, Value-initialization: arrays should have each element value-initialized</a>
<br>Reported by Niels Dekker (LKEB), 2010
</li><li>
<a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=83851">
Embarcadero/C++Builder Report 83851, Value-initialized temporary triggers internal backend error C1798</a>
<br>Reported by Niels Dekker, 2010
</li><li>
<a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=84279">
Embarcadero/C++Builder Report 84279, Internal compiler error (F1004), value-initializing member function pointer by "new T()"</a>
<br>Reported by Niels Dekker, 2010
</li><li>
Sun CR 6947016, Sun 5.10 may fail to value-initialize an object of a non-POD aggregate.
<br>Reported to Steve Clamage by Niels Dekker, 2010
</li><li>
IBM's XL V10.1 and V11.1 may fail to value-initialize a temporary of a non-POD aggregate.
<br>Reported to Michael Wong by Niels Dekker, 2010
</li><li>
Intel support issue 589832, Attempt to value-initialize pointer-to-member triggers internal error
on Intel 11.1.
<br>Reported by John Maddock, 2010
</li>
</ul>
Note that all known GCC issues regarding value-initialization are
fixed with GCC version 4.4, including
<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111">GCC Bug 30111</a>.
Clang also has completely implemented value-initialization, as far as we know,
now that <a href="http://llvm.org/bugs/show_bug.cgi?id=7139">Clang Bug 7139</a> is fixed.
</p><p>
New versions of <code>value_initialized</code>
(Boost release version 1.35 or higher)
offer a workaround to these issues: <code>value_initialized</code> may now clear
its internal data, prior to constructing the object that it contains. It will do
so for those compilers that need to have such a workaround, based on the
<a href="../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_defects"
>compiler defect macro</a> BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
</p>
<h2><a name="types"></a>Types</h2> <h2><a name="types"></a>Types and objects</h2>
<h2><a name="val_init"><code>template class value_initialized&lt;T&gt;</code></a></h2> <h2><a name="val_init"><code>template class value_initialized&lt;T&gt;</code></a></h2>
<pre>namespace boost {<br><br>template&lt;class T&gt;<br>class value_initialized<br>{<br> public :<br> value_initialized() : x() {}<br> operator T&amp;() const { return x ; }<br> T&amp; data() const { return x ; }<br><br> private :<br> <i>unspecified</i> x ;<br>} ;<br><br>template&lt;class T&gt;<br>T const&amp; get ( value_initialized&lt;T&gt; const&amp; x )<br>{<br> return x.data() ;<br>}<br><br>template&lt;class T&gt;<br>T&amp; get ( value_initialized&lt;T&gt;&amp; x )<br>{<br> return x.data() ;<br>}<br><br>} // namespace boost<br></pre> <pre>namespace boost {<br><br>template&lt;class T&gt;<br>class value_initialized<br>{
<br> public :
<br> value_initialized() : x() {}
<br> operator T const &amp;() const { return x ; }
<br> operator T&amp;() { return x ; }
<br> T const &amp;data() const { return x ; }
<br> T&amp; data() { return x ; }
<br> void swap( value_initialized&lt;T&gt;&amp; );
<br>
<br> private :
<br> <i>unspecified</i> x ;
<br>} ;
<br>
<br>template&lt;class T&gt;
<br>T const&amp; get ( value_initialized&lt;T&gt; const&amp; x )
<br>{
<br> return x.data() ;
<br>}
<br>
<br>template&lt;class T&gt;
<br>T&amp; get ( value_initialized&lt;T&gt;&amp; x )
<br>{
<br> return x.data() ;
<br>}
<br>
<br>} // namespace boost
<br></pre>
<p>An object of this template class is a <code>T</code>-wrapper convertible <p>An object of this template class is a <code>T</code>-wrapper convertible
to <code>'T&amp;'</code> whose wrapped object (data member of type <code>T</code>) to <code>'T&amp;'</code> whose wrapped object (data member of type <code>T</code>)
@ -149,69 +332,172 @@ data member:</p>
<code>T&amp;</code>, the member function <code>data()</code>, or the <code>T&amp;</code>, the member function <code>data()</code>, or the
non-member function <code>get()</code>: </p> non-member function <code>get()</code>: </p>
<pre>void watch(int);<br>value_initialized&lt;int&gt; x;<br><br>watch(x) ; // operator T&amp; used.<br>watch(x.data());<br>watch( get(x) ) // function get() used</pre> <pre>void watch(int);<br>value_initialized&lt;int&gt; x;
<br><br>watch(x) ; // operator T&amp; used.<br>watch(x.data());<br>watch( get(x) ) // function get() used</pre>
<p>Both <code>const</code> and non-<code>const</code> objects can be wrapped. <p>Both <code>const</code> and non-<code>const</code> objects can be wrapped.
Mutable objects can be modified directly from within the wrapper but constant Mutable objects can be modified directly from within the wrapper but constant
objects cannot:</p> objects cannot:</p>
<p>When <code>T</code> is a <em>Swappable</em> type, <code>value_initialized&lt;T&gt;</code>
is swappable as well, by calling its <code>swap</code> member function
as well as by calling <code>boost::swap</code>.</p>
<pre>value_initialized&lt;int&gt; x ; <br>static_cast&lt;int&amp;&gt;(x) = 1 ; // OK<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; y ; <br>static_cast&lt;int&amp;&gt;(y) = 1 ; // ERROR: cannot cast to int&amp;<br>static_cast&lt;int const&amp;&gt;(y) = 1 ; // ERROR: cannot modify a const value<br>get(y) = 1 ; // ERROR: cannot modify a const value</pre> <pre>value_initialized&lt;int&gt; x ; <br>static_cast&lt;int&amp;&gt;(x) = 1 ; // OK<br>get(x) = 1 ; // OK
<br><br>value_initialized&lt;int const&gt; y ; <br>static_cast&lt;int&amp;&gt;(y) = 1 ; // ERROR: cannot cast to int&amp;<br>static_cast&lt;int const&amp;&gt;(y) = 1 ; // ERROR: cannot modify a const value<br>get(y) = 1 ; // ERROR: cannot modify a const value</pre>
<h3>Warning:</h3> <h3>Warning:</h3>
<p>Both the conversion operator and the <code>data()</code> member function <p>The <code>value_initialized</code> implementation of Boost version 1.40.0 and older
are <code>const</code> in order to allow access to the wrapped object allowed <i>non-const</i> access to the wrapped object, from a constant wrapper,
from a constant wrapper:</p> both by its conversion operator and its <code>data()</code> member function. For example:</p>
<pre>void foo(int);<br>value_initialized&lt;int&gt; const x ;<br>foo(x);<br></pre> <pre>value_initialized&lt;int&gt; const x_c ;<br>int&amp; xr = x_c ; // OK, conversion to int&amp; available even though x_c is itself const.
<br>xr = 2 ; </pre>
<p>But notice that this conversion operator is to <code>T&amp;</code> although <p>The reason for this obscure behavior was that some compilers
it is itself <code>const</code>. As a consequence, if <code>T</code> is didn't accept the following valid code:</p>
a non-<code>const</code> type, you can modify the wrapped object even from
within a constant wrapper:</p>
<pre>value_initialized&lt;int&gt; const x_c ;<br>int&amp; xr = x_c ; // OK, conversion to int&amp; available even though x_c is itself const.<br>xr = 2 ; </pre>
<p>The reason for this obscure behavior is that some commonly used compilers
just don't accept the following valid code:</p>
<pre>struct X<br>{<br> operator int&amp;() ;<br> operator int const&amp;() const ; <br>};<br>X x ;<br>(x == 1 ) ; // ERROR HERE!</pre> <pre>struct X<br>{<br> operator int&amp;() ;<br> operator int const&amp;() const ; <br>};<br>X x ;<br>(x == 1 ) ; // ERROR HERE!</pre>
<p>These compilers complain about ambiguity between the conversion operators. <p>The current version of <code>value_initialized</code> no longer has this obscure behavior.
This complaint is incorrect, but the only workaround that I know of is As compilers nowadays widely support overloading the conversion operator by having a <code>const</code> and a <code>non-const</code> version, we have decided to fix the issue accordingly. So the current version supports the idea of logical constness.
to provide only one of them, which leads to the obscure behavior just explained.<br> <br>
</p> </p>
<h3>Recommended practice: The non-member get() idiom</h3> <h3>Recommended practice: The non-member get() idiom</h3>
<p>The obscure behavior of being able to modify a non-<code>const</code> <p>The obscure behavior of being able to modify a non-<code>const</code>
wrapped object from within a constant wrapper can be avoided if access to wrapped object from within a constant wrapper (as was supported by previous
versions of <code>value_initialized</code>)
can be avoided if access to
the wrapped object is always performed with the <code>get()</code> idiom:</p> the wrapped object is always performed with the <code>get()</code> idiom:</p>
<pre>value_initialized&lt;int&gt; x ;<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int&gt; const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int const&gt; const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre> <pre>value_initialized&lt;int&gt; x ;<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int&gt; const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int const&gt; const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre>
<h2><a name="initialized"><code>template class initialized&lt;T&gt;</code></a></h2>
<pre>namespace boost {<br><br>template&lt;class T&gt;<br>class initialized<br>{
<br> public :
<br> initialized() : x() {}
<br> explicit initialized(T const &amp; arg) : x(arg) {}
<br> operator T const &amp;() const;
<br> operator T&amp;();
<br> T const &amp;data() const;
<br> T&amp; data();
<br> void swap( value_initialized&lt;T&gt;&amp; );
<br>
<br> private :
<br> <i>unspecified</i> x ;
<br>} ;
<br>
<br>template&lt;class T&gt;
<br>T const&amp; get ( initialized&lt;T&gt; const&amp; x );
<br>
<br>template&lt;class T&gt;
<br>T&amp; get ( initialized&lt;T&gt;&amp; x );
<br>
<br>} // namespace boost
<br></pre>
The template class <code>boost::initialized&lt;T&gt;</code> supports both value-initialization
and direct-initialization, so its interface is a superset of the interface
of <code>value_initialized&lt;T&gt;</code>: Its default-constructor
value-initializes the wrapped object just like the default-constructor of
<code>value_initialized&lt;T&gt;</code>, but <code>boost::initialized&lt;T&gt;</code>
also offers an extra <code>explicit</code>
constructor, which direct-initializes the wrapped object by the specified value.
<p>
<code>initialized&lt;T&gt;</code> is especially useful when the wrapped
object must be either value-initialized or direct-initialized, depending on
runtime conditions. For example, <code>initialized&lt;T&gt;</code> could
hold the value of a data member that may be value-initialized by some
constructors, and direct-initialized by others.
On the other hand, if it is known beforehand that the
object must <i>always</i> be value-initialized, <code>value_initialized&lt;T&gt;</code>
may be preferable. And if the object must always be
direct-initialized, none of the two wrappers really needs to be used.
</p>
<h2><a name="initialized_value"><code>initialized_value</code></a></h2>
<pre>
namespace boost {
class initialized_value_t
{
public :
template &lt;class T&gt; operator T() const ;
};
initialized_value_t const initialized_value = {} ;
} // namespace boost
</pre>
<code>initialized_value</code> provides a convenient way to get
an initialized value: its conversion operator provides an appropriate
<em>value-initialized</em> object for any CopyConstructible type.
Suppose you need to have an initialized variable of type <code>T</code>.
You could do it as follows:
<pre>
T var = T();
</pre>
But as mentioned before, this form suffers from various compiler issues.
The template <code>value_initialized</code> offers a workaround:
<pre>
T var = get( value_initialized&lt;T&gt;() );
</pre>
Unfortunately both forms repeat the type name, which
is rather short now (<code>T</code>), but could of course be
more like <code>Namespace::Template&lt;Arg&gt;::Type</code>.
Instead, one could use <code>initialized_value</code> as follows:
<pre>
T var = initialized_value ;
</pre>
<h3><a name="references">References</a></h3> <h3><a name="references">References</a></h3>
[1] The C++ Standard, ISO/IEC 14882:98 <br> [1] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote
[2] Plain Old Data various papers, proposing to extend the support for brace-enclosed <em>initializer lists</em>
in the next version of C++.
This would allow a variable <code>var</code> of any DefaultConstructible type
<code>T</code> to be <em>value-initialized</em> by doing <code>T var = {}</code>.
The papers are listed at Bjarne's web page,
<a href="http://www.research.att.com/~bs/WG21.html">My C++ Standards committee papers</a> <br>
[2] Scott Meyers, Effective C++, Third Edition, item 6,
<em>Explicitly disallow the use of compiler-generated functions you do not want</em>,
<a href="http://www.aristeia.com/books.html">Scott Meyers: Books and CDs</a> <br>
[3] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003 <br>
[4] POD stands for "Plain Old Data"
<h3><a name="acknowledgements"></a>Acknowledgements</h3> <h3><a name="acknowledgements"></a>Acknowledgements</h3>
value_initialized was developed by Fernando Cacciola, with help and value_initialized was developed by Fernando Cacciola, with help and
suggestions from David Abrahams and Darin Adler.<br> suggestions from David Abrahams and Darin Adler.<br>
Special thanks to Bj<EFBFBD>rn Karlsson who carefully edited and completed this documentation. Special thanks to Bj&ouml;rn Karlsson who carefully edited and completed this documentation.
<pre>&nbsp;</pre>
<p>value_initialized was reimplemented by Fernando Cacciola and Niels Dekker
<hr> for Boost release version 1.35 (2008), offering a workaround to various compiler issues.
<p>Revised 19 September 2002</p> </p>
<p><code>boost::initialized</code> was very much inspired by feedback from Edward Diener and
<p>&copy; Copyright boost.org 2002. Permission to copy, use, modify, sell Jeffrey Hellrung.
and distribute this document is granted provided this copyright notice appears </p>
in all copies. This document is provided "as is" without express or implied <p>initialized_value was written by Niels Dekker, and added to Boost release version 1.36 (2008).
warranty, and with no claim as to its suitability for any purpose.</p> </p>
<p>Developed by <a href="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</a>, <p>Developed by <a href="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</a>,
the latest version of this file can be found at <a the latest version of this file can be found at <a
href="http://www.boost.org">www.boost.org</a>, and the boost discussion list href="http://www.boost.org">www.boost.org</a>.
at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.
</p> </p>
<hr>
<p>Revised 30 May 2010</p>
<p>&copy; Copyright Fernando Cacciola, 2002 - 2010.</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
<br> <br>
<br> <br>

View File

@ -1,4 +1,4 @@
// (C) 2002, Fernando Luis Cacciola Carballal. // Copyright 2002-2008, Fernando Luis Cacciola Carballal.
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@ -6,27 +6,32 @@
// //
// Test program for "boost/utility/value_init.hpp" // Test program for "boost/utility/value_init.hpp"
// //
// Initial: 21 Agu 2002 // 21 Ago 2002 (Created) Fernando Cacciola
// 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker
// 23 May 2008 (Added tests regarding initialized_value) Niels Dekker
// 21 Ago 2008 (Added swap test) Niels Dekker
#include <cstring> // For memcmp.
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "boost/utility/value_init.hpp" #include "boost/utility/value_init.hpp"
#include <boost/shared_ptr.hpp>
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#include "boost/test/minimal.hpp" #include <boost/detail/lightweight_test.hpp>
// //
// Sample POD type // Sample POD type
// //
struct POD struct POD
{ {
POD () : c(0), i(0), f(0) {} POD () : f(0), c(0), i(0){}
POD ( char c_, int i_, float f_ ) : c(c_), i(i_), f(f_) {} POD ( char c_, int i_, float f_ ) : f(f_), c(c_), i(i_) {}
friend std::ostream& operator << ( std::ostream& os, POD const& pod ) friend std::ostream& operator << ( std::ostream& os, POD const& pod )
{ return os << '(' << pod.c << ',' << pod.i << ',' << pod.f << ')' ; } { return os << '(' << pod.c << ',' << pod.i << ',' << pod.f << ')' ; }
@ -49,7 +54,7 @@ struct NonPODBase
struct NonPOD : NonPODBase struct NonPOD : NonPODBase
{ {
NonPOD () : id() {} NonPOD () : id() {}
NonPOD ( std::string const& id_) : id(id_) {} explicit NonPOD ( std::string const& id_) : id(id_) {}
friend std::ostream& operator << ( std::ostream& os, NonPOD const& npod ) friend std::ostream& operator << ( std::ostream& os, NonPOD const& npod )
{ return os << '(' << npod.id << ')' ; } { return os << '(' << npod.id << ')' ; }
@ -60,48 +65,305 @@ struct NonPOD : NonPODBase
std::string id ; std::string id ;
} ; } ;
template<class T> //
void test ( T const& y, T const& z ) // Sample aggregate POD struct type
// Some compilers do not correctly value-initialize such a struct, for example:
// Borland C++ Report #51854, "Value-initialization: POD struct should be zero-initialized "
// http://qc.codegear.com/wc/qcmain.aspx?d=51854
//
struct AggregatePODStruct
{ {
float f;
char c;
int i;
};
bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs )
{ return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; }
//
// An aggregate struct that contains an std::string and an int.
// Pavel Kuznetsov (MetaCommunications Engineering) used a struct like
// this to reproduce the Microsoft Visual C++ compiler bug, reported as
// Feedback ID 100744, "Value-initialization in new-expression"
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
//
struct StringAndInt
{
std::string s;
int i;
};
bool operator == ( StringAndInt const& lhs, StringAndInt const& rhs )
{ return lhs.s == rhs.s && lhs.i == rhs.i ; }
//
// A struct that has an explicit (user defined) destructor.
// Some compilers do not correctly value-initialize such a struct, for example:
// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression"
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
//
struct StructWithDestructor
{
int i;
~StructWithDestructor() {}
};
bool operator == ( StructWithDestructor const& lhs, StructWithDestructor const& rhs )
{ return lhs.i == rhs.i ; }
//
// A struct that has a virtual function.
// Some compilers do not correctly value-initialize such a struct either, for example:
// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression"
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
//
struct StructWithVirtualFunction
{
int i;
virtual void VirtualFunction();
};
void StructWithVirtualFunction::VirtualFunction()
{
}
bool operator == ( StructWithVirtualFunction const& lhs, StructWithVirtualFunction const& rhs )
{ return lhs.i == rhs.i ; }
//
// A struct that is derived from an aggregate POD struct.
// Some compilers do not correctly value-initialize such a struct, for example:
// GCC Bugzilla Bug 30111, "Value-initialization of POD base class doesn't initialize members",
// reported by Jonathan Wakely, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
//
struct DerivedFromAggregatePODStruct : AggregatePODStruct
{
DerivedFromAggregatePODStruct() : AggregatePODStruct() {}
};
//
// A struct that wraps an aggregate POD struct as data member.
//
struct AggregatePODStructWrapper
{
AggregatePODStructWrapper() : dataMember() {}
AggregatePODStruct dataMember;
};
bool operator == ( AggregatePODStructWrapper const& lhs, AggregatePODStructWrapper const& rhs )
{ return lhs.dataMember == rhs.dataMember ; }
typedef unsigned char ArrayOfBytes[256];
//
// A struct that allows testing whether the appropriate copy functions are called.
//
struct CopyFunctionCallTester
{
bool is_copy_constructed;
bool is_assignment_called;
CopyFunctionCallTester()
: is_copy_constructed(false), is_assignment_called(false) {}
CopyFunctionCallTester(const CopyFunctionCallTester & )
: is_copy_constructed(true), is_assignment_called(false) {}
CopyFunctionCallTester & operator=(const CopyFunctionCallTester & )
{
is_assignment_called = true ;
return *this ;
}
};
//
// A struct that allows testing whether its customized swap function is called.
//
struct SwapFunctionCallTester
{
bool is_custom_swap_called;
int data;
SwapFunctionCallTester()
: is_custom_swap_called(false), data(0) {}
SwapFunctionCallTester(const SwapFunctionCallTester & arg)
: is_custom_swap_called(false), data(arg.data) {}
void swap(SwapFunctionCallTester & arg)
{
std::swap(data, arg.data);
is_custom_swap_called = true;
arg.is_custom_swap_called = true;
}
};
void swap(SwapFunctionCallTester & lhs, SwapFunctionCallTester & rhs)
{
lhs.swap(rhs);
}
template<class T>
void check_initialized_value ( T const& y )
{
T initializedValue = boost::initialized_value ;
BOOST_TEST ( y == initializedValue ) ;
}
#ifdef __BORLANDC__
#if __BORLANDC__ == 0x582
void check_initialized_value( NonPOD const& )
{
// The initialized_value check is skipped for Borland 5.82
// and this type (NonPOD), because the following statement
// won't compile on this particular compiler version:
// NonPOD initializedValue = boost::initialized_value() ;
//
// This is caused by a compiler bug, that is fixed with a newer version
// of the Borland compiler. The Release Notes for Delphi(R) 2007 for
// Win32(R) and C++Builder(R) 2007 (http://dn.codegear.com/article/36575)
// say about similar statements:
// both of these statements now compile but under 5.82 got the error:
// Error E2015: Ambiguity between 'V::V(const A &)' and 'V::V(const V &)'
}
#endif
#endif
//
// This test function tests boost::value_initialized<T> for a specific type T.
// The first argument (y) is assumed have the value of a value-initialized object.
// Returns true on success.
//
template<class T>
bool test ( T const& y, T const& z )
{
const int errors_before_test = boost::detail::test_errors();
check_initialized_value(y);
boost::value_initialized<T> x ; boost::value_initialized<T> x ;
BOOST_CHECK ( y == x ) ; BOOST_TEST ( y == x ) ;
BOOST_CHECK ( y == boost::get(x) ) ; BOOST_TEST ( y == boost::get(x) ) ;
static_cast<T&>(x) = z ; static_cast<T&>(x) = z ;
boost::get(x) = z ; boost::get(x) = z ;
BOOST_CHECK ( x == z ) ; BOOST_TEST ( x == z ) ;
boost::value_initialized<T> const x_c ; boost::value_initialized<T> const x_c ;
BOOST_CHECK ( y == x_c ) ; BOOST_TEST ( y == x_c ) ;
BOOST_CHECK ( y == boost::get(x_c) ) ; BOOST_TEST ( y == boost::get(x_c) ) ;
T& x_c_ref = x_c ; T& x_c_ref = const_cast<T&>( boost::get(x_c) ) ;
x_c_ref = z ; x_c_ref = z ;
BOOST_CHECK ( x_c == z ) ; BOOST_TEST ( x_c == z ) ;
boost::value_initialized<T> const copy1 = x;
BOOST_TEST ( boost::get(copy1) == boost::get(x) ) ;
boost::value_initialized<T> copy2;
copy2 = x;
BOOST_TEST ( boost::get(copy2) == boost::get(x) ) ;
boost::shared_ptr<boost::value_initialized<T> > ptr( new boost::value_initialized<T> );
BOOST_TEST ( y == *ptr ) ;
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
boost::value_initialized<T const> cx ; boost::value_initialized<T const> cx ;
BOOST_CHECK ( y == cx ) ; BOOST_TEST ( y == cx ) ;
BOOST_CHECK ( y == boost::get(cx) ) ; BOOST_TEST ( y == boost::get(cx) ) ;
boost::value_initialized<T const> const cx_c ; boost::value_initialized<T const> const cx_c ;
BOOST_CHECK ( y == cx_c ) ; BOOST_TEST ( y == cx_c ) ;
BOOST_CHECK ( y == boost::get(cx_c) ) ; BOOST_TEST ( y == boost::get(cx_c) ) ;
#endif #endif
return boost::detail::test_errors() == errors_before_test ;
} }
int test_main(int, char **) int main(int, char **)
{ {
test( 0,1234 ) ; BOOST_TEST ( test( 0,1234 ) ) ;
test( 0.0,12.34 ) ; BOOST_TEST ( test( 0.0,12.34 ) ) ;
test( POD(0,0,0.0), POD('a',1234,56.78) ) ; BOOST_TEST ( test( POD(0,0,0.0), POD('a',1234,56.78f) ) ) ;
test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ; BOOST_TEST ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ;
return 0; NonPOD NonPOD_object( std::string("NonPOD_object") );
BOOST_TEST ( test<NonPOD *>( 0, &NonPOD_object ) ) ;
AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 };
AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 };
BOOST_TEST ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) );
StringAndInt stringAndInt0;
StringAndInt stringAndInt1;
stringAndInt0.i = 0;
stringAndInt1.i = 1;
stringAndInt1.s = std::string("1");
BOOST_TEST ( test(stringAndInt0, stringAndInt1) );
StructWithDestructor structWithDestructor0;
StructWithDestructor structWithDestructor1;
structWithDestructor0.i = 0;
structWithDestructor1.i = 1;
BOOST_TEST ( test(structWithDestructor0, structWithDestructor1) );
StructWithVirtualFunction structWithVirtualFunction0;
StructWithVirtualFunction structWithVirtualFunction1;
structWithVirtualFunction0.i = 0;
structWithVirtualFunction1.i = 1;
BOOST_TEST ( test(structWithVirtualFunction0, structWithVirtualFunction1) );
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct0;
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct1;
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct0) = zeroInitializedAggregatePODStruct;
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct1) = nonZeroInitializedAggregatePODStruct;
BOOST_TEST ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) );
AggregatePODStructWrapper aggregatePODStructWrapper0;
AggregatePODStructWrapper aggregatePODStructWrapper1;
aggregatePODStructWrapper0.dataMember = zeroInitializedAggregatePODStruct;
aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct;
BOOST_TEST ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) );
ArrayOfBytes zeroInitializedArrayOfBytes = { 0 };
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes;
BOOST_TEST (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0);
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes2;
valueInitializedArrayOfBytes2 = valueInitializedArrayOfBytes;
BOOST_TEST (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0);
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester1;
BOOST_TEST ( ! get(copyFunctionCallTester1).is_copy_constructed);
BOOST_TEST ( ! get(copyFunctionCallTester1).is_assignment_called);
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester2 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
BOOST_TEST ( get(copyFunctionCallTester2).is_copy_constructed);
BOOST_TEST ( ! get(copyFunctionCallTester2).is_assignment_called);
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester3;
copyFunctionCallTester3 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
BOOST_TEST ( ! get(copyFunctionCallTester3).is_copy_constructed);
BOOST_TEST ( get(copyFunctionCallTester3).is_assignment_called);
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester1;
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester2;
get(swapFunctionCallTester1).data = 1;
get(swapFunctionCallTester2).data = 2;
boost::swap(swapFunctionCallTester1, swapFunctionCallTester2);
BOOST_TEST( get(swapFunctionCallTester1).data == 2 );
BOOST_TEST( get(swapFunctionCallTester2).data == 1 );
BOOST_TEST( get(swapFunctionCallTester1).is_custom_swap_called );
BOOST_TEST( get(swapFunctionCallTester2).is_custom_swap_called );
return boost::report_errors();
} }
unsigned int expected_failures = 0;

View File

@ -1,4 +1,4 @@
// (C) 2002, Fernando Luis Cacciola Carballal. // Copyright 2002, Fernando Luis Cacciola Carballal.
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,4 +1,4 @@
// (C) 2002, Fernando Luis Cacciola Carballal. // Copyright 2002, Fernando Luis Cacciola Carballal.
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,4 +1,4 @@
// (C) 2002, Fernando Luis Cacciola Carballal. // Copyright 2002, Fernando Luis Cacciola Carballal.
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

126
verify_test.cpp Normal file
View File

@ -0,0 +1,126 @@
//
// verify_test.cpp - a test for BOOST_VERIFY
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2007 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/assert.hpp>
int f( int & x )
{
return ++x;
}
void test_default()
{
int x = 1;
BOOST_VERIFY( 1 );
BOOST_VERIFY( x == 1 );
BOOST_VERIFY( ++x );
BOOST_VERIFY( f(x) );
BOOST_VERIFY( &x );
BOOST_TEST( x == 3 );
}
#define BOOST_DISABLE_ASSERTS
#include <boost/assert.hpp>
void test_disabled()
{
int x = 1;
BOOST_VERIFY( 1 );
BOOST_VERIFY( x == 1 );
BOOST_VERIFY( ++x );
BOOST_VERIFY( f(x) );
BOOST_VERIFY( &x );
BOOST_TEST( x == 3 );
BOOST_VERIFY( 0 );
BOOST_VERIFY( !x );
BOOST_VERIFY( x == 0 );
BOOST_VERIFY( !++x );
BOOST_VERIFY( !f(x) );
BOOST_TEST( x == 5 );
void * p = 0;
BOOST_VERIFY( p );
}
#undef BOOST_DISABLE_ASSERTS
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <cstdio>
int handler_invoked = 0;
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::printf;
#endif
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
++handler_invoked;
}
struct X
{
static bool f()
{
BOOST_VERIFY( 0 );
return false;
}
};
void test_handler()
{
int x = 1;
BOOST_VERIFY( 1 );
BOOST_VERIFY( x == 1 );
BOOST_VERIFY( ++x );
BOOST_VERIFY( f(x) );
BOOST_VERIFY( &x );
BOOST_TEST( x == 3 );
BOOST_VERIFY( 0 );
BOOST_VERIFY( !x );
BOOST_VERIFY( x == 0 );
BOOST_VERIFY( !++x );
BOOST_VERIFY( !f(x) );
BOOST_TEST( x == 5 );
void * p = 0;
BOOST_VERIFY( p );
BOOST_VERIFY( X::f() );
BOOST_TEST( handler_invoked == 8 );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
int main()
{
test_default();
test_disabled();
test_handler();
return boost::report_errors();
}