Compare commits

..

228 Commits

Author SHA1 Message Date
a4c9c3eb65 Branch at revision 46530
[SVN r46531]
2008-06-19 18:57:10 +00:00
15a697f86b new jamfile to see warnings better
[SVN r46348]
2008-06-12 12:00:57 +00:00
dbef3564c4 fixes from Trac
[SVN r46346]
2008-06-12 10:54:44 +00:00
b948d9af17 fixes for problems from Trac
[SVN r46345]
2008-06-12 10:00:54 +00:00
95d424012b Quote href values - our tools don't support unquoted values.
[SVN r45283]
2008-05-11 13:49:20 +00:00
36a99eb0a0 test of updated as_literal()
[SVN r45124]
2008-05-05 06:42:30 +00:00
f117011b60 fix for as_literal()
[SVN r45123]
2008-05-05 06:41:54 +00:00
7c0d73b8cf fixed problem with operator()() when the value_type was abstract.
[SVN r43322]
2008-02-19 15:10:05 +00:00
405ebd8cca include config.hpp and workaround.hpp before uses of BOOST_WORKAROUND and BOOST_MSVC
[SVN r43220]
2008-02-11 03:48:41 +00:00
94b45ef51e missing ) fixed
[SVN r43175]
2008-02-08 15:25:01 +00:00
e115ac1006 silence of warnings for unused arguments
[SVN r43171]
2008-02-08 09:58:35 +00:00
8b712359a2 test
[SVN r43156]
2008-02-07 14:46:19 +00:00
428e72ed22 iterator_range disables msvc warning 4996
<http://svn.boost.org/trac/boost/ticket/1565>

[range] sub_range assignment issue
    <http://svn.boost.org/trac/boost/ticket/1284> 

[SVN r43155]
2008-02-07 14:41:04 +00:00
73db2a05b6 cleanup to pass inspection tool
[SVN r43135]
2008-02-06 23:12:21 +00:00
507d1e8075 fixed #if to #ifdef
[SVN r42715]
2008-01-13 11:37:41 +00:00
d31787daae doc fixes
[SVN r42693]
2008-01-12 12:38:57 +00:00
14a9a1906b Ticket #1477
[SVN r41638]
2007-12-03 09:08:02 +00:00
f65c137e73 missing include
[SVN r41636]
2007-12-03 09:00:23 +00:00
8085605217 fixed a serious oversigt
[SVN r41457]
2007-11-29 09:19:24 +00:00
0eb365edbe macro patch
[SVN r41183]
2007-11-17 21:24:16 +00:00
2e0d7eab4a removed some warnings
[SVN r41181]
2007-11-17 21:21:53 +00:00
637dc618d1 iostream macro patch
[SVN r41180]
2007-11-17 21:19:13 +00:00
dd1459f221 works after local test with vc8
[SVN r41177]
2007-11-17 20:44:29 +00:00
ba96d075b2 last updates
[SVN r41176]
2007-11-17 20:22:20 +00:00
a2f3a45214 minor update of comments
[SVN r41175]
2007-11-17 20:22:05 +00:00
6ac0cfe09c improved reference
[SVN r40968]
2007-11-09 15:15:28 +00:00
7b3857a9a8 minor tweaks to avoid warnings ... extension mechanism updated to follow new protocol
[SVN r40966]
2007-11-09 13:31:43 +00:00
2605b9ee45 update of new concepts, and replacement of range_size<T>::type with range_difference<T>::type throughut the library
[SVN r40965]
2007-11-09 13:30:57 +00:00
1509d5603b minor editorial issue
[SVN r40964]
2007-11-09 13:13:06 +00:00
93deddde63 major update wrt. new range concepts
[SVN r40962]
2007-11-09 10:27:42 +00:00
68a63cab85 added deprecated headers again for backward compatibility sake
[SVN r40629]
2007-10-31 21:48:11 +00:00
06c54ccd48 current version gave problem in regression ... to be updated later
[SVN r40612]
2007-10-30 19:47:40 +00:00
2e298b5e60 adds test for inclusion of concept header
[SVN r40521]
2007-10-28 10:11:54 +00:00
00e70244a5 fixes broken one from trunk ... still not finished
[SVN r40520]
2007-10-28 10:11:10 +00:00
3f98d69c94 added mfc/atl link
[SVN r40514]
2007-10-27 22:00:47 +00:00
4767db522b first update ... more to come
[SVN r40508]
2007-10-27 15:58:22 +00:00
f6e555dda3 updated example to new syntax
[SVN r40507]
2007-10-27 15:57:56 +00:00
01826978d6 cleaned up deprecated headers
[SVN r40506]
2007-10-27 15:57:20 +00:00
336c12b60f removed deprecated mfc stuff
[SVN r40425]
2007-10-24 15:53:54 +00:00
82768af3d2 roll-back of ADL names
[SVN r40423]
2007-10-24 15:19:16 +00:00
8984de1c74 roll back of ADL names
[SVN r40422]
2007-10-24 15:18:22 +00:00
4db083cd6d Shunsuke Sogame's MFC/ATL docs and tests
[SVN r40381]
2007-10-23 20:28:52 +00:00
f4cde208f2 Adding Shunsuke Sogame fantastic MFC/ATL mappings
[SVN r40379]
2007-10-23 20:23:05 +00:00
d130dff5ec cleanup
[SVN r40378]
2007-10-23 20:08:35 +00:00
aa9158b199 applied Ticket #1309 (new Patches)
[SVN r40377]
2007-10-23 19:56:39 +00:00
bbd9fdb7bd displabed some warnings and applied Ticket #1284: sub_range_copy.patch
[SVN r40376]
2007-10-23 19:50:59 +00:00
17514e1d44 added operator() to allow random access index with transform iterators
[SVN r40375]
2007-10-23 19:34:38 +00:00
d759c23552 added test for operator()
[SVN r40374]
2007-10-23 19:34:06 +00:00
cf9ad808a6 new fancy quickbook documentaion
[SVN r40373]
2007-10-23 19:12:19 +00:00
028bff0c22 changed ADL functions back the names of 1.34 ... these names have been in use for too long ... let's not break code that depends on them
[SVN r40372]
2007-10-23 19:07:38 +00:00
33a8016af3 change names of ADL functions back to 1.34 names ... the old names have been in use for too long so let's not break code that depends on them
[SVN r40371]
2007-10-23 19:06:39 +00:00
24466ae189 applied patch from Ticket #1302 (new Patches) to handle char arrays correctly
[SVN r40370]
2007-10-23 18:59:11 +00:00
c8ffe55ae5 added test for char array with nested null in response to Ticket #471
[SVN r40367]
2007-10-23 18:36:03 +00:00
a862a573df Applied patch from Ticket #1320
[SVN r40020]
2007-10-14 17:53:15 +00:00
0b0dfc0e06 Added missing boost namespace reference to as_literal.
[SVN r39683]
2007-10-04 11:51:51 +00:00
e0a76af0f9 Quiet unused argument warnings from gcc.
[SVN r39274]
2007-09-14 17:18:02 +00:00
51650f1aa2 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
aeb47120e3 fixed typo
[SVN r36684]
2007-01-10 18:57:20 +00:00
22b7b4ec8e commented out old array code
[SVN r36683]
2007-01-10 18:50:13 +00:00
a933622ae1 Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35989]
2006-11-10 19:09:56 +00:00
f49be0b382 *** empty log message ***
[SVN r35717]
2006-10-24 10:37:46 +00:00
007117cefb Merge in recent fixes for inspect errors.
[SVN r34973]
2006-08-27 10:40:36 +00:00
73bb3d899a *** empty log message ***
[SVN r34034]
2006-05-19 18:01:02 +00:00
4a8987865e dos2unix on some files
[SVN r34025]
2006-05-19 10:30:02 +00:00
f885495565 *** empty log message ***
[SVN r34015]
2006-05-18 21:27:29 +00:00
dc34cd6079 *** empty log message ***
[SVN r34014]
2006-05-18 21:11:55 +00:00
5850d7ce3e new traits and functions for v2
[SVN r34013]
2006-05-18 20:53:21 +00:00
554f832234 upgrade to v2
[SVN r34012]
2006-05-18 20:52:17 +00:00
dc96b440be v2 upgrade
[SVN r34011]
2006-05-18 19:17:04 +00:00
1ac9efbd6a *** empty log message ***
[SVN r33301]
2006-03-10 09:16:22 +00:00
d2f0c15826 *** empty log message ***
[SVN r33271]
2006-03-08 21:40:14 +00:00
ae953cda6b *** empty log message ***
[SVN r33260]
2006-03-07 21:11:19 +00:00
b22773b2e3 applied bug fixes
[SVN r33038]
2006-02-20 21:15:05 +00:00
e50a544c2a Update Jamfile.v2
[SVN r32704]
2006-02-07 11:55:46 +00:00
4b362a9cff Rearrange the test to prevent undefined reference to init_unit_test_suite,
when:
  - BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION is not defined
  - Toolset is gcc/Linux
  - Boost.Test is built as shared library


[SVN r32703]
2006-02-07 11:55:10 +00:00
c75dc3ae02 added pass test for good compilers
[SVN r32088]
2005-12-17 15:15:32 +00:00
fa03f39333 *** empty log message ***
[SVN r32016]
2005-12-13 22:50:57 +00:00
6478f85444 *** empty log message ***
[SVN r32015]
2005-12-13 22:50:00 +00:00
51f7fe9878 added new convinience funcs
[SVN r31969]
2005-12-09 22:33:57 +00:00
c08103b1c5 merge from 1.33.1
[SVN r31968]
2005-12-09 22:22:32 +00:00
a2b6c3f5ec fixed vc7.1 iterator conversion problems
[SVN r31942]
2005-12-07 01:26:57 +00:00
e76e9cda28 Large patch from Ulrich Eckhardt to fix support for EVC++ 4.
[SVN r30670]
2005-08-25 16:27:28 +00:00
cd6a5e6a7f changed cast
[SVN r30592]
2005-08-16 15:56:23 +00:00
e82a7fab5d Merged from 1.33.0 release
[SVN r30540]
2005-08-12 13:02:37 +00:00
7311fb528a *** empty log message ***
[SVN r30165]
2005-07-18 20:04:33 +00:00
8a998c64d8 *** empty log message ***
[SVN r30163]
2005-07-18 19:50:41 +00:00
2bc8622027 Fix HTML
[SVN r30080]
2005-07-14 16:03:14 +00:00
1c4fcbee6f moved includes around to avoid http://gcc.gnu.org/PR18604 in GCC 3.4.x/4.0.x
[SVN r29458]
2005-06-07 07:11:16 +00:00
24a881ef85 CRAY X1 patch
[SVN r29309]
2005-05-30 22:45:23 +00:00
8db1f867f9 removed Borland workaround which broke iostreams on Borland
[SVN r29300]
2005-05-30 08:54:38 +00:00
e5ddbb4bbc gcc-2.95 fix
[SVN r29287]
2005-05-30 07:35:51 +00:00
f6b183140f *** empty log message ***
[SVN r29148]
2005-05-22 15:57:27 +00:00
1b3c6f1c81 workaroud for borland seems to require more work, current code is not working
[SVN r29137]
2005-05-21 23:39:50 +00:00
d509beb073 intended borland fix
[SVN r29106]
2005-05-21 00:17:33 +00:00
0965a46d9c Borland fix broke VC6
[SVN r29043]
2005-05-18 23:43:41 +00:00
5771d953ea default assignment operator added to resolve bcc problems
[SVN r28955]
2005-05-16 13:52:19 +00:00
898aae2c85 explicit handling of bool conversion operator or borland removed
[SVN r28933]
2005-05-15 17:52:05 +00:00
75667cc53d fix 'operator bool()' workaround for borland
[SVN r28932]
2005-05-15 17:47:34 +00:00
16989df4d6 removed special handling for borland in the bool conversion test
(workaround in iterator_range is applied)


[SVN r28906]
2005-05-14 18:52:48 +00:00
4b89a3e223 added workaround for borland for bool conversion operator
[SVN r28905]
2005-05-14 18:51:59 +00:00
c2ddc197aa removed redundant entries for long double
[SVN r28886]
2005-05-13 20:09:56 +00:00
0ab5e6e60d added support for more fundamental types
[SVN r28885]
2005-05-13 19:57:55 +00:00
34e3275c99 added unit_test.hpp include
[SVN r28884]
2005-05-13 19:30:19 +00:00
b2e9200529 enabled static asserts for VC6
[SVN r28881]
2005-05-13 17:09:17 +00:00
c17afe8d03 switched to BOOST_RANGE_DEDUCED_TYPENAME
[SVN r28878]
2005-05-13 15:48:05 +00:00
a5a74c161f fixed RANGE_DEDUCED_TYPENAME for VC7.0 + /Za
[SVN r28877]
2005-05-13 15:47:29 +00:00
d77dbb2d0b fixes for VC6-7.0
[SVN r28876]
2005-05-13 15:45:53 +00:00
c5d1b4a62a replaced DEDUCED_TYPENAME with typename
[SVN r28875]
2005-05-13 15:42:53 +00:00
9b1cdde025 initial commitment
[SVN r28874]
2005-05-13 15:29:36 +00:00
f5aad599ef *** empty log message ***
[SVN r28787]
2005-05-10 17:53:15 +00:00
5843a9fd3f *** empty log message ***
[SVN r28658]
2005-05-05 12:59:41 +00:00
918b652291 *** empty log message ***
[SVN r28648]
2005-05-03 22:39:49 +00:00
a02b6c0f74 updated so ADL kick in in iterator_range and const_begin/const_end
[SVN r28562]
2005-05-01 22:58:25 +00:00
b358ea0773 *** empty log message ***
[SVN r28329]
2005-04-19 19:35:43 +00:00
6d4740bcab Fix link failure for shared linking on Linux
[SVN r28316]
2005-04-18 09:05:44 +00:00
25ebab429d Add V2 Jamfile
[SVN r28244]
2005-04-14 11:56:47 +00:00
4cca4fac2f Changed - effectively I rolled back the last change because it clobbers
VC7.1 and VC8.0 tests (they do NOT show in the regression, which
          is another problem altogether) as well as killing some code of mine
          which uses boost::array.
NOTE    - I've commented out the one line I replaced so that more people can
          look at this change and decide what it _really_ needs to be (I haven't
          the time to so do).
          One thing that seems VERY odd is the changing of the && to || in the
          "new" line.


[SVN r28066]
2005-04-08 18:44:52 +00:00
6b9919ae4b *** empty log message ***
[SVN r28042]
2005-04-07 13:27:30 +00:00
1c8f27535d *** empty log message ***
[SVN r27796]
2005-03-24 11:23:04 +00:00
7d5596abd6 *** empty log message ***
[SVN r27787]
2005-03-23 20:06:44 +00:00
4524abb615 *** empty log message ***
[SVN r27671]
2005-03-15 16:00:19 +00:00
bf5ca9612c remove transform_range()
[SVN r27657]
2005-03-14 23:20:00 +00:00
844bfc5a2d *** empty log message ***
[SVN r27363]
2005-02-13 21:34:00 +00:00
d8fb9a991c added namespace qualification to boost::empty()
[SVN r27333]
2005-02-11 23:15:14 +00:00
caa13c7387 modified to conform with new iterator_rang.hpp: idl_begin and idl_end are implemented in separate class
[SVN r27279]
2005-02-09 17:41:28 +00:00
64cd26106a fixes for gcc-2.9x: support for 'old' iostreams; moved adl_begin and adl_end into separate class
[SVN r27278]
2005-02-09 17:26:18 +00:00
1451d487e1 *** empty log message ***
[SVN r27192]
2005-02-06 22:22:45 +00:00
92c5ce8ffa *** empty log message ***
[SVN r27190]
2005-02-06 22:08:12 +00:00
e5d4c1c376 *** empty log message ***
[SVN r27153]
2005-02-05 21:33:29 +00:00
fbd60395d6 *** empty log message ***
[SVN r27149]
2005-02-05 20:47:39 +00:00
d82d9b9680 *** empty log message ***
[SVN r27148]
2005-02-05 20:07:02 +00:00
ed09875157 added missing boost/assert.hpp include
[SVN r27003]
2005-02-02 03:42:25 +00:00
92c375e173 *** empty log message ***
[SVN r26766]
2005-01-20 22:33:25 +00:00
eeb7bf0fe0 Test added to spot a problem with char*/wchar_t* passed by a reference
[SVN r26752]
2005-01-19 22:26:38 +00:00
b3d4845ba6 *** empty log message ***
[SVN r26630]
2005-01-05 18:19:31 +00:00
6dd15529f6 *** empty log message ***
[SVN r26475]
2004-12-08 18:00:48 +00:00
ae8efa1436 *** empty log message ***
[SVN r25581]
2004-10-06 18:19:13 +00:00
846cbcea43 c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
3f27b522c1 cw 8.3 fixes
[SVN r25419]
2004-09-26 13:13:04 +00:00
a29ddcbcca *** empty log message ***
[SVN r25418]
2004-09-26 12:15:12 +00:00
f7ffdde09f metroworks hacks
[SVN r25342]
2004-09-22 15:24:23 +00:00
0909f0cc51 *** empty log message ***
[SVN r25319]
2004-09-21 20:03:06 +00:00
931bf86c87 *** empty log message ***
[SVN r25318]
2004-09-21 19:19:12 +00:00
920a874e3a *** empty log message ***
[SVN r25157]
2004-09-16 19:07:04 +00:00
a88312e955 *** empty log message ***
[SVN r25156]
2004-09-16 18:56:31 +00:00
6efc4ee478 *** empty log message ***
[SVN r25153]
2004-09-16 18:27:51 +00:00
c7047652d8 *** empty log message ***
[SVN r25152]
2004-09-16 18:21:42 +00:00
84a9126cc9 *** empty log message ***
[SVN r25126]
2004-09-15 21:36:14 +00:00
e6611aafb1 fixed missing references on char* arguments
[SVN r25090]
2004-09-14 21:24:20 +00:00
bd13c9082e maybe string problem is fixed
[SVN r25059]
2004-09-13 17:47:45 +00:00
af5431e553 *** empty log message ***
[SVN r25020]
2004-09-12 10:58:22 +00:00
5e470543ad *** empty log message ***
[SVN r25019]
2004-09-11 22:01:30 +00:00
3abdd3afd4 *** empty log message ***
[SVN r25018]
2004-09-11 15:33:46 +00:00
cfb03e4aee *** empty log message ***
[SVN r25014]
2004-09-10 21:44:06 +00:00
811d3da3eb *** empty log message ***
[SVN r25013]
2004-09-10 21:39:23 +00:00
4243a38acd *** empty log message ***
[SVN r25012]
2004-09-10 21:37:53 +00:00
7a5e8fba8e *** empty log message ***
[SVN r25011]
2004-09-10 21:25:55 +00:00
3b3cb0571c *** empty log message ***
[SVN r25001]
2004-09-10 11:48:58 +00:00
da43d13564 *** empty log message ***
[SVN r24999]
2004-09-10 11:43:36 +00:00
58eee2c6ef *** empty log message ***
[SVN r24991]
2004-09-09 17:49:50 +00:00
b1174d5433 *** empty log message ***
[SVN r24967]
2004-09-08 11:20:06 +00:00
3ce0264517 *** empty log message ***
[SVN r24943]
2004-09-06 20:22:37 +00:00
bf9925e2aa *** empty log message ***
[SVN r24877]
2004-09-02 17:32:58 +00:00
caac9c37c3 *** empty log message ***
[SVN r24875]
2004-09-02 17:28:57 +00:00
f3f71946a1 *** empty log message ***
[SVN r24831]
2004-08-30 18:25:00 +00:00
bf3ff8fd5d *** empty log message ***
[SVN r24826]
2004-08-30 10:56:26 +00:00
60450042a3 *** empty log message ***
[SVN r24774]
2004-08-26 23:49:24 +00:00
ea0e0c96e2 *** empty log message ***
[SVN r24773]
2004-08-26 23:35:36 +00:00
821c5c621b *** empty log message ***
[SVN r24717]
2004-08-24 15:58:01 +00:00
97b8964e51 *** empty log message ***
[SVN r24708]
2004-08-24 13:05:15 +00:00
af8171efdc *** empty log message ***
[SVN r24707]
2004-08-24 12:59:10 +00:00
a929adc492 *** empty log message ***
[SVN r24638]
2004-08-21 21:54:02 +00:00
77dff97861 *** empty log message ***
[SVN r24637]
2004-08-21 21:18:00 +00:00
e7f41d9aac *** empty log message ***
[SVN r24624]
2004-08-20 19:39:18 +00:00
7f5b192dfa *** empty log message ***
[SVN r24623]
2004-08-20 19:35:31 +00:00
4de4fbc46e *** empty log message ***
[SVN r24622]
2004-08-20 19:26:34 +00:00
df504d811a *** empty log message ***
[SVN r24621]
2004-08-20 19:11:52 +00:00
d2c2fec7a8 *** empty log message ***
[SVN r24620]
2004-08-20 19:05:27 +00:00
a6e1f784d0 *** empty log message ***
[SVN r24619]
2004-08-20 18:59:28 +00:00
63e1d006c9 *** empty log message ***
[SVN r24590]
2004-08-19 09:31:03 +00:00
789d2c3fe0 *** empty log message ***
[SVN r24569]
2004-08-18 21:37:18 +00:00
247ff6c8b8 removed errorness ADL hook
[SVN r24568]
2004-08-18 21:31:35 +00:00
e0e4055a9d *** empty log message ***
[SVN r24519]
2004-08-16 22:48:00 +00:00
230c7a245c updated naming convention
[SVN r24518]
2004-08-16 22:47:16 +00:00
a3d3c28ccc updated naming convention
[SVN r24517]
2004-08-16 22:07:07 +00:00
531339a51d *** empty log message ***
[SVN r24455]
2004-08-13 07:24:13 +00:00
68b1d06b39 *** empty log message ***
[SVN r24448]
2004-08-12 17:20:51 +00:00
8378643b44 *** empty log message ***
[SVN r24430]
2004-08-12 10:58:13 +00:00
7d81f9a845 Fix link to CSS
[SVN r24409]
2004-08-11 15:05:41 +00:00
ebca0b2a2a *** empty log message ***
[SVN r24385]
2004-08-10 16:09:30 +00:00
0dbf587323 *** empty log message ***
[SVN r24384]
2004-08-10 16:05:53 +00:00
e245cc6a7e *** empty log message ***
[SVN r24371]
2004-08-10 11:53:33 +00:00
6157440017 *** empty log message ***
[SVN r24368]
2004-08-10 09:56:55 +00:00
7b37911918 Enable array support for CW 9
[SVN r24317]
2004-08-05 21:08:42 +00:00
3e632e0a32 *** empty log message ***
[SVN r24315]
2004-08-05 19:37:40 +00:00
9657ab7b2b compat2_test removed
[SVN r24309]
2004-08-05 17:54:05 +00:00
33bde55e1c Test only on broken compilers
[SVN r24308]
2004-08-05 17:41:29 +00:00
be9bf983a8 added const overloads
[SVN r24268]
2004-08-03 15:27:59 +00:00
87374d6dfe *** empty log message ***
[SVN r24233]
2004-08-01 15:33:06 +00:00
ab738f30ba *** empty log message ***
[SVN r24196]
2004-07-30 21:28:40 +00:00
12acb0fdf7 *** empty log message ***
[SVN r24195]
2004-07-30 21:15:29 +00:00
51c6547351 *** empty log message ***
[SVN r24193]
2004-07-30 21:07:56 +00:00
aa01efb722 *** empty log message ***
[SVN r24192]
2004-07-30 20:52:50 +00:00
4356af8d45 *** empty log message ***
[SVN r24189]
2004-07-30 15:10:17 +00:00
dc7d30bab6 *** empty log message ***
[SVN r24177]
2004-07-30 03:12:22 +00:00
b86b99190b *** empty log message ***
[SVN r24176]
2004-07-30 02:56:01 +00:00
65f5d654f7 *** empty log message ***
[SVN r24174]
2004-07-30 01:30:27 +00:00
00d991f460 *** empty log message ***
[SVN r24161]
2004-07-29 14:45:19 +00:00
f94261d0aa *** empty log message ***
[SVN r24160]
2004-07-29 14:28:41 +00:00
bea144c2a8 *** empty log message ***
[SVN r24158]
2004-07-29 14:20:35 +00:00
5a479378d6 *** empty log message ***
[SVN r24140]
2004-07-28 11:01:10 +00:00
e26056b475 *** empty log message ***
[SVN r24125]
2004-07-27 18:35:14 +00:00
deb05d7f62 *** empty log message ***
[SVN r24124]
2004-07-27 18:28:10 +00:00
d73fb64736 *** empty log message ***
[SVN r24123]
2004-07-27 18:05:36 +00:00
2f4e6004f3 *** empty log message ***
[SVN r24122]
2004-07-27 17:53:15 +00:00
ec8b51b82b *** empty log message ***
[SVN r24118]
2004-07-27 14:16:38 +00:00
716d34097b *** empty log message ***
[SVN r24117]
2004-07-27 14:00:39 +00:00
eb18ab0cc6 vc6 fixes
[SVN r24116]
2004-07-27 13:56:02 +00:00
ebb9cf200c *** empty log message ***
[SVN r24115]
2004-07-27 13:37:57 +00:00
d2dca990db vc6 fixes
[SVN r24114]
2004-07-27 13:37:44 +00:00
81b3665c8f *** empty log message ***
[SVN r24112]
2004-07-27 12:29:02 +00:00
129e5862d2 *** empty log message ***
[SVN r24080]
2004-07-26 14:20:06 +00:00
1494248e57 Remove tabs in file.
[SVN r24043]
2004-07-25 17:12:17 +00:00
23625421f1 *** empty log message ***
[SVN r24009]
2004-07-24 13:16:12 +00:00
fd8f0bebd0 *** empty log message ***
[SVN r23991]
2004-07-23 14:09:14 +00:00
d78d5e3fd6 *** empty log message ***
[SVN r23988]
2004-07-23 14:00:36 +00:00
25ecc19ec1 *** empty log message ***
[SVN r23987]
2004-07-23 12:45:24 +00:00
3a452b498f *** empty log message ***
[SVN r23986]
2004-07-23 12:38:56 +00:00
88 changed files with 14061 additions and 1270 deletions

32
doc/Jamfile.v2 Normal file
View File

@ -0,0 +1,32 @@
#// Boost.Range library
#//
#// Copyright Thorsten Ottosen 2003-2008. Use, modification and
#// distribution is subject to the Boost Software License, Version
#// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
#// http://www.boost.org/LICENSE_1_0.txt)
#//
#// For more information, see http://www.boost.org/libs/range/
#//
use-project boost : $(BOOST_ROOT) ;
import boostbook : boostbook ;
import quickbook ;
xml boost_range : boost_range.qbk ;
boostbook standalone
:
boost_range
:
<xsl:param>toc.max.depth=2
<xsl:param>toc.section.depth=4
<xsl:param>chunk.section.depth=2
# <xsl:param>generate.section.toc.level=4
# <xsl:param>chunk.first.sections=7
# <xsl:param>toc.section.depth=10
;

769
doc/boost_range.html Normal file
View File

@ -0,0 +1,769 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Boost.Range Reference </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table>
<tr>
<td><img src="../../../boost.png" width="100%" border="0"></td>
<td><h1><br>
Boost.Range
</h1>
</td>
</tr>
</table>
<h2>Synopsis and Reference
</h2>
<ul>
<li>
<a href="#overview">Overview</a>
<li>
<a href="#Synopsis">Synopsis</a>
<li>
<a href="#Semantics">Semantics</a>
<li>
<a href="#minimal_interface">Extending the library</a></li>
</ul>
<hr size="1">
<a name="overview"></a>
<h3>Overview</h3>
<p>
Three types of objects are currently supported by the library:
<ul>
<li>
standard-like containers
<li>
<code>std::pair&lt;iterator,iterator&gt;</code>
<li>
built-in arrays
</li>
</ul>
Even though the behavior of the primary templates are exactly such that
standard containers will be supported by default, the requirements are much
lower than the standard container requirements. For example, the utility class <a href="utility_class.html#iter_range">
<code>iterator_range</code></a> implements the <a href="#minimal_interface">minimal
interface</a> required to make the class a <a href="range.html#forward_range">Forward
Range</a>
.
<P></P>
<p>
Please also see <a href="range.html">Range concepts</a> for more details.
</p>
<a name="Synopsis"></a>
<h3>Synopsis</h3>
<p>
<pre>
<span class=keyword>namespace </span><span class=identifier>boost</span>
<span class=special>{
</span><span class=comment>//
// Single Pass Range metafunctions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_iterator"><span
class=identifier>range_iterator</span></a><span class=special>;
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_value"><span
class=identifier>range_value</span></a><span class=special>;
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_reference"><span
class=identifier>range_reference</span></a><span class=special>;
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_pointer"><span
class=identifier>range_pointer</span></a><span class=special>;
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_category"><span
class=identifier>range_category</span></a><span class=special>;
</span><span class=comment>//
// Forward Range metafunctions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_difference"><span
class=identifier>range_difference</span></a><span class=special>;
</span><span class=comment>//
// Bidirectional Range metafunctions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a
href="#range_reverse_iterator"><span
class=identifier>range_reverse_iterator</span></a><span class=special>;
</span><span class=comment>//
// Single Pass Range functions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#begin"><span class=identifier>begin</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#begin"><span class=identifier>begin</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#end"><span class=identifier>end</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#end"><span class=identifier>end</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>bool
</span><a href="#empty"><span class=identifier>empty</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=comment>//
// Forward Range functions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#size"><span class=identifier>distance</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=comment>//
// Bidirectional Range functions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#rbegin"><span class=identifier>rbegin</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#rbegin"><span class=identifier>rbegin</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#rend"><span class=identifier>rend</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#rend"><span class=identifier>rend</span></a><span class=special>( </span><span class=keyword>const </span><span
class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
</span><span class=comment>//
// Random Access Range functions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#size"><span class=identifier>size</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);</span>
<span class=comment>//
// Special const Range functions
//
</span>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;</span>
<span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type </span>
<a href="#const_begin"><span class=identifier>const_begin</span></a><span class=special>(</span><span class=keyword> const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;</span>
<span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type </span>
<a href="#const_end"><span class=identifier>const_end</span></a><span class=special>(</span><span class=keyword> const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;</span>
<span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type </span>
<a href="#const_rbegin"><span class=identifier>const_rbegin</span></a><span class=special>(</span><span class=keyword> const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;</span>
<span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type </span>
<a href="#const_rend"><span class=identifier>const_rend</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);</span>
<span class=comment>//
// String utilities
//</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=identifier>iterator_range</span><span class=special>&lt;...</span><span class=identifier>see</span> <span class=identifier>below</span><span class=special>...&gt;</span>
<span class=identifier><a href="#as_literal">as_literal</a></span><span class=special>(</span> <span class=identifier>T</span><span class=special>&amp;</span> <span class=identifier>r</span> <span class=special>);</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=identifier>iterator_range</span><span class=special>&lt;...</span><span class=identifier>see</span> <span class=identifier>below</span><span class=special>...&gt;</span>
<span class=identifier><a href="#as_array">as_literal</a></span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>T</span><span class=special>&amp;</span> <span class=identifier>r</span> <span class=special>);</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=identifier>iterator_range</span><span class=special>&lt;</span> <span class=keyword>typename</span> <span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type</span> <span class=special>&gt;</span>
<span class=identifier><a href="#as_array">as_array</a></span><span class=special>(</span> <span class=identifier>T</span><span class=special>&amp;</span> <span class=identifier>r</span> <span class=special>);</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=identifier>iterator_range</span><span class=special>&lt;</span> <span class=keyword>typename</span> <span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const</span> <span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type</span> <span class=special>&gt;</span>
<span class=identifier><a href="#as_literal">as_array</a></span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>T</span><span class=special>&amp;</span> <span class=identifier>r</span> <span class=special>);</span>
<span class=special>} </span><span class=comment>// namespace 'boost'
</span>
</pre>
<P></P>
<a name="Semantics"></a>
<h3>Semantics</h3>
<h4>notation</h4>
<p>
<table cellpadding="5" border="1">
<tr>
<th>
Type
<th>
Object
<th>
Describes
</tr>
<tr>
<td><code>X</code>
<td><code>x</code>
<td>any type</td>
<tr>
<td><code>T</code>
</td>
<td><code>t</code>
<td>denotes behavior of the primary templates</td>
</tr>
<tr>
<td><code>P</code>
<td><code>p</code>
<td>denotes <code>std::pair&lt;iterator,iterator&gt;</code></td>
<tr>
<td><code>A[sz]</code>
<td><code>a</code>
<td>denotes an array of type <code>A</code> of size <code>sz</code>
<tr>
<tr>
<td><code>Char*</code>
<td><code>s</code>
<td>denotes either <code>char*</code> or <code>wchar_t*</code></td>
</tr>
</table>
</p>
<p>
Please notice in tables below that when four lines appear in a cell, the first
line will describe the primary template, the second line pairs of iterators,
the third line arrays and the last line null-terminated strings.
</p>
<h4>Metafunctions</h4>
<p>
<table border="1" cellpadding="5">
<tr>
<th>
Expression</th>
<th>
Return type</th>
<th>
Complexity</th>
</tr>
<tr>
<a name="range_iterator"></a>
<td><code>range_iterator&lt;X&gt;::type</code></td>
<td><code>T::iterator</code><br>
<code>P::first_type</code><br>
<code>A*</code><br>
<td>compile time</td>
</tr>
<tr>
<a name="range_const_iterator"></a>
<td><code>range_iterator&lt;const X&gt;::type</code></td>
<td><code>T::const_iterator</code><br>
<code>P::first_type</code><br>
<code>const A*</code><br>
<td>compile time</td>
</tr>
<tr>
<a name="range_value"></a>
<td><code>range_value&lt;X&gt;::type</code></td>
<td><code>boost::iterator_value&lt;range_iterator&lt;X&gt;::type&gt;::type</code>
</td>
<td>compile time</td>
</tr>
<tr>
<a name="range_reference"></a>
<td><code>range_reference&lt;X&gt;::type</code></td>
<td><code>boost::iterator_reference&lt;range_iterator&lt;X&gt;::type&gt;::type</code>
</td>
<td>compile time</td>
</tr>
<tr>
<a name="range_pointer"></a>
<td><code>range_pointer&lt;X&gt;::type</code></td>
<td><code>boost::iterator_pointer&lt;range_iterator&lt;X&gt;::type&gt;::type</code>
</td>
<td>compile time</td>
</tr>
<tr>
<a name="range_category"></a>
<td><code>range_category&lt;X&gt;::type</code></td>
<td><code>boost::iterator_category&lt;range_iterator&lt;X&gt;::type&gt;::type</code>
</td>
<td>compile time</td>
</tr>
<tr>
<a name="range_difference"></a>
<td><code>range_difference&lt;X&gt;::type</code></td>
<td>
<code>boost::iterator_difference&lt;range_iterator&lt;X&gt;::type&gt;::type</code></td>
<td>compile time</td>
</tr>
</tr>
<tr>
<a name="range_reverse_iterator"></a>
<td><code>range_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>boost::reverse_iterator&lt;range_iterator&lt;X&gt;::type&gt;</code><br>
<td>compile time</td>
</tr>
<tr>
<a name="range_const_reverse_iterator"></a>
<td><code>range_reverse_iterator&lt;const X&gt;::type</code></td>
<td><code>boost::reverse_iterator&lt;range_iterator&lt;const X&gt;::type&gt;</code>
<br>
<td>compile time</td>
</tr>
</table>
</p>
<h4>Functions</h4>
<p>
<table border="1" cellpadding="5">
<tr>
<th>
Expression</th>
<th>
Return type</th>
<th>
Returns</th>
<th>
Complexity</th>
</tr>
<tr>
<a name="begin"></a>
<td><code>begin(x)</code></td>
<td><code>range_iterator&lt;X&gt;::type</code></td>
<td>
<code>p.first</code> if <code>p</code> is of type <code>std::pair&ltT&gt;<code><br>
<code>a</code> if <code>a</code> is an array <br>
<code>range_begin(x)</code> if that expression would invoke a function found by ADL <br>
<code>t.begin()</code> otherwise
<td>constant time</td>
</tr>
<tr>
<a name="end"></a>
<td><code>end(x)</code></td>
<td><code>range_iterator&lt;X&gt;::type</code></td>
<td>
<code>p.second</code> if <code>p</code> is of type <code>std::pair&ltT&gt;<code><br>
<code>a + sz</code> if <code>a</code> is an array of size <code>sz</code>
<br>
<code>range_end(x)</code> if that expression would invoke a function found by ADL <br>
<code>t.end()</code> otherwise
<td>
constant time </td>
</tr>
<tr>
<a name="empty"></a>
<td><code>empty(x)</code></td>
<td><code>bool</code></td>
<td><code>boost::begin(x) == boost::end(x)</code><br>
<td> constant time <br>
</td>
</tr>
<tr>
<a name="distance"></a>
<td><code>distance(x)</code></td>
<td><code>range_difference&lt;X&gt;::type</code></td>
<td>
<code>
std::distance(boost::begin(x),boost::end(x))
</code>
</td>
<td>-</td>
</tr>
<tr>
<a name="size"></a>
<td><code>size(x)</code></td>
<td><code>range_difference&lt;X&gt;::type</code></td>
<td><code> boost::end(x) - boost::begin(x)</code>
<td> constant time </td>
</tr>
<tr>
<a name="rbegin"></a>
<td><code>rbegin(x)</code></td>
<td><code>range_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;X&gt;::type( boost::end(x) )</code>
<br>
<td>constant time
</td>
</tr>
<tr>
<a name="rend"></a>
<td><code>rend(x)</code></td>
<td><code>range_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;X&gt;::type( boost::begin(x) )</code>
<td>constant time</td>
</tr>
<tr>
<a name="const_begin"></a>
<td><code>const_begin(x)</code></td>
<td><code>range_iterator&lt;const X&gt;::type</code></td>
<td><code>range_iterator&lt;const X&gt;::type( boost::begin(x) )</code>
<br>
<td>constant time
</td>
</tr>
<tr>
<a name="const_end"></a>
<td><code>const_end(x)</code></td>
<td><code>range_iterator&lt;const X&gt;::type</code></td>
<td><code>range_iterator&lt;const X&gt;::type( boost::end(x) )</code>
<td>constant time</td>
</tr>
<tr>
<a name="const_rbegin"></a>
<td><code>const_rbegin(x)</code></td>
<td><code>range_reverse_iterator&lt;const X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;const X&gt;::type( boost::rbegin(x) )</code>
<br>
<td>constant time
</td>
</tr>
<tr>
<a name="const_rend"></a>
<td><code>const_rend(x)</code></td>
<td><code>range_reverse_iterator&lt;const X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;const X&gt;::type( boost::rend(x) )</code>
<td>constant time</td>
</tr>
<tr>
<a name="as_literal"></a>
<td><code>as_literal(x)</code></td>
<td><code>iterator_range&lt;U></code> where <code>U</code> is
<code>Char*</code> if <code>x</code> is a pointer to a
string and <code>U</code> is
<code>range_iterator&lt;X>::type</code> otherwise
</td>
<td>
<code>[a,a+sz-1)</code> if <code>a</code> is an array of size <code>sz</code><br>
<code>[s,s + std::char_traits&lt;X&gt;::length(s))</code> if <code>s</code> is a <code>Char*</code>
<br>
<code>[boost::begin(x),boost::end(x))</code> otherwise
</td>
<td>linear time for pointers to a string, constant time
otherwise</td>
</tr>
<tr>
<a name="as_array"></a>
<td><code>as_array(x)</code></td>
<td><code>iterator_range&lt;X></code> </td>
<td>
<code>[boost::begin(x),boost::end(x))</code>
</td>
<td>constant time otherwise</td>
</tr>
</table>
</p>
<p>
The special <code>const_</code>-named functions are useful when you
want to document clearly that your code is read-only.
</p>
<p>
<code>as_literal()</code> can be used <i>internally</i> in string
algorithm librararies such that arrays of characters are
handled correctly.
</p>
<p>
<code>as_array()</code> can be used with string algorithm libraries to make it clear that arrays of characters are handled like an array and not like a string.
</p>
<p>Notice that the above functions should always be called with
qualification (<code>boost::</code>) to prevent <i>unintended</i>
Argument Dependent Lookup (ADL).
</p>
<hr>
<a name="minimal_interface"></a>
<h3>Extending the library</h3>
<ul>
<li><a href="#method1">Method 1: provide member functions and nested types</a></li>
<li><a href="#method2">Method 2: provide free-standing functions and specialize metafunctions</a></li>
</ul>
<!--<b>Warning:</b><i> If possible, then prefer method 1 if you want to be absolutely sure your code is forward compatible.
</i>-->
<a name="method1"></a>
<h4>Method 1: provide member functions and nested types</h4>
<p>
This procedure assumes that you have control over the types that should be made
conformant to a Range concept. If not, see <a href="#method2">method 2</a>.
</p>
<p>
The primary templates in this library are implemented such that standard
containers will work automatically and so will <code>boost::<a href="../../array/index.html">array</a></code>.
Below is given an overview of which member functions and member types a class
must specify to be useable as a certain Range concept.
</p>
<p>
<table cellpadding="5" border="1">
<tr>
<th>
Member function</th>
<th>
Related concept</th>
<tr>
<td><code>begin()</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>end()</code>
</td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
</table>
</p>
<p>
Notice that <code>rbegin()</code> and <code>rend()</code> member functions are
not needed even though the container can support bidirectional iteration.
</p>
<p>
The required member types are:
</p>
<p>
<table cellpadding="5" border="1">
<tr>
<th>
Member type</th>
<th>
Related concept</th>
<tr>
<tr>
<td><code>iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>const_iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
</table>
</p>
<p>
Again one should notice that member types <code>reverse_iterator</code> and <code>const_reverse_iterator</code>
are not needed.
</p>
<a name="method2"></a>
<h4>Method 2: provide free-standing functions and specialize metafunctions</h4>
<p>
This procedure assumes that you cannot (or do not wish to) change the types that should be made
conformant to a Range concept. If this is not true, see <a href="#method1">method 1</a>.
</p>
<p>
The primary templates in this library are implemented such that
certain functions are found via argument-dependent-lookup (ADL).
Below is given an overview of which free-standing functions a class
must specify to be useable as a certain Range concept.
Let <code>x</code> be a variable (<code>const</code> or mutable)
of the class in question.
</p>
<p>
<table cellpadding="5" border="1" ID="Table1">
<tr>
<th>
Function</th>
<th>
Related concept</th>
<tr>
<td><code>range_begin(x)</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>range_end(x)</code>
</td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
</table>
</p>
<p><code>range_begin()</code> and <code>range_end()</code> must be
overloaded for both <code>const</code> and mutable reference arguments.
</p>
<p>
You must also specialize two metafunctions for your type <code>X</code>:
</p>
<p>
<table cellpadding="5" border="1" ID="Table2">
<tr>
<th>
Metafunction</th>
<th>
Related concept</th>
<tr>
<td><code>boost::range_mutable_iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>boost::range_const_iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
</table>
</p>
<p>
A complete example is given here:
</p>
<blockquote>
<pre>
<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>range</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>&gt;</span> <span class=comment>// for std::iterator_traits, std::distance()</span>
<span class=keyword>namespace</span> <span class=identifier>Foo</span>
<span class=special>{</span>
<span class=comment>//
// Our sample UDT. A 'Pair'
// will work as a range when the stored
// elements are iterators.
//</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>struct</span> <span class=identifier>Pair</span>
<span class=special>{</span>
<span class=identifier>T</span> <span class=identifier>first</span><span class=special>,</span> <span class=identifier>last</span><span class=special>;</span>
<span class=special>};</span>
<span class=special>}</span> <span class=comment>// namespace 'Foo'</span>
<span class=keyword>namespace</span> <span class=identifier>boost</span>
<span class=special>{</span>
<span class=comment>//
// Specialize metafunctions. We must include the range.hpp header.
// We must open the 'boost' namespace.
//</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>struct</span> <span class=identifier>range_mutable_iterator</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=special>{</span>
<span class=keyword>typedef</span> <span class=identifier>T</span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>};</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>struct</span> <span class=identifier>range_const_iterator</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=special>{</span>
<span class=comment>//
// Remark: this is defined similar to 'range_mutable_iterator'
// because the 'Pair' type does not distinguish
// between an iterator and a const_iterator.
//</span>
<span class=keyword>typedef</span> <span class=identifier>T</span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>};</span>
<span class=special>}</span> <span class=comment>// namespace 'boost'</span>
<span class=keyword>namespace</span> <span class=identifier>Foo</span>
<span class=special>{</span>
<span class=comment>//
// The required functions. These should be defined in
// the same namespace as 'Pair', in this case
// in namespace 'Foo'.
//</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_begin</span><span class=special>(</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>first</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_begin</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>first</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_end</span><span class=special>(</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>last</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_end</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>last</span><span class=special>;</span>
<span class=special>}</span>
<span class=special>}</span> <span class=comment>// namespace 'Foo'</span>
<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>vector</span><span class=special>&gt;</span>
<span class=keyword>int</span> <span class=identifier>main</span><span class=special>()</span>
<span class=special>{</span>
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt;::</span><span class=identifier>iterator</span> <span class=identifier>iter</span><span class=special>;</span>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt;</span> <span class=identifier>vec</span><span class=special>;</span>
<span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=identifier>pair</span> <span class=special>=</span> <span class=special>{</span> <span class=identifier>vec</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span> <span class=identifier>vec</span><span class=special>.</span><span class=identifier>end</span><span class=special>()</span> <span class=special>};</span>
<span class=keyword>const</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;&amp;</span> <span class=identifier>cpair</span> <span class=special>=</span> <span class=identifier>pair</span><span class=special>;</span>
<span class=comment>//
// Notice that we call 'begin' etc with qualification.
//</span>
<span class=identifier>iter</span> <span class=identifier>i</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>(</span> <span class=identifier>pair</span> <span class=special>);</span>
<span class=identifier>iter</span> <span class=identifier>e</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>(</span> <span class=identifier>pair</span> <span class=special>);</span>
<span class=identifier>i</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=identifier>e</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_difference</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span> <span class=identifier>s</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>size</span><span class=special>(</span> <span class=identifier>pair</span> <span class=special>);</span>
<span class=identifier>s</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>size</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span> <span class=identifier>const Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span>
<span class=identifier>ri</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>rbegin</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>),</span>
<span class=identifier>re</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>rend</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=special>}</span>
</pre>
</blockquote>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

1234
doc/boost_range.qbk Normal file

File diff suppressed because it is too large Load Diff

151
doc/example.cpp Normal file
View File

@ -0,0 +1,151 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/range.hpp>
#include <iterator> // for std::iterator_traits, std::distance()
namespace Foo
{
//
// Our sample UDT. A 'Pair'
// will work as a range when the stored
// elements are iterators.
//
template< class T >
struct Pair
{
T first, last;
};
} // namespace 'Foo'
namespace boost
{
//
// Specialize metafunctions. We must include the range.hpp header.
// We must open the 'boost' namespace.
//
/*
template< class T >
struct range_value< Foo::Pair<T> >
{
typedef typename std::iterator_traits<T>::value_type type;
};
*/
template< class T >
struct range_iterator< Foo::Pair<T> >
{
typedef T type;
};
template< class T >
struct range_const_iterator< Foo::Pair<T> >
{
//
// Remark: this is defined similar to 'range_iterator'
// because the 'Pair' type does not distinguish
// between an iterator and a const_iterator.
//
typedef T type;
};
/*
template< class T >
struct range_difference< Foo::Pair<T> >
{
typedef typename std::iterator_traits<T>::difference_type type;
};
*/
template< class T >
struct range_size< Foo::Pair<T> >
{
int static_assertion[ sizeof( std::size_t ) >=
sizeof( typename range_difference< Foo::Pair<T> >::type ) ];
typedef std::size_t type;
};
} // namespace 'boost'
namespace Foo
{
//
// The required functions. These should be defined in
// the same namespace as 'Pair', in this case
// in namespace 'Foo'.
//
template< class T >
inline T boost_range_begin( Pair<T>& x )
{
return x.first;
}
template< class T >
inline T boost_range_begin( const Pair<T>& x )
{
return x.first;
}
template< class T >
inline T boost_range_end( Pair<T>& x )
{
return x.last;
}
template< class T >
inline T boost_range_end( const Pair<T>& x )
{
return x.last;
}
template< class T >
inline typename boost::range_size< Pair<T> >::type
boost_range_size( const Pair<T>& x )
{
return std::distance(x.first,x.last);
}
} // namespace 'Foo'
#include <vector>
int main()
{
typedef std::vector<int>::iterator iter;
std::vector<int> vec;
vec.push_back( 42 );
Foo::Pair<iter> pair = { vec.begin(), vec.end() };
const Foo::Pair<iter>& cpair = pair;
//
// Notice that we call 'begin' etc with qualification.
//
iter i = boost::begin( pair );
iter e = boost::end( pair );
i = boost::begin( cpair );
e = boost::end( cpair );
boost::range_size< Foo::Pair<iter> >::type s = boost::size( pair );
s = boost::size( cpair );
boost::range_const_reverse_iterator< Foo::Pair<iter> >::type
ri = boost::rbegin( cpair ),
re = boost::rend( cpair );
//
// Test metafunctions
//
boost::range_value< Foo::Pair<iter> >::type
v = *boost::begin(pair);
boost::range_difference< Foo::Pair<iter> >::type
d = boost::end(pair) - boost::begin(pair);
}

72
doc/examples.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Examples </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range </h1></td>
</tr>
</table>
<h2 >Examples</h2><a name="Examples" ></a>
<p >
Some examples are given in the accompanying test files:
</p>
<ul >
<li >
<a href="../test/string.cpp" target="_self" ><code >string.cpp</code></a>
</li>
shows how to implement a container version of <code >std::find()</code> that
works with <code >char[],wchar_t[],char*,wchar_t*.</code>
<li >
<a href="../test/algorithm_example.cpp" target="_self" ><code >algorithm_example.cpp</code></a>
</li>
shows the replace example from the introduction.
<li> <a href="../test/iterator_range.cpp">iterator_range.cpp</a>
<li> <a href="../test/sub_range.cpp">sub_range.cpp</a>
<li> <a href="../test/iterator_pair.cpp">iterator_pair.cpp</a>
<li> <a href="../test/reversible_range.cpp">reversible_range.cpp</a>
<li> <a href="../test/std_container.cpp">std_container.cpp</a>
<li> <a href="../test/array.cpp">array.cpp</a>
</ul>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

145
doc/faq.html Normal file
View File

@ -0,0 +1,145 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range FAQ </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range</h1></td>
</tr>
</table>
<p>
<h2 >FAQ</h2> <a name="FAQ" ></a>
<ol >
<li >
<i>Why is there no difference between <code >range_iterator&lt;C&gt;::type</code>
and <code >range_const_iterator&lt;C&gt;::type</code> for <code>std::pair&lt;iterator, iterator&gt;</code></i>.
</li>
<p >
In general it is not possible nor desirable to find a corresponding <code >const_iterator</code>.
When it is possible to come up with one, the client might choose to construct a <code >std::pair&lt;const_iterator,const_iterator&gt;</code>
object.
</p>
<p>
Note that an <a href="utility_class.html#iter_range">iterator_range</a>
is somewhat more convenient than a <code>pair</code> and that a <a
href="utility_class.html#sub_range"><code>sub_range</code></a> does
propagate const-ness. </p>
<li >
<i>Why is there not supplied more types or more functions?</i>
<p >
The library has been kept small because its current interface will
serve most
purposes. If and when a genuine need arises for more functionality, it can be
implemented.
</p>
</li>
<li >
<i>How should I implement generic algorithms for ranges?</i>
<p >
One should always start with a generic algorithm that takes two iterators (or
more) as input. Then use Boost.Range to build handier versions on top of the
iterator based algorithm. Please notice that once the range version of the
algorithm is done, it makes sense <i>not</i> to expose the iterator version in
the public interface.
</p>
</li>
<li>
<i>Why is there no Incrementable Range concept?</i>
<p>
Even though we speak of incrementable iterators, it would not make
much sense for ranges; for example, we cannot determine the size and
emptiness of a range since we cannot even compare
its iterators.
</p>
<p>
Note also that incrementable iterators are derived from output
iterators and so there exist no output range.
</p>
</li>
<!--
<li>
<i>Should I use qualified syntax, for example
<blockquote><pre>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>); </span>
</pre></blockquote>
instead of
<blockquote>
<pre><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>;</span>
<span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>)</span></pre></blockquote>
when calling functions in this library? If so, can I still rely on argument
dependent lookup (ADL) to kick in?</i>
<p>
The answer to the first question is that "it's up to you". The
answer to the second question is Yes. Normally qualified syntax
disables ADL, but the functions are implemented in a special
manner that preserves ADL properties. The trick was explained by
Daniel Frey on comp.lang.std.c++ in the thread "Whence Swap" and
it is best explained by some code: <blockquote>
<pre>
<span class=keyword>namespace </span><span class=identifier>boost</span>
<span class=special>{
</span><span class=keyword>namespace </span><span class=identifier>range_detail
</span><span class=special>{
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;:</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>)
</span><span class=special>{ </span><span class=comment>/* normal implementation */ </span><span class=special>}
</span><span class=special>}
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>)
</span><span class=special>{
</span><span class=comment>//
// Create ADL hook
//
</span><span class=keyword>using </span><span class=identifier>range_detail</span><span class=special>::</span><span class=identifier>begin</span><span class=special>;
</span><span class=keyword>return </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
</span><span class=special>}</span>
<span class=special>} </span>
</pre>
</blockquote>
Cool indeed!
</p>
-->
</ol>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

202
doc/headers.html Normal file
View File

@ -0,0 +1,202 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Headers </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range</h1></td>
</tr>
</table>
<p>
<h2 >Library headers</h2><a name="Library headers" ></a>
<table cellpadding="5" border="1" >
<tr >
<th >Header</th>
<th >Includes</th>
<th>Related concept </th>
</tr>
<tr >
<td ><code >&lt;boost/range.hpp&gt;</code></td>
<td >everything</td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/metafunctions.hpp&gt;</code></td>
<td >every metafunction</td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/functions.hpp&gt;</code></td>
<td >every function</td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/value_type.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_value" >range_value</a></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr >
<td ><code >&lt;boost/range/iterator.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_iterator"
>range_iterator</a></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/mutable_iterator.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_mutable_iterator"
>range_mutable_iterator</a></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/const_iterator.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_const_iterator"
>range_const_iterator</a></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/difference_type.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_difference"
>range_difference</a></td>
<td><a href="range.html#forward_range">Forward Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/pointer.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_pointer"
>range_pointer</a></td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/category.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_category"
>range_category</a></td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/reverse_iterator.hpp&gt;</code></td>
<td ><a href="boost_range.html#range_reverse_iterator" >range_reverse_iterator</a></td>
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/begin.hpp&gt;</code></td>
<td >
<a href="boost_range.html#begin" >begin</a> and
<a href="boost_range.html#const_begin" >const_begin</a>
</td>
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/end.hpp&gt;</code></td>
<td >
<a href="boost_range.html#end" >end</a> and
<a href="boost_range.html#const_end" >const_end</a>
</td>
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/empty.hpp&gt;</code></td>
<td ><a href="boost_range.html#empty" >empty</a></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/distance.hpp&gt;</code></td>
<td ><a href="boost_range.html#distance" >distance</a></td>
<td><a href="range.html#forward_range">Forward Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/size.hpp&gt;</code></td>
<td ><a href="boost_range.html#size" >size</a></td>
<td><a href="range.html#random_access_range">Random Access Range</a>
</td>
</tr>
<tr >
<td ><code >&lt;boost/range/rbegin.hpp&gt;</code></td>
<td >
<a href="boost_range.html#rbegin" >rbegin</a> and
<a href="boost_range.html#const_rbegin" >const_rbegin</a>
</td>
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/rend.hpp&gt;</code></td>
<td >
<a href="boost_range.html#rend" >rend</a> and
<a href="boost_range.html#const_rend" >const_rend</a>
</td>
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
</tr>
<tr >
<td ><code >&lt;boost/range/as_array.hpp&gt;</code></td>
<td >
<a href="boost_range.html#as_array" >as_array</a>
</td>
<td>-</td>
</tr>
<tr >
<td ><code >&lt;boost/range/as_literal.hpp&gt;</code></td>
<td >
<a href="boost_range.html#as_literal" >as_literal</a>
</td>
<td>-</td>
</tr>
<tr >
<td ><code >&lt;boost/range/iterator_range.hpp&gt;</code></td>
<td ><a href="utility_class.html#iter_range"
>iterator_range</a></td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/sub_range.hpp&gt;</code></td>
<td ><a href="utility_class.html#sub_range" >sub_range</a></td>
<td>- </td>
</tr>
<tr >
<td ><code >&lt;boost/range/concepts.hpp&gt;</code></td>
<td ><a href="range.html#concept_checking" >concept checks</a></td>
<td>- </td>
</tr>
</table>
<br
</p>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

90
doc/history_ack.html Normal file
View File

@ -0,0 +1,90 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range History and Acknowledgement </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td><img src="../../../boost.png" border="0" ></td>
<td><h1 align="center">Boost.Range </h1></td>
</tr>
</table>
<h2 >History and Acknowledgement</h2><a name="History" ></a>
<p >
The library was under way for a long time. Dietmar K<>hl originally intended
to submit an <code >array_traits</code> class template which had most of
the functionality present now, but only for arrays and standard containers.
I believe this was back in 2001 or 2002.
</p>
<p>
Meanwhile work on algorithms for containers in various contexts showed the
need for handling pairs of iterators, and string libraries needed special
treatment of character arrays. In the end it made sense to formalize the
minimal requirements of these similar concepts. And the results are the
Range concepts found in this library. </p>
<p>
The term Range was adopted because of paragraph <code>24.1/7</code> from the
C++ standard: <blockquote>
Most of the library's algorithmic templates that operate on data
structures have interfaces that use ranges. A <i>range</i> is a pair of
iterators that designate the beginning and end of the computation. A
range [i, i) is an empty range; in general, a range [i, j) refers to
the elements in the data structure starting with the one pointed to
by i and up to but not including the one pointed to by j. Range [i,
j) is valid if and only if j is reachable from i. The result of the
application of functions in the library to invalid ranges is
undefined.
</blockquote>
<p>
Special thanks goes to
<ul>
<li> Pavol Droba for help with documentation and implementation
<li> Pavel Vozenilek for help with porting the library
<li> Jonathan Turkanis and John Torjo for help with documentation
<li> Hartmut Kaiser for being review manager
<li> Jonathan Turkanis for porting the lib (as far sa possible) to
vc6 and vc7.
</ul>
</p>
<p>
The concept checks and their documentation was provided by Daniel Walker.
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

164
doc/intro.html Normal file
View File

@ -0,0 +1,164 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Introduction </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range</h1></td>
</tr>
</table>
<h2>Introduction</h2>
<p>
Generic algorithms have so far been specified in terms of two or more
iterators. Two iterators would together form a range of values that the
algorithm could work on. This leads to a very general interface, but also
to a somewhat clumsy use of the algorithms with redundant specification
of container names. Therefore we would like to raise the abstraction level
for algorithms so they specify their interface in terms of <a
href="range.html">Ranges</a> as much as possible.
</p>
<p>
The most common form of ranges we are used to work with is standard library
containers. However, one
often finds it desirable to extend that code to work with other types that
offer
enough functionality to satisfy the needs of the generic code
<i>if a suitable layer of indirection is applied </i>. For
example, raw arrays are often suitable for use with generic code that
works with containers, provided a suitable adapter is used.
</p>
<p>
This library therefore provides the means to adapt standard-like
containers, <code>std::pairs</code> of iterators, and raw arrays (and
more), such that
the same generic code can work with them all.
The basic idea is to add another layer of indirection using <a
href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a> and
free-standing functions so syntactic and/or semantic differences can be removed.
</p>
<p >
The main advantages are
<ul >
<li >
simpler implementation and specification of generic range algorithms
</li>
<li >
more flexible, compact and maintainable client code
</li>
<li >
safe use of built-in arrays
</li>
</ul>
</p>
<p > Below is given a small example (the complete example can be found <a
href="../test/algorithm_example.cpp" target="_self" >here</a>): <blockquote>
<pre >
<span class=comment>
//
// example: extracting bounds in a generic algorithm
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardReadableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_iterator</span><span class=special>&lt; </span><span class=identifier>ForwardReadableRange </span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>ForwardReadableRange</span><span class=special>&amp; </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>value </span><span class=special>)
</span><span class=special>{
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>value </span><span class=special>);
</span><span class=special>}
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardReadableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_iterator</span><span class=special>&lt; </span><span class=keyword>const </span><span
class=identifier>ForwardReadableRange </span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=identifier>find</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardReadableRange</span><span class=special>&amp; </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>value </span><span class=special>)
</span><span class=special>{
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>value </span><span class=special>);
</span><span class=special>}
</span><span class=comment>//
// replace first value and return its index
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardReadableWriteableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_difference</span><span class=special>&lt; </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>ForwardReadableWriteableRange</span><span class=special>&amp; </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>value</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>replacement </span><span class=special>)
</span><span class=special>{
</span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_iterator</span><span class=special>&lt; </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>found </span><span class=special>= </span><span class=identifier>find</span><span class=special>( </span><span class=identifier>c</span><span class=special>, </span><span class=identifier>value </span><span class=special>);
</span><span class=keyword>if</span><span class=special>( </span><span class=identifier>found </span><span class=special>!= </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>) </span><span class=special>)
</span><span class=special>*</span><span class=identifier>found </span><span class=special>= </span><span class=identifier>replacement</span><span class=special>;
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>distance</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>found </span><span class=special>);
</span><span class=special>}
</span><span class=comment>//
// usage
//
</span><span class=keyword>const </span><span class=keyword>int </span><span class=identifier>N </span><span class=special>= </span><span class=number>5</span><span class=special>;
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt; </span><span class=identifier>my_vector</span><span class=special>;
</span><span class=keyword>int </span><span class=identifier>values</span><span class=special>[] </span><span class=special>= </span><span class=special>{ </span><span class=number>1</span><span class=special>,</span><span class=number>2</span><span class=special>,</span><span class=number>3</span><span class=special>,</span><span class=number>4</span><span class=special>,</span><span class=number>5</span><span class=special>,</span><span class=number>6</span><span class=special>,</span><span class=number>7</span><span class=special>,</span><span class=number>8</span><span class=special>,</span><span class=number>9 </span><span class=special>};
</span>
<span class=identifier>my_vector</span><span class=special>.</span><span
class=identifier>assign</span><span class=special>( </span><span class=identifier>values</span><span class=special>, </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>values </span><span class=special>) </span><span class=special>);</span>
</span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt;::</span><span class=identifier>iterator </span><span class=identifier>iterator</span><span class=special>;
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>iterator</span><span class=special>&gt; </span><span class=identifier>my_view</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>my_vector </span><span class=special>),
</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>my_vector </span><span class=special>) </span><span class=special>+ </span><span class=identifier>N </span><span class=special>);
</span><span class=keyword>char </span><span class=identifier>str_val</span><span class=special>[] </span><span class=special>= </span><span class=string>&quot;a string&quot;</span><span class=special>;
</span><span class=keyword>char</span><span class=special>* </span><span class=identifier>str </span><span class=special>= </span><span class=identifier>str_val</span><span class=special>;
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_vector</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>);
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_view</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>);
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>str</span><span class=special>, </span><span class=literal>'a'</span><span class=special>, </span><span class=literal>'b' </span><span class=special>);
</span>
<span class=comment>// prints '3', '5' and '0' </span>
</pre>
</blockquote>
By using the free-standing functions and <a
href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a>, the code automatically
works for all the types supported by this library; now and in the future.
Notice that we have to
provide two version of <code >find()</code> since we cannot forward a non-const
rvalue with reference arguments (see this article about <a href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_self" >The
Forwarding Problem</a> ).
</p>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

581
doc/mfc_atl.html Normal file
View File

@ -0,0 +1,581 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.10: http://docutils.sourceforge.net/" />
<title>Boost Range MFC/ATL Extension</title>
<meta name="author" content="Shunsuke Sogame" />
<meta name="date" content="26th of May 2006" />
<meta name="copyright" content="Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt)." />
<style type="text/css">
/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date: 2005-09-25 17:49:54 +0200 (Sun, 25 Sep 2005) $
:Revision: $Revision: 3901 $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* "! important" is used here to override other ``margin-top`` and
``margin-bottom`` styles that are later in the stylesheet or
more specific. See http://www.w3.org/TR/CSS1#the-cascade */
.first {
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin-left: 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left {
clear: left }
img.align-right {
clear: right }
img.borderless {
border: 0 }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font-family: serif ;
font-size: 100% }
pre.line-block {
font-family: serif ;
font-size: 100% }
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em ;
background-color: #eeeeee }
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid thin gray }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid thin black }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
tt.docutils {
background-color: #eeeeee }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="boost-range-mfc-atl-extension">
<h1 class="title"><img alt="Boost" src="http://www.boost.org/libs/ptr_container/doc/boost.png" /> Range MFC/ATL Extension</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Shunsuke Sogame</td></tr>
<tr><th class="docinfo-name">Contact:</th>
<td><a class="first last reference" href="mailto:mb2act&#64;yahoo.co.jp">mb2act&#64;yahoo.co.jp</a></td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>26th of May 2006</td></tr>
<tr><th class="docinfo-name">Copyright:</th>
<td>Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt</a>).</td></tr>
</tbody>
</table>
<div class="section">
<h1><a id="overview" name="overview">Overview</a></h1>
<p>Boost.Range MFC/ATL Extension provides <a class="reference" href="../index.html">Boost.Range</a> support for MFC/ATL collection and string types.</p>
<pre class="literal-block">
CTypedPtrArray&lt;CPtrArray, CList&lt;CString&gt; *&gt; myArray;
...
BOOST_FOREACH (CList&lt;CString&gt; *theList, myArray)
{
BOOST_FOREACH (CString&amp; str, *theList)
{
boost::to_upper(str);
std::sort(boost::begin(str), boost::end(str));
...
}
}
</pre>
<ul class="simple">
<li><a class="reference" href="#requirements">Requirements</a></li>
<li><a class="reference" href="#mfc-ranges">MFC Ranges</a></li>
<li><a class="reference" href="#atl-ranges">ATL Ranges</a></li>
<li><a class="reference" href="#const-ranges">const Ranges</a></li>
<li><a class="reference" href="#references">References</a></li>
</ul>
</div>
<div class="section">
<h1><a id="requirements" name="requirements">Requirements</a></h1>
<ul class="simple">
<li><a class="reference" href="http://www.boost.org/">Boost C++ Libraries Version 1.34.0</a> or later (no compilation required)</li>
<li>Visual C++ 7.1 or Visual C++ 8.0</li>
</ul>
</div>
<div class="section">
<h1><a id="mfc-ranges" name="mfc-ranges">MFC Ranges</a></h1>
<p>If the <tt class="docutils literal"><span class="pre">&lt;boost/range/mfc.hpp&gt;</span></tt> is included before or after <a class="reference" href="../index.html">Boost.Range</a> headers,
the MFC collections and strings become models of Range.
The table below lists the Traversal Category and <tt class="docutils literal"><span class="pre">range_reference</span></tt> of MFC ranges.</p>
<table border="1" class="docutils">
<colgroup>
<col width="34%" />
<col width="21%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head"><tt class="docutils literal"><span class="pre">Range</span></tt></th>
<th class="head">Traversal Category</th>
<th class="head"><tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt></th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">CArray&lt;T,A&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">T&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CList&lt;T,A&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">T&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMap&lt;K,AK,M,AM&gt;</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">Range::CPair&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CTypedPtrArray&lt;B,T*&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">T*</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CTypedPtrList&lt;B,T*&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">T*</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CTypedPtrMap&lt;B,T*,V*&gt;</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">std::pair&lt;T*,V*&gt;</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CByteArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">BYTE&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CDWordArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">DWORD&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CObArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">CObject*</span> <span class="pre">&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CPtrArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">void*</span> <span class="pre">&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CStringArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">CString&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CUIntArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">UINT&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CWordArray</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">WORD&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CObList</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">CObject*</span> <span class="pre">&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CPtrList</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">void*</span> <span class="pre">&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CStringList</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">CString&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMapPtrToWord</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">std::pair&lt;void*,WORD&gt;</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMapPtrToPtr</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">std::pair&lt;void*,void*&gt;</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMapStringToOb</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">std::pair&lt;String,CObject*&gt;</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMapStringToString</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">Range::CPair&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMapWordToOb</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">std::pair&lt;WORD,CObject*&gt;</span> <span class="pre">const</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CMapWordToPtr</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">std::pair&lt;WORD,void*&gt;</span> <span class="pre">const</span></tt></td>
</tr>
</tbody>
</table>
<p>Other <a class="reference" href="../index.html">Boost.Range</a> metafunctions are defined by the following.
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt>.
<tt class="docutils literal"><span class="pre">range_value&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">remove_reference&lt;remove_const&lt;Ref&gt;::type&gt;::type</span></tt>,
<tt class="docutils literal"><span class="pre">range_difference&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
<tt class="docutils literal"><span class="pre">range_pointer&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer&lt;remove_reference&lt;Ref&gt;::type&gt;::type</span></tt>.
As for <tt class="docutils literal"><span class="pre">const</span> <span class="pre">Range</span></tt>, see <a class="reference" href="#const-ranges">const Ranges</a>.</p>
</div>
<div class="section">
<h1><a id="atl-ranges" name="atl-ranges">ATL Ranges</a></h1>
<p>If the <tt class="docutils literal"><span class="pre">&lt;boost/range/atl.hpp&gt;</span></tt> is included before or after <a class="reference" href="../index.html">Boost.Range</a> headers,
the ATL collections and strings become models of Range.
The table below lists the Traversal Category and <tt class="docutils literal"><span class="pre">range_reference</span></tt> of ATL ranges.</p>
<table border="1" class="docutils">
<colgroup>
<col width="34%" />
<col width="21%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head"><tt class="docutils literal"><span class="pre">Range</span></tt></th>
<th class="head">Traversal Category</th>
<th class="head"><tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt></th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">CAtlArray&lt;E,ET&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">E&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CAutoPtrArray&lt;E&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">E&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CInterfaceArray&lt;I,pi&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">CComQIPtr&lt;I,pi&gt;&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CAtlList&lt;E,ET&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">E&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CAutoPtrList&lt;E&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">E&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CHeapPtrList&lt;E,A&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">E&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CInterfaceList&lt;I,pi&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">CComQIPtr&lt;I,pi&gt;&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CAtlMap&lt;K,V,KT,VT&gt;</span></tt></td>
<td>Forward</td>
<td><tt class="docutils literal"><span class="pre">Range::CPair&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CRBTree&lt;K,V,KT,VT&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">Range::CPair&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CRBMap&lt;K,V,KT,VT&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">Range::CPair&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CRBMultiMap&lt;K,V,KT,VT&gt;</span></tt></td>
<td>Bidirectional</td>
<td><tt class="docutils literal"><span class="pre">Range::CPair&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CSimpleStringT&lt;B,b&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">B&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CStringT&lt;B,ST&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">B&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CFixedStringT&lt;S,n&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">range_reference&lt;S&gt;::type</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CStringT&lt;B,ST&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">B&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CComBSTR</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">OLECHAR&amp;</span></tt></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">CSimpleArray&lt;T,TE&gt;</span></tt></td>
<td>Random Access</td>
<td><tt class="docutils literal"><span class="pre">T&amp;</span></tt></td>
</tr>
</tbody>
</table>
<p>Other <a class="reference" href="../index.html">Boost.Range</a> metafunctions are defined by the following.
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt>.
<tt class="docutils literal"><span class="pre">range_value&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">remove_reference&lt;Ref&gt;::type</span></tt>,
<tt class="docutils literal"><span class="pre">range_difference&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
<tt class="docutils literal"><span class="pre">range_pointer&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer&lt;remove_reference&lt;Ref&gt;::type&gt;::type</span></tt>.
As for <tt class="docutils literal"><span class="pre">const</span> <span class="pre">Range</span></tt>, see <a class="reference" href="#const-ranges">const Ranges</a>.</p>
</div>
<div class="section">
<h1><a id="const-ranges" name="const-ranges">const Ranges</a></h1>
<p><tt class="docutils literal"><span class="pre">range_reference&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is defined by the following algorithm.
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt>.</p>
<pre class="literal-block">
if (Range is CObArray || Range is CObList)
return CObject const * &amp;
else if (Range is CPtrArray || Range is CPtrList)
return void const * &amp;
else if (there is a type X such that X&amp; is the same as ReF)
return X const &amp;
else if (there is a type X such that X* const is the same as ReF)
return X const * const
else
return ReF
</pre>
<p>Other <a class="reference" href="../index.html">Boost.Range</a> metafunctions are defined by the following.
<tt class="docutils literal"><span class="pre">range_value&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">range_value&lt;Range&gt;::type</span></tt>,
<tt class="docutils literal"><span class="pre">range_difference&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
<tt class="docutils literal"><span class="pre">range_pointer&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer&lt;remove_reference&lt;range_reference&lt;const</span> <span class="pre">Range&gt;::type&gt;::type&gt;::type</span></tt>.</p>
</div>
<div class="section">
<h1><a id="references" name="references">References</a></h1>
<ul class="simple">
<li><a class="reference" href="../index.html">Boost.Range</a></li>
<li><a class="reference" href="http://msdn2.microsoft.com/en-us/library/942860sh.aspx">MFC Collections</a></li>
<li><a class="reference" href="http://msdn2.microsoft.com/en-US/library/15e672bd.aspx">ATL Collection Classes</a></li>
</ul>
</div>
</div>
</body>
</html>

232
doc/mfc_atl.rst Normal file
View File

@ -0,0 +1,232 @@
++++++++++++++++++++++++++++++++
|Boost| Range MFC/ATL Extension
++++++++++++++++++++++++++++++++
.. |Boost| image:: http://www.boost.org/libs/ptr_container/doc/boost.png
:Author: Shunsuke Sogame
:Contact: mb2act@yahoo.co.jp
:date: 26th of May 2006
:copyright: Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
__ http://www.boost.org/LICENSE_1_0.txt
========
Overview
========
Boost.Range MFC/ATL Extension provides `Boost.Range`_ support for MFC/ATL collection and string types.
.. parsed-literal::
CTypedPtrArray<CPtrArray, CList<CString> \*> myArray;
...
BOOST_FOREACH (CList<CString> \*theList, myArray)
{
BOOST_FOREACH (CString& str, \*theList)
{
boost::to_upper(str);
std::sort(boost::begin(str), boost::end(str));
...
}
}
* `Requirements`_
* `MFC Ranges`_
* `ATL Ranges`_
* `const Ranges`_
* `References`_
============
Requirements
============
- `Boost C++ Libraries Version 1.34.0`__ or later (no compilation required)
- Visual C++ 7.1 or Visual C++ 8.0
__ Boost_
==========
MFC Ranges
==========
If the ``<boost/range/mfc.hpp>`` is included before or after `Boost.Range`_ headers,
the MFC collections and strings become models of Range.
The table below lists the Traversal Category and ``range_reference`` of MFC ranges.
============================= ================== =======================================
``Range`` Traversal Category ``range_reference<Range>::type``
============================= ================== =======================================
``CArray<T,A>`` Random Access ``T&``
----------------------------- ------------------ ---------------------------------------
``CList<T,A>`` Bidirectional ``T&``
----------------------------- ------------------ ---------------------------------------
``CMap<K,AK,M,AM>`` Forward ``Range::CPair&``
----------------------------- ------------------ ---------------------------------------
``CTypedPtrArray<B,T*>`` Random Access ``T* const``
----------------------------- ------------------ ---------------------------------------
``CTypedPtrList<B,T*>`` Bidirectional ``T* const``
----------------------------- ------------------ ---------------------------------------
``CTypedPtrMap<B,T*,V*>`` Forward ``std::pair<T*,V*> const``
----------------------------- ------------------ ---------------------------------------
``CByteArray`` Random Access ``BYTE&``
----------------------------- ------------------ ---------------------------------------
``CDWordArray`` Random Access ``DWORD&``
----------------------------- ------------------ ---------------------------------------
``CObArray`` Random Access ``CObject* &``
----------------------------- ------------------ ---------------------------------------
``CPtrArray`` Random Access ``void* &``
----------------------------- ------------------ ---------------------------------------
``CStringArray`` Random Access ``CString&``
----------------------------- ------------------ ---------------------------------------
``CUIntArray`` Random Access ``UINT&``
----------------------------- ------------------ ---------------------------------------
``CWordArray`` Random Access ``WORD&``
----------------------------- ------------------ ---------------------------------------
``CObList`` Bidirectional ``CObject* &``
----------------------------- ------------------ ---------------------------------------
``CPtrList`` Bidirectional ``void* &``
----------------------------- ------------------ ---------------------------------------
``CStringList`` Bidirectional ``CString&``
----------------------------- ------------------ ---------------------------------------
``CMapPtrToWord`` Forward ``std::pair<void*,WORD> const``
----------------------------- ------------------ ---------------------------------------
``CMapPtrToPtr`` Forward ``std::pair<void*,void*> const``
----------------------------- ------------------ ---------------------------------------
``CMapStringToOb`` Forward ``std::pair<String,CObject*> const``
----------------------------- ------------------ ---------------------------------------
``CMapStringToString`` Forward ``Range::CPair&``
----------------------------- ------------------ ---------------------------------------
``CMapWordToOb`` Forward ``std::pair<WORD,CObject*> const``
----------------------------- ------------------ ---------------------------------------
``CMapWordToPtr`` Forward ``std::pair<WORD,void*> const``
============================= ================== =======================================
Other `Boost.Range`_ metafunctions are defined by the following.
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
``range_value<Range>::type`` is the same as ``remove_reference<remove_const<Ref>::type>::type``,
``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
As for ``const Range``, see `const Ranges`_.
==========
ATL Ranges
==========
If the ``<boost/range/atl.hpp>`` is included before or after `Boost.Range`_ headers,
the ATL collections and strings become models of Range.
The table below lists the Traversal Category and ``range_reference`` of ATL ranges.
============================= ================== =======================================
``Range`` Traversal Category ``range_reference<Range>::type``
============================= ================== =======================================
``CAtlArray<E,ET>`` Random Access ``E&``
----------------------------- ------------------ ---------------------------------------
``CAutoPtrArray<E>`` Random Access ``E&``
----------------------------- ------------------ ---------------------------------------
``CInterfaceArray<I,pi>`` Random Access ``CComQIPtr<I,pi>&``
----------------------------- ------------------ ---------------------------------------
``CAtlList<E,ET>`` Bidirectional ``E&``
----------------------------- ------------------ ---------------------------------------
``CAutoPtrList<E>`` Bidirectional ``E&``
----------------------------- ------------------ ---------------------------------------
``CHeapPtrList<E,A>`` Bidirectional ``E&``
----------------------------- ------------------ ---------------------------------------
``CInterfaceList<I,pi>`` Bidirectional ``CComQIPtr<I,pi>&``
----------------------------- ------------------ ---------------------------------------
``CAtlMap<K,V,KT,VT>`` Forward ``Range::CPair&``
----------------------------- ------------------ ---------------------------------------
``CRBTree<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
----------------------------- ------------------ ---------------------------------------
``CRBMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
----------------------------- ------------------ ---------------------------------------
``CRBMultiMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
----------------------------- ------------------ ---------------------------------------
``CSimpleStringT<B,b>`` Random Access ``B&``
----------------------------- ------------------ ---------------------------------------
``CStringT<B,ST>`` Random Access ``B&``
----------------------------- ------------------ ---------------------------------------
``CFixedStringT<S,n>`` Random Access ``range_reference<S>::type``
----------------------------- ------------------ ---------------------------------------
``CStringT<B,ST>`` Random Access ``B&``
----------------------------- ------------------ ---------------------------------------
``CComBSTR`` Random Access ``OLECHAR&``
----------------------------- ------------------ ---------------------------------------
``CSimpleArray<T,TE>`` Random Access ``T&``
============================= ================== =======================================
Other `Boost.Range`_ metafunctions are defined by the following.
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
``range_value<Range>::type`` is the same as ``remove_reference<Ref>::type``,
``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
As for ``const Range``, see `const Ranges`_.
============
const Ranges
============
``range_reference<const Range>::type`` is defined by the following algorithm.
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
.. parsed-literal::
if (Range is CObArray || Range is CObList)
return CObject const \* &
else if (Range is CPtrArray || Range is CPtrList)
return void const \* &
else if (there is a type X such that X& is the same as ReF)
return X const &
else if (there is a type X such that X* const is the same as ReF)
return X const \* const
else
return ReF
Other `Boost.Range`_ metafunctions are defined by the following.
``range_value<const Range>::type`` is the same as ``range_value<Range>::type``,
``range_difference<const Range>::type`` is the same as ``std::ptrdiff_t``, and
``range_pointer<const Range>::type`` is the same as ``add_pointer<remove_reference<range_reference<const Range>::type>::type>::type``.
==========
References
==========
- `Boost.Range`_
- `MFC Collections`__
- `ATL Collection Classes`__
__ http://msdn2.microsoft.com/en-us/library/942860sh.aspx
__ http://msdn2.microsoft.com/en-US/library/15e672bd.aspx
.. _Boost C++ Libraries: http://www.boost.org/
.. _Boost: `Boost C++ Libraries`_
.. _Boost.Range: ../index.html
.. _forward: range.html#forward_range
.. _bidirectional: range.html#forward_range
.. _random access: range.html#random_access_range

104
doc/portability.html Normal file
View File

@ -0,0 +1,104 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Portability </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range</h1></td>
</tr>
</table>
<h2>Portability</h2><a name="Portability" ></a>
<p>
A huge effort has been made to port the library to as many compilers as possible.
<!-- The results of the test-suites can be found <a
href="http://boost.sourceforge.net/regression-logs/developer/range.html">here</a
>.--> </p>
<p>
Full support for built-in arrays require that the compiler supports class
template partial specialization. For non-conforming compilers there might be a
chance that it works anyway thanks to workarounds in the type traits library.
</p>
<pp>
Visual C++ 6/7.0 has a limited support for arrays: as long as the arrays are
of built-in type it should work.
</p>
<p >
Notice also that some compilers cannot do function template ordering properly.
In that case one must rely on <a
href="boost_range.html#range_iterator"><code >range_iterator</code></a>
and a single function definition instead of overloaded versions for const and
non-const arguments.
So if one cares about old compilers, one should not pass rvalues to the
functions.
</p>
<p>
For maximum portability you should follow these guidelines:
<ol>
<li>
do not use built-in arrays,
<li>
do not pass rvalues to <a
href="boost_range.html#begin"><code>begin()</code></a>, <a
href="boost_range.html#end"><code>end()</code></a> and <a href="utility_class.html#iter_range">
<code>iterator_range</code></a> Range constructors and assignment operators,
<li>
use <a href="boost_range.html#const_begin"><code>const_begin()</code></a>
and <a href="boost_range.html#const_begin"><code>const_end()</code></a>
whenever your code by intention is read-only; this will also solve
most rvalue problems,
<li>
do not rely on ADL:
<ul>
<li>
if you overload functions, include that header <i>before</i> the headers in this
library,
<li>
put all overloads in namespace <code>boost</code>.
</ul>
</ol>
</p>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

377
doc/range.html Normal file
View File

@ -0,0 +1,377 @@
<HTML>
<!--
-- Copyright (c) Jeremy Siek 2000
--
-- Permission to use, copy, modify, distribute and sell this software
-- and its documentation for any purpose is hereby granted without fee,
-- provided that the above copyright notice appears in all copies and
-- that both that copyright notice and this permission notice appear
-- in supporting documentation. Silicon Graphics makes no
-- representations about the suitability of this software for any
-- purpose. It is provided "as is" without express or implied warranty.
-->
<Head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<Title>Range Concepts</Title>
<link rel="stylesheet" href="style.css" type="text/css">
</HEAD>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range </h1></td>
</tr>
</table>
<h2>Range concepts </h2>
<ul>
<li>
<a href="#overview">Overview</a>
<li>
<a href="#single_pass_range">Single Pass Range</a>
<li>
<a href="#forward_range">Forward Range</a>
<li>
<a href="#bidirectional_range">Bidirectional Range</a>
<li>
<a href="#random_access_range">Random Access Range</a>
<li>
<a href="#concept_checking">Concept Checking</a>
</ul>
<a name="overview"></a>
<hr>
<h3>Overview</h3>
<p>
A Range is a <i>concept</i> similar to the STL <a
href="http://www.sgi.com/Technology/STL/Container.html">Container</a> concept. A
Range provides iterators for accessing a half-open range
<code>[first,one_past_last)</code> of elements and provides
information about the number of elements in the Range. However, a Range has
<i>much</i> fewer requirements than a Container.
</p>
<p>
The motivation for the Range concept is
that there are many useful Container-like types that do not meet the full
requirements of Container, and many algorithms that can be written with this
reduced set of requirements. In particular, a Range does not necessarily
<ul>
<li>
own the elements that can be accessed through it,
<li>
have copy semantics,
<!--
<li>
require that the associated reference type is a real C++ reference.
-->
</ul>
Because of the second requirement, a Range object must be passed by
(const or non-const) reference in generic code.
</p>
<p>
The operations that can be performed on a Range is dependent on the
<a href="../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal">traversal
category</a> of the underlying iterator type. Therefore
the range concepts are named to reflect which traversal category their
iterators support. See also <a href="style.html">terminology and style
guidelines.</a> for more information about naming of ranges.</p>
<p> The concepts described below specifies associated types as
<a href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a> and all
functions as free-standing functions to allow for a layer of indirection. </p>
<!--<p><i>Notice that these metafunctions must be defined in namespace </i>
<code>boost</code></p>-->
<hr>
<a name="single_pass_range">
<H2>Single Pass Range</H2>
<h3>Notation</h3>
<Table>
<TR>
<TD VAlign="top"><code>X</code></TD>
<TD VAlign="top">A type that is a model of Single Pass Range.</TD>
</TR>
<TR>
<TD VAlign="top"><code>a</code></TD>
<TD VAlign="top">Object of type <code>X</code>.</TD>
</TR>
</table>
<h3>Description</h3>
<p>
A range X where <code>boost::range_iterator&lt;X>::type</code> is a model of <a
href="../../iterator/doc/new-iter-concepts.html#single-pass-iterators-lib-single-pass-iterators">
Single Pass Iterator</a>
</p>
<h3>Associated types</h3>
<table border="1" cellpadding="5">
<TR>
<TD VAlign="top">Iterator type</TD>
<TD VAlign="top"><code>boost::range_iterator&lt;X>::type</code></TD>
<TD VAlign="top">The type of iterator used to iterate through a Range's elements.
The iterator's value type is expected to be the Range's value type. A
conversion from the iterator type to the const iterator type must exist.
</TR>
<TR>
<TD VAlign="top">Const iterator type</TD>
<TD VAlign="top"><code>boost::range_iterator&lt;const X>::type</code></TD>
<TD VAlign="top">A type of iterator that may be used to examine, but not to
modify, a Range's elements.</TD>
</TR>
<!--
<TR>
<TD VAlign="top">Reference type</TD>
<TD VAlign="top"><code>reference_of&lt;X>::type</code></TD>
<TD VAlign="top">A type that behaves like a reference to the Range's value type. <a href="#1">[1]</a></TD>
</TR>
-->
</table>
<h3>Valid expressions</h3>
The following expressions must be valid.
<p>
<Table border="1" cellpadding="5">
<TR>
<TH>Name</TH>
<TH>Expression</TH>
<TH>Return type</TH>
</TR>
<TR>
<TD VAlign="top">Beginning of range</TD>
<TD VAlign="top"><code>boost::begin(a)</code></TD>
<TD VAlign="top"><code>boost::range_iterator&lt;X>::type</code> if
<code>a</code> is mutable, <code>boost::range_iterator&lt;const X>::type</code>
otherwise</TD> </TR>
<TR>
<TD VAlign="top">End of range</TD>
<TD VAlign="top"><code>boost::end(a)</code></TD>
<TD VAlign="top"><code>boost::range_iterator&lt;X>::type</code> if
<code>a</code> is mutable, <code>boost::range_iterator&lt;const X>::type</code>
otherwise</TD>
</TR>
</table>
<h3>Expression semantics</h3>
<Table border>
<TR>
<TH>Expression</TH>
<TH>Semantics</TH>
<TH>Postcondition</TH>
</TR>
<TR>
<TD VAlign="top"><code>boost::begin(a)</code></TD>
<TD VAlign="top">Returns an iterator pointing to the first element in the Range.</TD>
<TD VAlign="top"><code>boost::begin(a)</code> is either dereferenceable or past-the-end.
It is past-the-end if and only if <code>boost::distance(a) == 0</code>.</TD>
</TR>
<TR>
<TD VAlign="top"><code>boost::end(a)</code></TD>
<TD VAlign="top">Returns an iterator pointing one past the last element in the
Range.</TD>
<TD VAlign="top"><code>boost::end(a)</code> is past-the-end.</TD>
</TR>
</table>
<h3>Complexity guarantees</h3>
<code>boost::end(a)</code> is at most amortized linear time, <code>boost::begin(a)</code> is
amortized constant time. For most practical
purposes, one can expect both to be amortized constant time.
<h3>Invariants</h3>
<Table border>
<TR>
<TD VAlign="top">Valid range</TD>
<TD VAlign="top">For any Range <code>a</code>, <code>[boost::begin(a),boost::end(a))</code> is
a valid range, that is, <code>boost::end(a)</code> is reachable from <code>boost::begin(a)</code>
in a finite number of increments.</TD>
</TR>
<TR>
<TD VAlign="top">Completeness</TD>
<TD VAlign="top">An algorithm that iterates through the range <code>[boost::begin(a),boost::end(a))</code>
will pass through every element of <code>a</code>.</TD>
</tr>
</table>
<h3>See also</h3>
<p><a
href="boost_range.html#minimal_interface">Extending the library for UDTs </a></p>
<p> <a href="boost_range.html#boost::rang_difference">Implementation of
metafunctions </a></p>
<p> <a href="boost_range.html#begin">Implementation of
functions </a></p>
<p>
<A href="http://www.sgi.com/Technology/STL/Container.html">Container</A>
</p>
<hr>
<a name=forward_range><h2>Forward Range</h2>
<h3>Notation</h3>
<Table>
<TR>
<TD VAlign="top"><code>X</code></TD>
<TD VAlign="top">A type that is a model of Forward Range.</TD>
</TR>
<TR>
<TD VAlign="top"><code>a</code></TD>
<TD VAlign="top">Object of type <code>X</code>.</TD>
</TR>
</table>
<h3>Description</h3>
<p>
A range <code>X</code> where <code>boost::range_iterator&lt;X>::type</code> is a model
of <a
href="../../iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">Forward Traversal Iterator</a>
</p>
<h3>Refinement of</h3> <a href="#single_pass_range">Single Pass
Range</a>
</p>
<hr>
<a name="bidirectional_range"><h2>Bidirectional Range</h2>
<h3>Notation</h3>
<Table>
<TR>
<TD VAlign="top"><code>X</code></TD>
<TD VAlign="top">A type that is a model of Bidirectional Range.</TD>
</TR>
<TR>
<TD VAlign="top"><code>a</code></TD>
<TD VAlign="top">Object of type <code>X</code>.</TD>
</TR>
</table>
<h3>Description</h3> This concept provides access to iterators that traverse in
both directions (forward and reverse). The
<code>boost::range_iterator&lt;X>::type</code> iterator must meet all of the requirements
of <a
href="../../iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterator
s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.</a>
<h3>Refinement of</h3> <a href="#forward_range">Forward Range</a>
</p>
<hr>
<a name=random_access_range><h2>Random Access Range</h2> <h3>Description</h3>
<p>
A range <code>X</code> where <code>boost::range_iterator&lt;X>::type</code> is a model
of <a
href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterators
-lib-random-access-traversal-iterators">Random Access Traversal Iterator</a>
</p>
<h3>Refinement of</h3>
<p>
<a href="#bidirectional_range">Bidirectional Range</a>
</p>
<hr>
<a name=concept_checking><h2>Concept Checking</h2>
Each of the range concepts has a corresponding concept checking
class in the file <code><boost/range/concepts.hpp></codE>. These classes may be
used in conjunction with the <a
href="../../concept_check/concept_check.htm">Boost Concept
Check</a> library to insure that the type of a template parameter
is compatible with a range concept. If not, a meaningful compile
time error is generated. Checks are provided for the range
concepts related to iterator traversal categories. For example,
the following line checks that the type <code>T</code> models the
<a href="#forward_range">ForwardRange</a> concept.
<pre>
function_requires&lt;ForwardRangeConcept&lt;T&gt; &gt;();
</pre>
An additional concept check is required for the value access
property of the range based on the range's iterator type. For
example to check for a ForwardReadableRange, the following code is
required.
<pre>
function_requires&lt;ForwardRangeConcept&lt;T&gt; &gt;();
function_requires&lt;
ReadableIteratorConcept&lt;
typename range_iterator&lt;T&gt;::type
&gt;
&gt;();
</pre>
The following range concept checking classes are provided.
<ul>
<li>
Class <code>SinglePassRangeConcept</code> checks for <a
href="#single_pass_range">Single Pass Range</a>
<li>
Class <code>ForwardRangeConcept</code> checks for <a
href="#forward_range">Forward Range</a>
<li>
Class <code>BidirectionalRangeConcept</code> checks for <a
href="#bidirectional_range">Bidirectional Range</a>
<li>
Class <code>RandomAccessRangeConcept</code> checks for <a
href="#random_access_range">Random Access Range</a>
</ul>
<h3>See also</h3>
<p> <a href="style.html">Range Terminology and style guidelines</a></p>
<p> <a href="../../iterator/doc/iterator_concepts.html">Iterator Concepts</a></p>
<p> <a href="../../concept_check/concept_check.htm">Boost Concept Check library</a></p>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</BODY>
</HTML>

42
doc/style.css Normal file
View File

@ -0,0 +1,42 @@
/*
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
*/
pre{
BORDER-RIGHT: gray 1pt solid;
PADDING-RIGHT: 2pt;
BORDER-TOP: gray 1pt solid;
DISPLAY: block;
PADDING-LEFT: 2pt;
PADDING-BOTTOM: 2pt;
BORDER-LEFT: gray 1pt solid;
MARGIN-RIGHT: 32pt;
PADDING-TOP: 2pt;
BORDER-BOTTOM: gray 1pt solid;
FONT-FAMILY: "Courier New", Courier, mono;
background-color: #EEEEEE;
}
.keyword{color: #0000FF;}
.identifier{}
.comment{font-style: italic; color: #008000;}
.special{color: #800040;}
.preprocessor{color: #3F007F;}
.string{font-style: italic; color: #666666;}
.literal{font-style: italic; color: #666666;}
table
{
cellpadding: 5px;
border: 2px;
}

132
doc/style.html Normal file
View File

@ -0,0 +1,132 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Terminology and Style Guidelines </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range </h1></td>
</tr>
</table>
<h2>Terminology and style guidelines </h2>
<p>
The use of a consistent terminology is as important for <a href="range.html">Range</a>s
and range-based algorithms as it is for iterators and iterator-based algorithms.
If a conventional set of names are adopted, we can avoid misunderstandings and
write generic function prototypes that are <i>self-documenting</i>.
</p>
<p>
Since ranges are characterized by a specific underlying iterator type, we get a
type of range for each type of iterator. Hence we can speak of the following
types of ranges:
<ul>
<li>
<i>Value access</i> category:
<ul>
<li>
Readable Range
<li>
Writeable Range
<li>
Swappable Range
<li>
Lvalue Range
</ul>
<li>
<i>Traversal</i> category:
<ul>
<li>
<a href="range.html#single_pass_range">Single Pass Range</a>
<li>
<a href="range.html#forward_range">Forward Range</a>
<li>
<a href="range.html#bidirectional_range">Bidirectional Range</a> <li>
<a href="range.html#random_access_range">Random Access Range</a> </ul>
</ul>
Notice how we have used the categories from the <a href="../../iterator/doc/new-iter-concepts.html">new
style iterators</a>.
<p>
Notice that an iterator (and therefore an range) has one <i>traversal</i>
property and one or more properties from the <i>value access</i> category. So in
reality we will mostly talk about mixtures such as
<ul>
<li>
Random Access Readable Writeable Range
<li>
Forward Lvalue Range
</ul>
By convention, we should always specify the <i>traversal</i> property first as
done above. This seems reasonable since there will only be one <i>traversal</i>
property, but perhaps many <i>value access</i> properties.
</p>
<p>
It might, however, be reasonable to specify only one category if the other
category does not matter. For example, the <a
href="utility_class.html#iter_range">iterator_range</a> can be constructed from
a Forward Range. This means that we do not care about what <i>value access</i>
properties the Range has. Similarly, a Readable Range will be one that has the
lowest possible <i>traversal</i> property (Single Pass).
</p>
<p>
As another example, consider how we specify the interface of <code>std::sort()</code>.
Algorithms are usually more cumbersome to specify the interface of since both <i>traversal</i>
and <i>value access</i> properties must be exactly defined. The iterator-based
version looks like this:
<pre>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>RandomAccessTraversalReadableWritableIterator </span><span class=special>&gt;
</span><span class=keyword>void </span><span class=identifier>sort</span><span class=special>( </span><span class=identifier>RandomAccessTraversalReadableWritableIterator </span><span class=identifier>first</span><span class=special>,
</span><span class=identifier>RandomAccessTraversalReadableWritableIterator </span><span class=identifier>last </span><span class=special>);</span>
</pre>
For ranges the interface becomes
<pre>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>RandomAccessReadableWritableRange </span><span class=special>&gt;
</span><span class=keyword>void </span><span class=identifier>sort</span><span class=special>( </span><span class=identifier>RandomAccessReadableWritableRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);</span>
</pre>
</p>
<p>
</p>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

381
doc/utility_class.html Normal file
View File

@ -0,0 +1,381 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Utilities </title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../../boost.png" border="0" ></td>
<td ><h1 align="center">Boost.Range</h1></td>
</tr>
</table>
<h2>Utilities</h2>
<p>
Having an abstraction that encapsulates a pair of iterators is very useful. The
standard library uses <code>std::pair</code> in some circumstances, but that
class is cumbersome to use because we need to specify two template arguments,
and for all range algorithm purposes we must enforce the two template arguments
to be the same. Moreover, <code>std::pair&lt;iterator,iterator></code> is hardly
self-documenting whereas more domain specific class names are. Therefore these
two classes are provided:
<ul>
<li>
Class <a href="#iter_range"><code>iterator_range</code></a>
<li>
Class <a href="#sub_range"><code>sub_range</code></a>
</ul>
</ul>
The <code>iterator_range</code> class is templated on a <a
href="../../iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">Forward
Traversal Iterator</a> and should be used whenever fairly general code is needed.
The <code>sub_range</code> class is templated on a <a
href="range.html#forward_range">Forward Range</a> and it is less general,
but a bit easier to use since its template
argument is easier to specify. The biggest difference is, however, that a
<code>sub_range</code> can propagate constness because it knows what a
corresponding <code>const_iterator</code> is. </p>
<p>
Both classes can be used as ranges since they implement the <a
href="boost_range.html#minimal_interface">minimal interface</a>
required for this to work automatically.
</p>
<hr>
<a name=iter_range></a> <h1>Class <code>iterator_range</code></h1>
<p>
The intention of the <code>iterator_range</code> class is to encapsulate two
iterators so they fulfill the <a
href="range.html#forward_range">Forward Range</a> concept. A few other
functions are also provided for convenience.
</p>
<p>
If the template argument is not a model of Forward Traversal Iterator, one can
still use a subset of the interface. In particular, <code>size()</code> requires
Random Access Iterators whereas <code>empty()</code> only requires Single
Pass Iterators.
</p>
<p>
Recall that many default constructed iterators
are <i>singular</i> and hence can only be assigned, but not compared or
incremented or anything. Likewise, if one creates a default constructed
<code>iterator_range</code>, then one have to be careful about not doing
anything besides copying. </p>
<h3>Synopsis</h3>
<pre>
<span class=keyword>namespace </span><span class=identifier>boost</span>
<span class=special>{
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator </span><span class=special>&gt;
</span><span class=keyword>class </span><span class=identifier>iterator_range
</span><span class=special>{
</span><span class=keyword>public</span><span class=special>: </span><span class=comment>// Forward Range types
</span><span class=keyword>typedef </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>iterator</span><span class=special>;
</span><span class=keyword>typedef </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>const_iterator</span><span class=special>;</span>
<span class=keyword>typedef </span><span class=identifier>iterator_difference</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>difference_type</span><span class=special>;</span>
</span><span class=keyword>public</span><span class=special>: </span><span class=comment>// construction, assignment
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator2 </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>( </span><span class=identifier>ForwardTraversalIterator2 </span><span class=identifier>Begin</span><span class=special>, </span><span class=identifier>ForwardTraversalIterator2 </span><span class=identifier>End </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>( </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>=( </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>=( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>public</span><span class=special>: </span><span class=comment>// Forward Range functions
</span><span class=identifier>iterator </span><span class=identifier>begin</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
</span><span class=identifier>iterator </span><span class=identifier>end</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
</span><span class=identifier>difference_type </span><span class=identifier>size</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
</span><span class=keyword>bool </span><span class=identifier>empty</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
</span><span class=keyword>public</span><span class=special>: </span><span class=comment>// convenience
</span><span class=keyword>operator </span><a href="#unspecified_bool"><span class=identifier>unspecified_bool_type</span></a><span class=special>() </span><span class=keyword>const</span><span class=special>;
</span> <span class=keyword>bool</span> <span
class=identifier><a href="#equal">equal</a></span><span
class=special>( </span><span class=keyword>const</span> <span class=identifier>iterator_range</span><span class=special>& ) </span><span
class=keyword>const;</span>
<span class=identifier>reference </span><span class=identifier>front</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>reference </span><span class=identifier>back</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>iterator_range</span><span class=special>&amp;</span> <span class=identifier>advance_begin</span><span class=special>(</span> <span class=identifier>difference_type</span> <span class=identifier>n</span> <span class=special>);</span>
<span class=identifier>iterator_range</span><span class=special>&amp;</span> <span class=identifier>advance_end</span><span class=special>(</span> <span class=identifier>difference_type</span> <span class=identifier>n</span> <span class=special>);</span>
<span class=comment>// for Random Access Range only: </span>
<span class=identifier>reference </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>difference_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>value_type</span> <span class=keyword>operator</span><span class=special>()( </span><span class=identifier>difference_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
</span><span class=special>};
</span><span class=comment>// stream output
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>Traits </span><span class=special>&gt;
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>basic_ostream</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>Traits</span><span class=special>&gt;&amp;
</span><span class=keyword>operator</span><span class=special>&lt;&lt;( </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>basic_ostream</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>Traits</span><span class=special>&gt;&amp; </span><span class=identifier>Os</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=comment>// <a href="#comparison">comparison</a>
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator2 </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>==( </span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator2</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>==( </span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>==( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator2 </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>!=( </span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator2</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>!=( </span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>!=( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator2 </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>&lt;( </span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator2</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>&lt;( </span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>bool </span><span class=keyword>operator</span><span class=special>&lt;( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>l</span><span class=special>,
</span><span class=keyword>const </span><span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>ForwardTraversalIterator</span><span class=special>&gt;&amp; </span><span class=identifier>r </span><span class=special>);</span>
</span><span class=comment>// external construction
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>&lt; </span><span class=identifier>ForwardTraversalIterator </span><span class=special>&gt;
</span><span class=identifier>make_iterator_range</span><span class=special>( </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>Begin</span><span class=special>,
</span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>End </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>&lt; </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>ForwardRange</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=special>&gt;
</span><span class=identifier>make_iterator_range</span><span class=special>( </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>iterator_range</span><span class=special>&lt; </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=special>&gt;
</span><span class=identifier>make_iterator_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>Range </span><span class=special>&gt;</span>
<span class=identifier>iterator_range</span><span class=special>&lt; </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>Range</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=special>&gt;</span>
<span class=identifier><a href="#make_iterator_range">make_iterator_range</a></span><span class=special>(</span><span class=identifier> Range</span><span class=special>&amp; </span><span class=identifier>r</span><span class=special>,
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special>&lt;</span><span class=identifier>Range</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>advance_begin</span><span class=special>,
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special>&lt;</span><span class=identifier>Range</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>advance_end </span><span class=special>);
</span>
<span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>Range </span><span class=special>&gt;</span>
<span class=identifier>iterator_range</span><span class=special>&lt; </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>Range</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=special>&gt;</span>
<span class=identifier>make_iterator_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>Range</span><span class=special>&amp; </span><span class=identifier>r</span><span class=special>,
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special>&lt;</span><span class=identifier>Range</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>advance_begin</span><span class=special>,
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special>&lt;</span><span class=identifier>Range</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>advance_end </span><span class=special>);</span>
</span><span class=comment>// convenience
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>Sequence</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=identifier>Sequence </span><a href="#copy_range"><span
class=identifier>copy_range</span></a><span class=special>( </span><span
class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
<span class=special>} </span><span class=comment>// namespace 'boost'</span>
</pre>
<p>
If an instance of
<code>iterator_range</code> is constructed by a client with two iterators, the
client must ensure that the two iterators delimit a valid closed-open range
<code>[begin,end)</code>.
</p>
<p>
It is worth noticing that the templated constructors and assignment operators
allow conversion from <code>iterator_range&lt;iterator></code> to
<code>iterator_range&lt;const_iterator></code>. Similarly, since the comparison
operators have two template arguments, we can compare ranges whenever the
iterators are comparable; for example when we are dealing with const and
non-const iterators from the same container. </p>
<h3>Details member functions</h3>
<p>
<a name="unspecified_bool"></a>
<code>operator unspecified_bool_type() const; </code>
<blockquote>
<i>Returns</i> <code>!empty();</code>
</blockquote>
</p>
<p>
<a name="equal"></a>
<code>bool equal( iterator_range& r ) const;</code>
<blockquote>
<i>Returns</i> <code>begin() == r.begin() && end() == r.end();</code>
</blockquote>
</p>
<h3>Details functions</h3>
<p>
<a name="comparison"></a>
<code>bool operator==( const ForwardRange1& l, const ForwardRange2& r );</code>
<blockquote>
<i>Returns</i> <code>size(l) != size(r) ? false : std::equal( begin(l), end(l), begin(r) );</code> </blockquote> </p>
<code>bool operator!=( const ForwardRange1& l, const ForwardRange2& r );</code>
<blockquote>
<i>Returns</i> <code>!( l == r );</code>
</blockquote>
<code>bool operator<( const ForwardRange1& l, const ForwardRange2& r );</code>
<blockquote>
<i>Returns</i> <code>std::lexicographical_compare( begin(l), end(l), begin(r), end(r) );</code> </blockquote>
<p>
<a name="make_iterator_range"></a>
<pre>
iterator_range make_iterator_range( Range& r,
typename range_difference&lt;Range>::type advance_begin,
typename range_difference&lt;Range>::type advance_end );
</pre>
<blockquote>
<i>Effects</i>:
<pre>
iterator new_begin = begin( r ),
iterator new_end = end( r );
std::advance( new_begin, advance_begin );
std::advance( new_end, advance_end );
return make_iterator_range( new_begin, new_end );
</pre>
</blockquote>
<p>
<a name="copy_range"></a>
<code>Sequence copy_range( const ForwardRange& r );</code>
<blockquote>
<i>Returns</i> <code>Sequence( begin(r), end(r) );</code>
</blockquote>
</p>
<hr> <a name=sub_range></a>
<h1>Class <code>sub_range</code></h1>
The <code>sub_range</code> class inherits all its functionality
from the <a href="#iter_range"><code>iterator_range</code></a> class.
The <code>sub_range</code> class is often easier to use because
one must specify the <a href="range.html#forward_range">Forward Range</a>
template argument instead of an iterator. Moreover, the <code>sub_range</code>
class can propagate constness since it knows what a corresponding
<code>const_iterator</code> is.
<h3>Synopsis</h3>
<pre>
<span class=keyword>namespace </span><span class=identifier>boost</span>
<span class=special>{
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>&gt;
</span><span class=keyword>class </span><span class=identifier>sub_range </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>iterator_range</span><span class=special>&lt; </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>ForwardRange</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=special>&gt;
</span><span class=special>{
</span><span class=keyword>public</span><span class=special>: </span>
<span class=keyword>typedef </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>ForwardRange</span><spanclass=special>&gt;::</span><span class=identifier>type </span><span class=identifier>iterator</span><span class=special>;</span>
<span class=keyword>typedef </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>const_iterator</span><span class=special>;</span>
<span class=keyword>typedef </span><span class=keyword>typename </span><span class=identifier>iterator_difference</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>&gt;::</span><span class=identifier>type </span><span class=identifier>difference_type</span><span class=special>;</span>
<span class=keyword>public</span><span class=special>: </span><span class=comment>// construction, assignment
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardTraversalIterator </span><span class=special>&gt;
</span><span class=identifier>sub_range</span><span class=special>( </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>Begin</span><span class=special>, </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>End </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange2 </span><span class=special>&gt;
</span><span class=identifier>sub_range</span><span class=special>( </span><span class=identifier>ForwardRange2</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange2 </span><span class=special>&gt;
</span><span class=identifier>sub_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardRange2</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange2 </span><span class=special>&gt;
</span><span class=identifier>sub_range</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>=( </span><span class=identifier>ForwardRange2</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>ForwardRange2 </span><span class=special>&gt;
</span><span class=identifier>sub_range</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>=( </span><span class=keyword>const </span><span class=identifier>ForwardRange2</span><span class=special>&amp; </span><span class=identifier>r </span><span class=special>);
</span>
<span class=keyword>public</span><span class=special>: </span><span class=comment>// Forward Range functions
</span><span class=identifier>iterator </span><span class=identifier>begin</span><span class=special>();
</span><span class=identifier>const_iterator </span><span class=identifier>begin</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
</span><span class=identifier>iterator </span><span class=identifier>end</span><span class=special>();
</span><span class=identifier>const_iterator </span><span class=identifier>end</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=keyword>public</span><span class=special>: </span><span class=comment>// convenience
</span> <span class=identifier>value_type</span><span class=special>&amp; </span><span class=identifier>front</span><span class=special>();</span>
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>&amp; </span><span class=identifier>front</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>value_type</span><span class=special>&amp; </span><span class=identifier>back</span><span class=special>();</span>
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>&amp; </span><span class=identifier>back</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=comment>// for Random Access Range only: </span>
<span class=identifier>value_type</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>difference_type </span><span class=identifier>at </span><span class=special>);</span>
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>difference_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
<span class=keyword>public</span><span class=special>:
</span><span class=comment>// rest of interface inherited from <a href="#iter_range"><code>iterator_range</code></a>
</span><span class=special>};
</span>
<span class=special>} </span><span class=comment>// namespace 'boost'</span>
</pre>
<p>
The class should be trivial to use as seen below.
Imagine that we have an algorithm that searches for a sub-string in a string.
The
result is an <code>iterator_range</code>, that delimits the match. We need to
store the result
from this algorithm. Here is an example of how we can do it with and without
<code>sub_range</code>
<pre>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>str</span><span class=special>(</span><span class=string>&quot;hello&quot;</span><span class=special>);</span>
<span class=identifier>iterator_range</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>::</span><span class=identifier>iterator</span><span class=special>&gt;</span> <span class=identifier>ir</span> <span class=special>=</span> <span class=identifier>find_first</span><span class=special>(</span> <span class=identifier>str</span><span class=special>,</span> <span class=identifier>as_literal</span><span class=special>(</span><span class=string>&quot;ll&quot;</span><span class=special>)</span> <span class=special>);</span>
<span class=identifier>sub_range</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>sub</span> <span class=special>=</span> <span class=identifier>find_first</span><span class=special>(</span> <span class=identifier>str</span><span class=special>,</span> <span class=identifier>as_literal</span><span class=special>(</span><span class=string>&quot;ll&quot;</span><span class=special>)</span> <span class=special>);</span>
</pre>
</p>
<hr>
<p>
&copy; <a name="Copyright" id="Copyright">Copyright</a> Thorsten Ottosen 2008.
</p>
<p>
Distributed under 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">www.boost.org/LICENSE_1_0.txt</a>)
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

18
include/boost/range.hpp Executable file → Normal file
View File

@ -8,16 +8,26 @@
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_HPP
#define BOOST_RANGE_HPP
#ifndef BOOST_RANGE_HPP_27_07_04
#define BOOST_RANGE_HPP_27_07_04
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/functions.hpp>
#include <boost/range/types.hpp>
#if _MSC_VER == 1300 // experiment
#include <boost/range/detail/collection_traits.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/sub_range.hpp>
#else
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/sub_range.hpp>
#endif // _MSC_VER == 1300 // experiment
#endif

View File

@ -0,0 +1,45 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_AS_ARRAY_HPP
#define BOOST_RANGE_AS_ARRAY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/iterator_range.hpp>
#include <boost/range/detail/str_types.hpp>
namespace boost
{
template< class R >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<R>::type >
as_array( R& r )
{
return boost::make_iterator_range( r );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class Range >
inline boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
as_array( const Range& r )
{
return boost::make_iterator_range( r );
}
#endif
}
#endif

View File

@ -0,0 +1,127 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_AS_LITERAL_HPP
#define BOOST_RANGE_AS_LITERAL_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/as_literal.hpp>
#else
#include <boost/range/iterator_range.hpp>
#include <boost/range/detail/str_types.hpp>
#include <boost/detail/workaround.hpp>
#include <cstring>
#ifndef BOOST_NO_CWCHAR
#include <cwchar>
#endif
namespace boost
{
namespace range_detail
{
inline std::size_t length( const char* s )
{
return strlen( s );
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
inline std::size_t length( const wchar_t* s )
{
return wcslen( s );
}
#endif
//
// Remark: the compiler cannot choose between T* and T[sz]
// overloads, so we must put the T* internal to the
// unconstrained version.
//
inline bool is_char_ptr( char* )
{
return true;
}
inline bool is_char_ptr( const char* )
{
return true;
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
inline bool is_char_ptr( wchar_t* )
{
return true;
}
inline bool is_char_ptr( const wchar_t* )
{
return true;
}
#endif
template< class T >
inline long is_char_ptr( T /* r */ )
{
return 0L;
}
template< class T >
inline iterator_range<T*>
make_range( T* const r, bool )
{
return iterator_range<T*>( r, r + length(r) );
}
template< class T >
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<T>::type>
make_range( T& r, long )
{
return boost::make_iterator_range( r );
}
}
template< class Range >
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
as_literal( Range& r )
{
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
}
template< class Range >
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type>
as_literal( const Range& r )
{
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
}
template< class Char, std::size_t sz >
inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
{
return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
}
template< class Char, std::size_t sz >
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
{
return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
}
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif

733
include/boost/range/atl.hpp Normal file
View File

@ -0,0 +1,733 @@
#ifndef BOOST_RANGE_ATL_HPP
#define BOOST_RANGE_ATL_HPP
// Boost.Range ATL Extension
//
// Copyright Shunsuke Sogame 2005-2006.
// 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)
// config
//
#include <atldef.h> // _ATL_VER
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
#if (_ATL_VER < 0x0700)
#define BOOST_RANGE_ATL_NO_COLLECTIONS
#endif
#endif
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
#if (_ATL_VER < 0x0700) // dubious
#define BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX
#endif
#endif
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
#if (_MSC_VER < 1310) // from <boost/regex/mfc.hpp>, but dubious
#define BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING
#endif
#endif
// forward declarations
//
#include <basetyps.h> // IID
namespace ATL {
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
// arrays
//
template< class E, class ETraits >
class CAtlArray;
template< class E >
class CAutoPtrArray;
template< class I, const IID *piid >
class CInterfaceArray;
// lists
//
template< class E, class ETraits >
class CAtlList;
template< class E >
class CAutoPtrList;
template< class E, class Allocator >
class CHeapPtrList;
template< class I, const IID *piid >
class CInterfaceList;
// maps
//
template< class K, class V, class KTraits, class VTraits >
class CAtlMap;
template< class K, class V, class KTraits, class VTraits >
class CRBTree;
template< class K, class V, class KTraits, class VTraits >
class CRBMap;
template< class K, class V, class KTraits, class VTraits >
class CRBMultiMap;
// strings
//
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
template< class BaseType, bool t_bMFCDLL >
class CSimpleStringT;
#else
template< class BaseType >
class CSimpleStringT;
#endif
template< class BaseType, class StringTraits >
class CStringT;
template< class StringType, int t_nChars >
class CFixedStringT;
template< class BaseType, const int t_nSize >
class CStaticString;
#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
// simples
//
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
template< class T, class TEqual >
class CSimpleArray;
template< class TKey, class TVal, class TEqual >
class CSimpleMap;
#else
template< class T >
class CSimpleArray;
template< class T >
class CSimpleValArray;
template< class TKey, class TVal >
class CSimpleMap;
#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
// pointers
//
template< class E >
class CAutoPtr;
template< class T >
class CComPtr;
template< class T, const IID *piid >
class CComQIPtr;
template< class E, class Allocator >
class CHeapPtr;
template< class T >
class CAdapt;
} // namespace ATL
// indirect_iterator customizations
//
#include <boost/mpl/identity.hpp>
#include <boost/pointee.hpp>
namespace boost {
template< class E >
struct pointee< ATL::CAutoPtr<E> > :
mpl::identity<E>
{ };
template< class T >
struct pointee< ATL::CComPtr<T> > :
mpl::identity<T>
{ };
template< class T, const IID *piid >
struct pointee< ATL::CComQIPtr<T, piid> > :
mpl::identity<T>
{ };
template< class E, class Allocator >
struct pointee< ATL::CHeapPtr<E, Allocator> > :
mpl::identity<E>
{ };
template< class T >
struct pointee< ATL::CAdapt<T> > :
pointee<T>
{ };
} // namespace boost
// extended customizations
//
#include <boost/iterator/indirect_iterator.hpp>
#include <boost/iterator/zip_iterator.hpp>
#include <boost/range/detail/microsoft.hpp>
#include <boost/tuple/tuple.hpp>
#include <atlbase.h> // CComBSTR
namespace boost { namespace range_detail_microsoft {
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
// arrays
//
struct atl_array_functions :
array_functions
{
template< class Iterator, class X >
Iterator end(X& x) // redefine
{
return x.GetData() + x.GetCount(); // no 'GetSize()'
}
};
template< class E, class ETraits >
struct customization< ATL::CAtlArray<E, ETraits> > :
atl_array_functions
{
template< class X >
struct meta
{
typedef E val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< class E >
struct customization< ATL::CAutoPtrArray<E> > :
atl_array_functions
{
template< class X >
struct meta
{
// ATL::CAutoPtr/CHeapPtr is no assignable.
typedef ATL::CAutoPtr<E> val_t;
typedef val_t *miter_t;
typedef val_t const *citer_t;
typedef indirect_iterator<miter_t> mutable_iterator;
typedef indirect_iterator<citer_t> const_iterator;
};
};
template< class I, const IID *piid >
struct customization< ATL::CInterfaceArray<I, piid> > :
atl_array_functions
{
template< class X >
struct meta
{
typedef ATL::CComQIPtr<I, piid> val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< class E, class ETraits >
struct customization< ATL::CAtlList<E, ETraits> > :
list_functions
{
template< class X >
struct meta
{
typedef E val_t;
typedef list_iterator<X, val_t> mutable_iterator;
typedef list_iterator<X const, val_t const> const_iterator;
};
};
struct indirected_list_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
typedef typename Iterator::base_type base_t; // == list_iterator
return Iterator(base_t(x, x.GetHeadPosition()));
}
template< class Iterator, class X >
Iterator end(X& x)
{
typedef typename Iterator::base_type base_t;
return Iterator(base_t(x, POSITION(0)));
}
};
template< class E >
struct customization< ATL::CAutoPtrList<E> > :
indirected_list_functions
{
template< class X >
struct meta
{
typedef ATL::CAutoPtr<E> val_t;
typedef list_iterator<X, val_t> miter_t;
typedef list_iterator<X const, val_t const> citer_t;
typedef indirect_iterator<miter_t> mutable_iterator;
typedef indirect_iterator<citer_t> const_iterator;
};
};
template< class E, class Allocator >
struct customization< ATL::CHeapPtrList<E, Allocator> > :
indirected_list_functions
{
template< class X >
struct meta
{
typedef ATL::CHeapPtr<E, Allocator> val_t;
typedef list_iterator<X, val_t> miter_t;
typedef list_iterator<X const, val_t const> citer_t;
typedef indirect_iterator<miter_t> mutable_iterator;
typedef indirect_iterator<citer_t> const_iterator;
};
};
template< class I, const IID *piid >
struct customization< ATL::CInterfaceList<I, piid> > :
list_functions
{
template< class X >
struct meta
{
typedef ATL::CComQIPtr<I, piid> val_t;
typedef list_iterator<X, val_t> mutable_iterator;
typedef list_iterator<X const, val_t const> const_iterator;
};
};
// maps
//
struct atl_rb_tree_tag
{ };
template< >
struct customization< atl_rb_tree_tag > :
indirected_list_functions
{
template< class X >
struct meta
{
typedef typename X::CPair val_t;
typedef list_iterator<X, val_t *, val_t *> miter_t;
typedef list_iterator<X const, val_t const *, val_t const *> citer_t;
typedef indirect_iterator<miter_t> mutable_iterator;
typedef indirect_iterator<citer_t> const_iterator;
};
};
template< class K, class V, class KTraits, class VTraits >
struct customization< ATL::CAtlMap<K, V, KTraits, VTraits> > :
customization< atl_rb_tree_tag >
{
template< class Iterator, class X >
Iterator begin(X& x) // redefine
{
typedef typename Iterator::base_type base_t; // == list_iterator
return Iterator(base_t(x, x.GetStartPosition())); // no 'GetHeadPosition'
}
};
// strings
//
struct atl_string_tag
{ };
template< >
struct customization< atl_string_tag >
{
template< class X >
struct meta
{
typedef typename X::PXSTR mutable_iterator;
typedef typename X::PCXSTR const_iterator;
};
template< class Iterator, class X >
typename mutable_<Iterator, X>::type begin(X& x)
{
return x.GetBuffer(0);
}
template< class Iterator, class X >
Iterator begin(X const& x)
{
return x.GetString();
}
template< class Iterator, class X >
Iterator end(X& x)
{
return begin<Iterator>(x) + x.GetLength();
}
};
template< class BaseType, const int t_nSize >
struct customization< ATL::CStaticString<BaseType, t_nSize> >
{
template< class X >
struct meta
{
typedef BaseType const *mutable_iterator;
typedef mutable_iterator const_iterator;
};
template< class Iterator, class X >
Iterator begin(X const& x)
{
return x;
}
template< class Iterator, class X >
Iterator end(X const& x)
{
return begin<Iterator>(x) + X::GetLength();
}
};
#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
template< >
struct customization< ATL::CComBSTR >
{
template< class X >
struct meta
{
typedef OLECHAR *mutable_iterator;
typedef OLECHAR const *const_iterator;
};
template< class Iterator, class X >
Iterator begin(X& x)
{
return x.operator BSTR();
}
template< class Iterator, class X >
Iterator end(X& x)
{
return begin<Iterator>(x) + x.Length();
}
};
// simples
//
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
template< class T, class TEqual >
struct customization< ATL::CSimpleArray<T, TEqual> > :
#else
template< class T >
struct customization< ATL::CSimpleArray<T> > :
#endif
array_functions
{
template< class X >
struct meta
{
typedef T val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
#if defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
template< class T >
struct customization< ATL::CSimpleValArray<T> > :
array_functions
{
template< class X >
struct meta
{
typedef T val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
#endif // defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
template< class TKey, class TVal, class TEqual >
struct customization< ATL::CSimpleMap<TKey, TVal, TEqual> >
#else
template< class TKey, class TVal >
struct customization< ATL::CSimpleMap<TKey, TVal> >
#endif
{
template< class X >
struct meta
{
typedef TKey k_val_t;
typedef k_val_t *k_miter_t;
typedef k_val_t const *k_citer_t;
typedef TVal v_val_t;
typedef v_val_t *v_miter_t;
typedef v_val_t const *v_citer_t;
// Topic:
// 'std::pair' can't contain references
// because of reference to reference problem.
typedef zip_iterator< tuple<k_miter_t, v_miter_t> > mutable_iterator;
typedef zip_iterator< tuple<k_citer_t, v_citer_t> > const_iterator;
};
template< class Iterator, class X >
Iterator begin(X& x)
{
return Iterator(boost::make_tuple(x.m_aKey, x.m_aVal));
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(boost::make_tuple(x.m_aKey + x.GetSize(), x.m_aVal + x.GetSize()));
}
};
} } // namespace boost::range_detail_microsoft
// range customizations
//
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
// arrays
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CAtlArray, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CAutoPtrArray, 1
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CInterfaceArray, (class)(const IID *)
)
// lists
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CAtlList, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CAutoPtrList, 1
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CHeapPtrList, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CInterfaceList, (class)(const IID *)
)
//maps
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CAtlMap, 4
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_rb_tree_tag,
(ATL, BOOST_PP_NIL), CRBTree, 4
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_rb_tree_tag,
(ATL, BOOST_PP_NIL), CRBMap, 4
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_rb_tree_tag,
(ATL, BOOST_PP_NIL), CRBMultiMap, 4
)
// strings
//
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_string_tag,
(ATL, BOOST_PP_NIL), CSimpleStringT, (class)(bool)
)
#else
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_string_tag,
(ATL, BOOST_PP_NIL), CSimpleStringT, 1
)
#endif
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_string_tag,
(ATL, BOOST_PP_NIL), CStringT, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::atl_string_tag,
(ATL, BOOST_PP_NIL), CFixedStringT, (class)(int)
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CStaticString, (class)(const int)
)
#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CComBSTR
)
// simples
//
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CSimpleArray, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CSimpleMap, 3
)
#else
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CSimpleArray, 1
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CSimpleMap, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
(ATL, BOOST_PP_NIL), CSimpleValArray, 1
)
#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
#endif

135
include/boost/range/begin.hpp Executable file → Normal file
View File

@ -22,94 +22,111 @@
#else
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
namespace boost
namespace boost
{
namespace range
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// default
// primary template
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type
begin( const C& c )
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
range_begin( C& c )
{
return c.begin();
//
// If you get a compile-error here, it is most likely because
// you have not implemented range_begin() properly in
// the namespace of C
//
return c.begin();
}
template< typename C >
inline BOOST_DEDUCED_TYPENAME iterator_of<C>::type
begin( C& c )
{
return c.begin();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator begin( const std::pair<Iterator,Iterator>& p )
inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
{
return p.first;
}
template< typename Iterator >
inline Iterator begin( std::pair<Iterator,Iterator>& p )
inline Iterator range_begin( std::pair<Iterator,Iterator>& p )
{
return p.first;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
//
// May this be discarded? Or is it needed for bad compilers?
//
template< typename T, std::size_t sz >
inline const T* begin( const T (&array)[sz] )
inline const T* range_begin( const T (&a)[sz] )
{
return array;
}
template< typename T, std::size_t sz >
inline T* begin( T (&array)[sz] )
{
return array;
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline const char* begin( const char* s )
{
return s;
}
inline char* begin( char* s )
{
return s;
}
inline const wchar_t* begin( const wchar_t* s )
{
return s;
}
inline wchar_t* begin( wchar_t* s )
{
return s;
return a;
}
} // namespace 'range'
template< typename T, std::size_t sz >
inline T* range_begin( T (&a)[sz] )
{
return a;
}
using range::begin;
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
} // namespace 'range_detail'
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_begin( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_begin( r );
}
} // namespace boost
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_begin( const T& r )
{
return boost::begin( r );
}
}
#endif

View File

@ -0,0 +1,29 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_CATEGORY_HPP
#define BOOST_RANGE_CATEGORY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_category : iterator_category< typename range_iterator<T>::type >
{ };
}
#endif

View File

@ -0,0 +1,140 @@
// Boost.Range library concept checks
//
// Copyright Daniel Walker 2006. Use, modification and distribution
// are subject to the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_CONCEPTS_HPP
#define BOOST_RANGE_CONCEPTS_HPP
#include <boost/concept_check.hpp>
#include <boost/iterator/iterator_concepts.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
/*!
* \file
* \brief Concept checks for the Boost Range library.
*
* The structures in this file may be used in conjunction with the
* Boost Concept Check library to insure that the type of a function
* parameter is compatible with a range concept. If not, a meaningful
* compile time error is generated. Checks are provided for the range
* concepts related to iterator traversal categories. For example, the
* following line checks that the type T models the ForwardRange
* concept.
*
* \code
* function_requires<ForwardRangeConcept<T> >();
* \endcode
*
* An additional concept check is required for the value access
* property of the range. For example to check for a
* ForwardReadableRange, the following code is required.
*
* \code
* function_requires<ForwardRangeConcept<T> >();
* function_requires<
* ReadableIteratorConcept<
* typename range_iterator<T>::type
* >
* >();
* \endcode
*
* \see http://www.boost.org/libs/range/doc/range.html for details
* about range concepts.
* \see http://www.boost.org/libs/iterator/doc/iterator_concepts.html
* for details about iterator concepts.
* \see http://www.boost.org/libs/concept_check/concept_check.htm for
* details about concept checks.
*/
namespace boost {
//! Check if a type T models the SinglePassRange range concept.
template<typename T>
struct SinglePassRangeConcept
{
typedef typename range_iterator<T const>::type range_const_iterator;
typedef typename range_iterator<T>::type range_iterator;
void constraints()
{
function_requires<
boost_concepts::SinglePassIteratorConcept<
range_iterator
>
>();
i = boost::begin(a);
i = boost::end(a);
const_constraints(a);
}
void const_constraints(const T& a)
{
ci = boost::begin(a);
ci = boost::end(a);
}
T a;
range_iterator i;
range_const_iterator ci;
};
//! Check if a type T models the ForwardRange range concept.
template<typename T>
struct ForwardRangeConcept
{
void constraints()
{
function_requires<
SinglePassRangeConcept<T>
>();
function_requires<
boost_concepts::ForwardTraversalConcept<
typename range_iterator<T>::type
>
>();
}
};
//! Check if a type T models the BidirectionalRange range concept.
template<typename T>
struct BidirectionalRangeConcept
{
void constraints()
{
function_requires<
ForwardRangeConcept<T>
>();
function_requires<
boost_concepts::BidirectionalTraversalConcept<
typename range_iterator<T>::type
>
>();
}
};
//! Check if a type T models the RandomAccessRange range concept.
template<typename T>
struct RandomAccessRangeConcept
{
void constraints()
{
function_requires<
BidirectionalRangeConcept<T>
>();
function_requires<
boost_concepts::RandomAccessTraversalConcept<
typename range_iterator<T>::type
>
>();
}
};
} // namespace boost
#endif // BOOST_RANGE_CONCEPTS_HPP

28
include/boost/range/config.hpp Executable file → Normal file
View File

@ -11,35 +11,41 @@
#ifndef BOOST_RANGE_CONFIG_HPP
#define BOOST_RANGE_CONFIG_HPP
#include <boost/detail/workaround.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#ifdef BOOST_CT_DEDUCED_TYPENAME
#ifdef BOOST_RANGE_DEDUCED_TYPENAME
#error "macro already defined!"
#endif
#ifdef __BORLANDC__
#define BOOST_CT_DEDUCED_TYPENAME
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# define BOOST_RANGE_DEDUCED_TYPENAME typename
#else
#define BOOST_CT_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) && !defined(_MSC_EXTENSIONS)
# define BOOST_RANGE_DEDUCED_TYPENAME typename
# else
# define BOOST_RANGE_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
# endif
#endif
#ifdef BOOST_CT_NO_ARRAY_SUPPORT
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
#error "macro already defined!"
#endif
#if _MSC_VER <= 1200 && !defined( __COMO__ ) && !defined( _GNUC_ )
#define BOOST_CT_NO_ARRAY_SUPPORT
#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
#define BOOST_RANGE_NO_ARRAY_SUPPORT 1
#endif
#ifdef BOOST_CT_NO_ARRAY_SUPPORT
#define BOOST_ARRAY_REF (array)
#define BOOST_CT_NO_STATIC_ASSERT
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
#define BOOST_RANGE_ARRAY_REF() (boost_range_array)
#define BOOST_RANGE_NO_STATIC_ASSERT
#else
#define BOOST_ARRAY_REF (&array)
#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
#endif

47
include/boost/range/const_iterator.hpp Executable file → Normal file
View File

@ -21,6 +21,7 @@
#include <boost/range/detail/const_iterator.hpp>
#else
#include <boost/type_traits/remove_const.hpp>
#include <cstddef>
#include <utility>
@ -31,7 +32,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct const_iterator_of
struct range_const_iterator
{
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
};
@ -41,61 +42,21 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct const_iterator_of< std::pair<Iterator,Iterator> >
struct range_const_iterator< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
template< typename Iterator >
struct const_iterator_of< const std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct const_iterator_of< T[sz] >
struct range_const_iterator< T[sz] >
{
typedef const T* type;
};
template< typename T, std::size_t sz >
struct const_iterator_of< const T[sz] >
{
typedef const T* type;
};
//////////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////////
template<>
struct const_iterator_of< char* >
{
typedef const char* type;
};
template<>
struct const_iterator_of< wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct const_iterator_of< const char* >
{
typedef const char* type;
};
template<>
struct const_iterator_of< const wchar_t* >
{
typedef const wchar_t* type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION

17
include/boost/range/const_reverse_iterator.hpp Executable file → Normal file
View File

@ -15,22 +15,17 @@
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/range/reverse_iterator.hpp>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
//
// This interface is deprecated, use range_reverse_iterator<const T>
//
template< typename C >
struct const_reverse_iterator_of
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type > type;
};
struct range_const_reverse_iterator : range_reverse_iterator<const C>
{ };
} // namespace boost

View File

@ -0,0 +1,33 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/detail/detail_str.hpp>
#include <boost/range/iterator_range.hpp>
namespace boost
{
template< class Range >
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
as_literal( Range& r )
{
return ::boost::make_iterator_range( ::boost::range_detail::str_begin(r),
::boost::range_detail::str_end(r) );
}
}
#endif

70
include/boost/range/detail/begin.hpp Executable file → Normal file
View File

@ -11,8 +11,13 @@
#ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
#define BOOST_RANGE_DETAIL_BEGIN_HPP
#include <boost/range/result_iterator.hpp>
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/detail/common.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/value_type.hpp>
#endif
namespace boost
{
@ -30,7 +35,7 @@ namespace boost
struct range_begin<std_container_>
{
template< typename C >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<C>::type fun( C& c )
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
{
return c.begin();
};
@ -44,7 +49,7 @@ namespace boost
struct range_begin<std_pair_>
{
template< typename P >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<P>::type fun( const P& p )
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
{
return p.first;
}
@ -57,61 +62,28 @@ namespace boost
template<>
struct range_begin<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_ARRAY_REF[sz] )
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return array;
return boost_range_array;
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
{
return t;
}
#endif
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<char_ptr_>
{
static char* fun( char* s )
{
return s;
}
};
template<>
struct range_begin<const_char_ptr_>
{
static const char* fun( const char* s )
{
return s;
}
};
template<>
struct range_begin<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return s;
}
};
template<>
struct range_begin<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return s;
}
};
} // namespace 'range_traits_detail'
} // namespace 'range_detail'
template< typename C >
inline BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
begin( C& c )
{
return range_traits_detail::range_begin< BOOST_DEDUCED_TYPENAME range_traits_detail::range<C>::type >::fun( c );
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'

View File

@ -0,0 +1,266 @@
// Boost string_algo library collection_traits.hpp header file -------------//
// Copyright Pavol Droba 2002-2003. 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)
// (C) Copyright Thorsten Ottosen 2002-2003. 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)
// (C) Copyright Jeremy Siek 2001. 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)
// Original idea of container traits was proposed by Jeremy Siek and
// Thorsten Ottosen. This implementation is lightweighted version
// of container_traits adapter for usage with string_algo library
#ifndef BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
#define BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/mpl/eval_if.hpp>
// Implementation
#include <boost/range/detail/collection_traits_detail.hpp>
/*! \file
Defines collection_traits class and related free-standing functions.
This facility is used to unify the access to different types of collections.
It allows the algorithms in the library to work with STL collections, c-style
array, null-terminated c-strings (and more) using the same interface.
*/
namespace boost {
namespace algorithm {
// collection_traits template class -----------------------------------------//
//! collection_traits class
/*!
Collection traits provide uniform access to different types of
collections. This functionality allows to write generic algorithms
which work with several different kinds of collections.
Currently following collection types are supported:
- containers with STL compatible container interface ( see ContainerConcept )
( i.e. \c std::vector<>, \c std::list<>, \c std::string<> ... )
- c-style array
( \c char[10], \c int[15] ... )
- null-terminated c-strings
( \c char*, \c wchar_T* )
- std::pair of iterators
( i.e \c std::pair<vector<int>::iterator,vector<int>::iterator> )
Collection traits provide an external collection interface operations.
All are accessible using free-standing functions.
The following operations are supported:
- \c size()
- \c empty()
- \c begin()
- \c end()
Container traits have somewhat limited functionality on compilers not
supporting partial template specialization and partial template ordering.
*/
template< typename T >
struct collection_traits
{
private:
typedef BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
::boost::algorithm::detail::is_pair<T>,
detail::pair_container_traits_selector<T>,
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
::boost::is_array<T>,
detail::array_container_traits_selector<T>,
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
::boost::is_pointer<T>,
detail::pointer_container_traits_selector<T>,
detail::default_container_traits_selector<T>
>
>
>::type container_helper_type;
public:
//! Function type
typedef container_helper_type function_type;
//! Value type
typedef BOOST_STRING_TYPENAME
container_helper_type::value_type value_type;
//! Size type
typedef BOOST_STRING_TYPENAME
container_helper_type::size_type size_type;
//! Iterator type
typedef BOOST_STRING_TYPENAME
container_helper_type::iterator iterator;
//! Const iterator type
typedef BOOST_STRING_TYPENAME
container_helper_type::const_iterator const_iterator;
//! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
typedef BOOST_STRING_TYPENAME
container_helper_type::result_iterator result_iterator;
//! Difference type
typedef BOOST_STRING_TYPENAME
container_helper_type::difference_type difference_type;
}; // 'collection_traits'
// collection_traits metafunctions -----------------------------------------//
//! Container value_type trait
/*!
Extract the type of elements contained in a container
*/
template< typename C >
struct value_type_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::value_type type;
};
//! Container difference trait
/*!
Extract the container's difference type
*/
template< typename C >
struct difference_type_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::difference_type type;
};
//! Container iterator trait
/*!
Extract the container's iterator type
*/
template< typename C >
struct iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::iterator type;
};
//! Container const_iterator trait
/*!
Extract the container's const_iterator type
*/
template< typename C >
struct const_iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::const_iterator type;
};
//! Container result_iterator
/*!
Extract the container's result_iterator type. This type maps to \c C::iterator
for mutable container and \c C::const_iterator for const containers.
*/
template< typename C >
struct result_iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::result_iterator type;
};
// collection_traits related functions -----------------------------------------//
//! Free-standing size() function
/*!
Get the size of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::size_type
size( const C& c )
{
return collection_traits<C>::function_type::size( c );
}
//! Free-standing empty() function
/*!
Check whether the container is empty. Uses container traits.
*/
template< typename C >
inline bool empty( const C& c )
{
return collection_traits<C>::function_type::empty( c );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//! Free-standing begin() function
/*!
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
begin( C& c )
{
return collection_traits<C>::function_type::begin( c );
}
//! Free-standing begin() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
begin( const C& c )
{
return collection_traits<C>::function_type::begin( c );
}
//! Free-standing end() function
/*!
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
end( C& c )
{
return collection_traits<C>::function_type::end( c );
}
//! Free-standing end() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
end( const C& c )
{
return collection_traits<C>::function_type::end( c );
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//! Free-standing begin() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
begin( C& c )
{
return collection_traits<C>::function_type::begin( c );
}
//! Free-standing end() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
end( C& c )
{
return collection_traits<C>::function_type::end( c );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
} // namespace algorithm
} // namespace boost
#endif // BOOST_STRING_COLLECTION_TRAITS_HPP

View File

@ -0,0 +1,621 @@
// Boost string_algo library collection_traits.hpp header file -----------------------//
// Copyright Pavol Droba 2002-2003. 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)
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
#define BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
#include <boost/algorithm/string/config.hpp>
#include <cstddef>
#include <string>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/algorithm/string/yes_no_type.hpp>
// Container traits implementation ---------------------------------------------------------
namespace boost {
namespace algorithm {
namespace detail {
// Default collection traits -----------------------------------------------------------------
// Default collection helper
/*
Wraps std::container compliant containers
*/
template< typename ContainerT >
struct default_container_traits
{
typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type;
typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator;
typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
::boost::mpl::if_< ::boost::is_const<ContainerT>,
const_iterator,
iterator
>::type result_iterator;
typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type;
typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type;
// static operations
template< typename C >
static size_type size( const C& c )
{
return c.size();
}
template< typename C >
static bool empty( const C& c )
{
return c.empty();
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename C >
static iterator begin( C& c )
{
return c.begin();
}
template< typename C >
static const_iterator begin( const C& c )
{
return c.begin();
}
template< typename C >
static iterator end( C& c )
{
return c.end();
}
template< typename C >
static const_iterator end( const C& c )
{
return c.end();
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename C >
static result_iterator begin( C& c )
{
return c.begin();
}
template< typename C >
static result_iterator end( C& c )
{
return c.end();
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
};
template<typename T>
struct default_container_traits_selector
{
typedef default_container_traits<T> type;
};
// Pair container traits ---------------------------------------------------------------------
// pair selector
template< typename T, typename U >
yes_type is_pair_impl( const std::pair<T,U>* );
no_type is_pair_impl( ... );
template<typename T> struct is_pair
{
private:
static T* t;
public:
BOOST_STATIC_CONSTANT( bool, value=
sizeof(is_pair_impl(t))==sizeof(yes_type) );
};
// pair helper
template< typename PairT >
struct pair_container_traits
{
typedef BOOST_STRING_TYPENAME PairT::first_type element_type;
typedef BOOST_STRING_TYPENAME ::boost::detail::
iterator_traits<element_type>::value_type value_type;
typedef std::size_t size_type;
typedef BOOST_STRING_TYPENAME ::boost::detail::
iterator_traits<element_type>::difference_type difference_type;
typedef element_type iterator;
typedef element_type const_iterator;
typedef element_type result_iterator;
// static operations
template< typename P >
static size_type size( const P& p )
{
difference_type diff = std::distance( p.first, p.second );
if ( diff < 0 )
return 0;
else
return diff;
}
template< typename P >
static bool empty( const P& p )
{
return p.first==p.second;
}
template< typename P >
static const_iterator begin( const P& p )
{
return p.first;
}
template< typename P >
static const_iterator end( const P& p )
{
return p.second;
}
}; // 'pair_container_helper'
template<typename T>
struct pair_container_traits_selector
{
typedef pair_container_traits<T> type;
};
// Array container traits ---------------------------------------------------------------
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// array traits ( partial specialization )
template< typename T >
struct array_traits;
template< typename T, std::size_t sz >
struct array_traits<T[sz]>
{
// typedef
typedef T* iterator;
typedef const T* const_iterator;
typedef T value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// size of the array ( static );
BOOST_STATIC_CONSTANT( size_type, array_size = sz );
};
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// array traits ( no partial specialization )
/*
without parial specialization we are able to
provide support only for a limited number of
types. Currently the primitive numeric types
are supported
*/
template< typename T, typename BaseT >
struct array_traits_impl
{
typedef BaseT value_type;
typedef BaseT* iterator;
typedef const BaseT* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// size of the array
BOOST_STATIC_CONSTANT( size_type, array_size = sizeof(T)/sizeof(BaseT) );
};
template< typename T, typename BaseT >
struct array_traits_impl_selector
{
typedef array_traits_impl<T,BaseT> type;
};
struct array_traits_void
{
typedef void type;
};
template< typename T, typename BaseT >
struct array_traits_cv_selector
{
typedef BOOST_STRING_TYPENAME
::boost::mpl::eval_if<
::boost::is_convertible<T,BaseT*>,
array_traits_impl_selector<T,BaseT>,
::boost::mpl::eval_if<
::boost::is_convertible<T,const BaseT*>,
array_traits_impl_selector<T, const BaseT>,
::boost::mpl::eval_if<
::boost::is_convertible<T, volatile BaseT*>,
array_traits_impl_selector<T, volatile BaseT>,
array_traits_impl_selector<T, const volatile BaseT>
>
>
>::type type;
};
template< typename T >
struct array_traits_select
{
template< typename T1, typename T2 >
struct apply
{
typedef BOOST_STRING_TYPENAME
::boost::mpl::eval_if<
::boost::is_convertible<T,const volatile T2*>,
array_traits_cv_selector<T,T2>,
::boost::mpl::identity<T1> >::type type;
};
};
template< typename T >
struct array_traits_selector
{
private:
// supported array base types
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
typedef BOOST_STRING_TYPENAME
::boost::mpl::vector10<
wchar_t,
#else // BOOST_NO_INTRINSIC_WCHAR_T
typedef BOOST_STRING_TYPENAME
::boost::mpl::vector9<
#endif // BOOST_NO_INTRINSIC_WCHAR_T
char,
signed char,
unsigned char,
signed short,
unsigned short,
signed int,
unsigned int,
signed long,
unsigned long
>::type array_base_types;
public:
typedef BOOST_STRING_TYPENAME
::boost::mpl::fold<
array_base_types,
::boost::algorithm::detail::array_traits_void,
::boost::algorithm::detail::array_traits_select<T> >::type type;
};
template< typename T >
struct array_traits
{
typedef BOOST_STRING_TYPENAME
array_traits_selector<T>::type traits_type;
typedef BOOST_STRING_TYPENAME
traits_type::value_type value_type;
typedef BOOST_STRING_TYPENAME
traits_type::iterator iterator;
typedef BOOST_STRING_TYPENAME
traits_type::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
traits_type::size_type size_type;
typedef BOOST_STRING_TYPENAME
traits_type::difference_type difference_type;
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// array lenght resolving
/*
Lenght of string contained in a static array could
be different from the size of the array.
For string processing we need the lenght without
terminating 0.
Therefore, the lenght is calulated for char and wchar_t
using char_traits, rather then simply returning
the array size.
*/
template< typename T >
struct array_length_selector
{
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
TraitsT::size_type size_type;
BOOST_STATIC_CONSTANT(
size_type,
array_size=TraitsT::array_size );
template< typename A >
static size_type length( const A& )
{
return array_size;
}
template< typename A >
static bool empty( const A& )
{
return array_size==0;
}
};
};
// specialization for char
template<>
struct array_length_selector<char>
{
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
TraitsT::size_type size_type;
template< typename A >
static size_type length( const A& a )
{
if ( a==0 )
return 0;
else
return std::char_traits<char>::length(a);
}
template< typename A >
static bool empty( const A& a )
{
return a==0 || a[0]==0;
}
};
};
// specialization for wchar_t
template<>
struct array_length_selector<wchar_t>
{
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
TraitsT::size_type size_type;
template< typename A >
static size_type length( const A& a )
{
if ( a==0 )
return 0;
else
return std::char_traits<wchar_t>::length(a);
}
template< typename A >
static bool empty( const A& a )
{
return a==0 || a[0]==0;
}
};
};
template< typename T >
struct array_container_traits
{
private:
// resolve array traits
typedef array_traits<T> traits_type;
public:
typedef BOOST_STRING_TYPENAME
traits_type::value_type value_type;
typedef BOOST_STRING_TYPENAME
traits_type::iterator iterator;
typedef BOOST_STRING_TYPENAME
traits_type::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
traits_type::size_type size_type;
typedef BOOST_STRING_TYPENAME
traits_type::difference_type difference_type;
typedef BOOST_STRING_TYPENAME
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator
>::type result_iterator;
private:
// resolve array size
typedef BOOST_STRING_TYPENAME
::boost::remove_cv<value_type>::type char_type;
typedef BOOST_STRING_TYPENAME
array_length_selector<char_type>::
BOOST_NESTED_TEMPLATE array_length<traits_type> array_length_type;
public:
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
// static operations
template< typename A >
static size_type size( const A& a )
{
return array_length_type::length(a);
}
template< typename A >
static bool empty( const A& a )
{
return array_length_type::empty(a);
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename A >
static iterator begin( A& a )
{
return a;
}
template< typename A >
static const_iterator begin( const A& a )
{
return a;
}
template< typename A >
static iterator end( A& a )
{
return a+array_length_type::length(a);
}
template< typename A >
static const_iterator end( const A& a )
{
return a+array_length_type::length(a);
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename A >
static result_iterator begin( A& a )
{
return a;
}
template< typename A >
static result_iterator end( A& a )
{
return a+array_length_type::length(a);
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
};
template<typename T>
struct array_container_traits_selector
{
typedef array_container_traits<T> type;
};
// Pointer container traits ---------------------------------------------------------------
template<typename T>
struct pointer_container_traits
{
typedef BOOST_STRING_TYPENAME
::boost::remove_pointer<T>::type value_type;
typedef BOOST_STRING_TYPENAME
::boost::remove_cv<value_type>::type char_type;
typedef ::std::char_traits<char_type> char_traits;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef BOOST_STRING_TYPENAME
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator
>::type result_iterator;
// static operations
template< typename P >
static size_type size( const P& p )
{
if ( p==0 )
return 0;
else
return char_traits::length(p);
}
template< typename P >
static bool empty( const P& p )
{
return p==0 || p[0]==0;
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename P >
static iterator begin( P& p )
{
return p;
}
template< typename P >
static const_iterator begin( const P& p )
{
return p;
}
template< typename P >
static iterator end( P& p )
{
if ( p==0 )
return p;
else
return p+char_traits::length(p);
}
template< typename P >
static const_iterator end( const P& p )
{
if ( p==0 )
return p;
else
return p+char_traits::length(p);
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename P >
static result_iterator begin( P& p )
{
return p;
}
template< typename P >
static result_iterator end( P& p )
{
if ( p==0 )
return p;
else
return p+char_traits::length(p);
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
};
template<typename T>
struct pointer_container_traits_selector
{
typedef pointer_container_traits<T> type;
};
} // namespace detail
} // namespace algorithm
} // namespace boost
#endif // BOOST_STRING_DETAIL_COLLECTION_HPP

28
include/boost/range/detail/common.hpp Executable file → Normal file
View File

@ -17,7 +17,6 @@
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
#include <boost/mpl/if.hpp>
@ -59,7 +58,7 @@ namespace boost
typedef mpl::int_<12>::type string_;
template< typename C >
struct collection_helper
struct range_helper
{
static C* c;
static C ptr;
@ -79,35 +78,35 @@ namespace boost
template< typename C >
class range
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_pair_,
boost::range_detail::std_pair_,
void >::type pair_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_array_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
boost::range_detail::std_pair_,
void >::type pair_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
boost::range_detail::array_,
pair_t >::type array_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_string_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
boost::range_detail::string_,
array_t >::type string_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_const_char_ptr_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
boost::range_detail::const_char_ptr_,
string_t >::type const_char_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_char_ptr_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
boost::range_detail::char_ptr_,
const_char_ptr_t >::type char_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_const_wchar_t_ptr_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
boost::range_detail::const_wchar_t_ptr_,
char_ptr_t >::type const_wchar_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_wchar_t_ptr_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
boost::range_detail::wchar_t_ptr_,
const_wchar_ptr_t >::type wchar_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_wchar_t_array_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
boost::range_detail::wchar_t_array_,
wchar_ptr_t >::type wchar_array_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_char_array_,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
boost::range_detail::char_array_,
wchar_array_t >::type char_array_t;
public:
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::is_void<char_array_t>::value,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
boost::range_detail::std_container_,
char_array_t >::type type;
}; // class 'range'
@ -115,3 +114,4 @@ namespace boost
}
#endif

51
include/boost/range/detail/const_iterator.hpp Executable file → Normal file
View File

@ -12,6 +12,7 @@
#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
@ -30,7 +31,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
typedef BOOST_RANGE_DEDUCED_TYPENAME C::const_iterator type;
};
};
@ -40,57 +41,25 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_const_iterator_<array_>; // give up
template<>
struct range_const_iterator_<char_ptr_>
{
template< typename S >
struct range_const_iterator_<array_>
{
template< typename T >
struct pts
{
typedef const char* type;
};
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_const_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
template<>
struct range_const_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
}
template< typename C >
class const_iterator_of
class range_const_iterator
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:

View File

@ -0,0 +1,376 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_DETAIL_STR_HPP
#define BOOST_RANGE_DETAIL_DETAIL_STR_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/range/iterator.hpp>
namespace boost
{
namespace range_detail
{
//
// iterator
//
template<>
struct range_iterator_<char_array_>
{
template< typename T >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_iterator_<char_ptr_>
{
template< typename S >
struct pts
{
typedef char* type;
};
};
template<>
struct range_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t* type;
};
};
template<>
struct range_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
//
// const iterator
//
template<>
struct range_const_iterator_<char_array_>
{
template< typename T >
struct pts
{
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_const_iterator_<char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
template<>
struct range_const_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
}
}
#include <boost/range/detail/begin.hpp>
#include <boost/range/detail/end.hpp>
#include <boost/range/detail/size_type>
#include <boost/range/detail/value_type>
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
//
// str_begin()
//
template<>
struct range_begin<char_ptr_>
{
static char* fun( char* s )
{
return s;
}
};
template<>
struct range_begin<const_char_ptr_>
{
static const char* fun( const char* s )
{
return s;
}
};
template<>
struct range_begin<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return s;
}
};
template<>
struct range_begin<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return s;
}
};
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
str_begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME
range_detail::range<C>::type >::fun( c );
}
//
// str_end()
//
template<>
struct range_end<char_array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( boost_range_array );
}
};
template<>
struct range_end<wchar_t_array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( boost_range_array );
}
};
template<>
struct range_end<char_ptr_>
{
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct range_end<const_char_ptr_>
{
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct range_end<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct range_end<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
str_end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME
range_detail::range<C>::type >::fun( c );
}
//
// size_type
//
template<>
struct range_size_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
//
// value_type
//
template<>
struct range_value_type_<char_array_>
{
template< typename T >
struct pts
{
typedef char type;
};
};
template<>
struct range_value_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef char type;
};
};
template<>
struct range_value_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char type;
};
};
template<>
struct range_value_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t type;
};
};
template<>
struct range_value_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t type;
};
};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

18
include/boost/range/detail/difference_type.hpp Executable file → Normal file
View File

@ -41,7 +41,7 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
};
};
@ -55,6 +55,16 @@ namespace boost
};
};
template<>
struct range_difference_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<char_ptr_>
{
@ -98,11 +108,11 @@ namespace boost
}
template< typename C >
class difference_type_of
class range_difference
{
typedef BOOST_CT_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_CT_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}

20
include/boost/range/detail/empty.hpp Executable file → Normal file
View File

@ -18,14 +18,14 @@ namespace boost
namespace range_detail
{
template< typename T >
struct collection_empty;
struct range_empty;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<std_container_>
struct range_empty<std_container_>
{
template< typename C >
static bool fun( C& c )
@ -39,7 +39,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<std_pair_>
struct range_empty<std_pair_>
{
template< typename P >
static bool fun( const P& p )
@ -53,12 +53,12 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<array_>
struct range_empty<array_>
{
template< typename T, std::size_t sz >
static bool fun( T BOOST_ARRAY_REF[sz] )
{
if( array == 0 )
if( boost_range_array == 0 )
return true;
return false;
}
@ -69,7 +69,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<char_ptr_>
struct range_empty<char_ptr_>
{
static bool fun( const char* s )
{
@ -78,7 +78,7 @@ namespace boost
};
template<>
struct collection_empty<const_char_ptr_>
struct range_empty<const_char_ptr_>
{
static bool fun( const char* s )
{
@ -87,7 +87,7 @@ namespace boost
};
template<>
struct collection_empty<wchar_t_ptr_>
struct range_empty<wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
@ -96,7 +96,7 @@ namespace boost
};
template<>
struct collection_empty<const_wchar_t_ptr_>
struct range_empty<const_wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
@ -111,7 +111,7 @@ namespace boost
inline bool
empty( const C& c )
{
return range_detail::collection_empty< BOOST_CT_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
return range_detail::range_empty< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'

105
include/boost/range/detail/end.hpp Executable file → Normal file
View File

@ -11,26 +11,36 @@
#ifndef BOOST_RANGE_DETAIL_END_HPP
#define BOOST_RANGE_DETAIL_END_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# include <boost/range/detail/vc6/end.hpp>
#else
# include <boost/range/detail/implementation_help.hpp>
# include <boost/range/iterator.hpp>
# include <boost/range/detail/common.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/detail/remove_extent.hpp>
# endif
namespace boost
{
namespace range_detail
{
template< typename T >
struct collection_end;
struct range_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<std_container_>
struct range_end<std_container_>
{
template< typename C >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<C>::type fun( C& c )
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
fun( C& c )
{
return c.end();
};
@ -41,10 +51,11 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<std_pair_>
struct range_end<std_pair_>
{
template< typename P >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<P>::type fun( const P& p )
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
fun( const P& p )
{
return p.second;
}
@ -55,87 +66,33 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<array_>
struct range_end<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_ARRAY_REF[sz] )
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( array );
return boost::range_detail::array_end( boost_range_array );
}
};
template<>
struct collection_end<char_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
{
return boost::range_detail::array_end( array );
}
};
template<>
struct collection_end<wchar_t_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( array );
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<char_ptr_>
{
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct collection_end<const_char_ptr_>
{
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct collection_end<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct collection_end<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return boost::range_detail::str_end( s );
return t + remove_extent<T>::size;
}
#endif
};
} // namespace 'range_detail'
template< typename C >
inline BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
end( C& c )
{
return range_detail::collection_end< BOOST_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'
# endif // VC6
#endif

100
include/boost/range/detail/implementation_help.hpp Executable file → Normal file
View File

@ -25,6 +25,8 @@ namespace boost
{
namespace range_detail
{
template <typename T>
inline void boost_range_silence_warning( const T& ) { }
/////////////////////////////////////////////////////////////////////
// end() help
@ -43,7 +45,7 @@ namespace boost
#else
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
if( s == 0 && s[0] == 0 )
if( s == 0 || s[0] == 0 )
return s;
while( *++s != 0 )
;
@ -51,107 +53,47 @@ namespace boost
}
#endif
template< typename Char >
template< class Char >
inline Char* str_end( Char* s )
{
return (Char*)str_end( s, s );
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz], int )
{
return array + sz;
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz], int )
{
return array + sz;
return const_cast<Char*>( str_end( s, s ) );
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz], char_or_wchar_t_array_tag )
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return array + sz - 1;
return boost_range_array + sz;
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz], char_or_wchar_t_array_tag )
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
return array + sz - 1;
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_end<T,sz>( array, tag() );
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_end<T,sz>( array, tag() );
return boost_range_array + sz;
}
/////////////////////////////////////////////////////////////////////
// size() help
/////////////////////////////////////////////////////////////////////
template< typename Char >
inline std::size_t str_size( const Char* s )
template< class Char >
inline std::size_t str_size( const Char* const& s )
{
return str_end( s ) - s;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( T BOOST_ARRAY_REF[sz], int )
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
{
boost_range_silence_warning( boost_range_array );
return sz;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T BOOST_ARRAY_REF[sz], int )
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
boost_range_silence_warning( boost_range_array );
return sz;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( T BOOST_ARRAY_REF[sz], char_or_wchar_t_array_tag )
{
return sz - 1;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T BOOST_ARRAY_REF[sz], char_or_wchar_t_array_tag )
{
return sz - 1;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_size<T,sz>( array, tag() );
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_size<T,sz>( array, tag() );
}
} // namespace 'range_detail'

67
include/boost/range/detail/iterator.hpp Executable file → Normal file
View File

@ -12,6 +12,9 @@
#define BOOST_RANGE_DETAIL_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <boost/static_assert.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
@ -22,7 +25,13 @@ namespace boost
namespace range_detail
{
template< typename T >
struct range_iterator_;
struct range_iterator_ {
template< typename C >
struct pts
{
typedef int type;
};
};
template<>
struct range_iterator_<std_container_>
@ -30,7 +39,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type;
};
};
@ -40,61 +49,29 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_iterator_<array_>; // give up
template<>
struct range_iterator_<char_ptr_>
{
template< typename S >
struct range_iterator_<array_>
{
template< typename T >
struct pts
{
typedef char* type;
};
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t* type;
};
};
template<>
struct range_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
}
template< typename C >
class iterator_of
class range_mutable_iterator
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
typedef typename range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}

View File

@ -0,0 +1,931 @@
#ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP
#define BOOST_RANGE_DETAIL_MICROSOFT_HPP
// Boost.Range MFC/ATL Extension
//
// Copyright Shunsuke Sogame 2005-2006.
// 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)
// config
//
#include <boost/range/iterator.hpp>
#define BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1 1
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
#define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin
#define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end
#else
#define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
#define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin
#define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end
#endif
// yet another customization way
//
#include <boost/iterator/iterator_traits.hpp> // iterator_difference
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/detail/is_unary.hpp>
#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/size_type.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/utility/enable_if.hpp> // disable_if
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#include <boost/range/mutable_iterator.hpp>
#else
#include <iterator> // distance
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>
#endif
namespace boost { namespace range_detail_microsoft {
// customization point
//
template< class Tag >
struct customization;
template< class T >
struct customization_tag;
struct using_type_as_tag
{ };
// Topic:
// In fact, it is unnecessary for VC++.
// VC++'s behavior seems conforming, while GCC fails without this.
template< class Iterator, class T >
struct mutable_ :
disable_if< is_const<T>, Iterator >
{ };
// helpers
//
template< class Tag, class T >
struct customization_tag_of
{
typedef typename mpl::if_< is_same<using_type_as_tag, Tag>,
T,
Tag
>::type type;
};
template< class T >
struct customization_of
{
typedef typename remove_cv<T>::type bare_t;
typedef typename customization_tag<bare_t>::type tag_t;
typedef customization<tag_t> type;
};
template< class T >
struct mutable_iterator_of
{
typedef typename remove_cv<T>::type bare_t;
typedef typename customization_of<bare_t>::type cust_t;
typedef typename cust_t::template meta<bare_t>::mutable_iterator type;
};
template< class T >
struct const_iterator_of
{
typedef typename remove_cv<T>::type bare_t;
typedef typename customization_of<bare_t>::type cust_t;
typedef typename cust_t::template meta<bare_t>::const_iterator type;
};
template< class T >
struct size_type_of
{
typedef typename range_detail_microsoft::mutable_iterator_of<T>::type miter_t;
typedef typename iterator_difference<miter_t>::type type;
};
template< class T > inline
typename mutable_iterator_of<T>::type
begin_of(T& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template begin<typename mutable_iterator_of<T>::type>(x);
}
template< class T > inline
typename const_iterator_of<T>::type
begin_of(T const& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template begin<typename const_iterator_of<T>::type>(x);
}
template< class T > inline
typename mutable_iterator_of<T>::type
end_of(T& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template end<typename mutable_iterator_of<T>::type>(x);
}
template< class T > inline
typename const_iterator_of<T>::type
end_of(T const& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template end<typename const_iterator_of<T>::type>(x);
}
#if defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
template< class T > inline
typename size_type_of<T>::type
size_of(T const& x)
{
return std::distance(boost::begin(x), boost::end(x));
}
#endif
template< class Range >
struct compatible_mutable_iterator :
BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>
{ };
} } // namespace boost::range_detail_microsoft
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op, ~, NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op(r, data, elem) \
namespace elem { \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op, ~, NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op(r, data, elem) \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op(r, data, elem) \
:: elem \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(Tag, NamespaceList, Name) \
namespace boost { namespace range_detail_microsoft { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
} } \
\
namespace boost { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
} \
\
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) :: Name \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, Fullname) \
template< > \
struct customization_tag< Fullname > : \
customization_tag_of< Tag, Fullname > \
{ }; \
/**/
// metafunctions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(Fullname) \
template< > \
struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
range_detail_microsoft::mutable_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(Fullname) \
template< > \
struct range_const_iterator< Fullname > : \
range_detail_microsoft::const_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(Fullname) \
template< > \
struct range_size< Fullname > : \
range_detail_microsoft::size_type_of< Fullname > \
{ }; \
/**/
// functions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(Fullname) \
inline \
boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(Fullname) \
inline \
boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(Fullname) \
inline \
boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(Fullname) \
inline \
boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
/**/
#else
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
inline \
boost::range_detail_microsoft::size_type_of< Fullname >::type \
boost_range_size(Fullname const& x) \
{ \
return boost::range_detail_microsoft::size_of(x); \
} \
/**/
#endif
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(Tag, NamespaceList, Name, ParamSeqOrCount) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl( \
Tag, NamespaceList, Name, \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
BOOST_PP_IIF(BOOST_PP_IS_UNARY(ParamSeqOrCount), \
ParamSeqOrCount BOOST_PP_TUPLE_EAT(3), \
BOOST_PP_REPEAT \
)(ParamSeqOrCount, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op, ~) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op(z, n, _) \
(class) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl(Tag, NamespaceList, Name, ParamSeq) \
namespace boost { namespace range_detail_microsoft { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag( \
Tag, \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
} } \
\
namespace boost { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
\
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
} \
\
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq) \
BOOST_PP_SEQ_FOR_EACH_I(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op, ~, ParamSeq) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op(r, data, i, elem) \
BOOST_PP_COMMA_IF(i) elem BOOST_PP_CAT(T, i) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) \
:: Name < BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(ParamSeq), T) > \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag(Tag, Params, Fullname) \
template< Params > \
struct customization_tag< Fullname > : \
customization_tag_of< Tag, Fullname > \
{ }; \
/**/
// metafunctions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator(Params, Fullname) \
template< Params > \
struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
range_detail_microsoft::mutable_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator(Params, Fullname) \
template< Params > \
struct range_const_iterator< Fullname > : \
range_detail_microsoft::const_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type(Params, Fullname) \
template< Params > \
struct range_size< Fullname > : \
range_detail_microsoft::size_type_of< Fullname > \
{ }; \
/**/
// functions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
/**/
#else
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::size_type_of< Fullname >::type \
boost_range_size(Fullname const& x) \
{ \
return boost::range_detail_microsoft::size_of(x); \
} \
/**/
#endif
// list_iterator and helpers
//
#include <boost/assert.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
// POSITION's header is undocumented, so is NULL.
//
struct __POSITION; // incomplete, but used as just a pointer.
typedef __POSITION *POSITION;
namespace boost { namespace range_detail_microsoft {
template<
class ListT,
class Value,
class Reference,
class Traversal
>
struct list_iterator;
template<
class ListT,
class Value,
class Reference,
class Traversal
>
struct list_iterator_super
{
typedef typename mpl::if_< is_same<use_default, Reference>,
Value&,
Reference
>::type ref_t;
typedef typename mpl::if_< is_same<use_default, Traversal>,
bidirectional_traversal_tag,
Traversal
>::type trv_t;
typedef iterator_facade<
list_iterator<ListT, Value, Reference, Traversal>,
Value,
trv_t,
ref_t
> type;
};
template<
class ListT,
class Value,
class Reference = use_default,
class Traversal = use_default
>
struct list_iterator :
list_iterator_super<ListT, Value, Reference, Traversal>::type
{
private:
typedef list_iterator self_t;
typedef typename list_iterator_super<ListT, Value, Reference, Traversal>::type super_t;
typedef typename super_t::reference ref_t;
public:
explicit list_iterator()
{ }
explicit list_iterator(ListT& lst, POSITION pos) :
m_plst(boost::addressof(lst)), m_pos(pos)
{ }
template< class, class, class, class > friend struct list_iterator;
template< class ListT_, class Value_, class Reference_, class Traversal_>
list_iterator(list_iterator<ListT_, Value_, Reference_, Traversal_> const& other) :
m_plst(other.m_plst), m_pos(other.m_pos)
{ }
private:
ListT *m_plst;
POSITION m_pos;
friend class iterator_core_access;
ref_t dereference() const
{
BOOST_ASSERT(m_pos != 0 && "out of range");
return m_plst->GetAt(m_pos);
}
// A B C D x
// Head Tail NULL(0)
//
void increment()
{
BOOST_ASSERT(m_pos != 0 && "out of range");
m_plst->GetNext(m_pos);
}
void decrement()
{
if (m_pos == 0) {
m_pos = m_plst->GetTailPosition();
return;
}
m_plst->GetPrev(m_pos);
}
bool equal(self_t const& other) const
{
BOOST_ASSERT(m_plst == other.m_plst && "iterators incompatible");
return m_pos == other.m_pos;
}
};
// customization helpers
//
struct array_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
return x.GetData();
}
template< class Iterator, class X >
Iterator end(X& x)
{
return begin<Iterator>(x) + x.GetSize();
}
};
struct list_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
return Iterator(x, x.GetHeadPosition());
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(x, POSITION(0));
}
};
} } // namespace boost::range_detail_microsoft
// test
//
#if defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
#include <algorithm>
#include <iterator>
#include <vector>
#include <boost/concept_check.hpp>
#include <boost/next_prior.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/distance.hpp>
#include <boost/range/empty.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/mutable_iterator.hpp>
#include <boost/range/rbegin.hpp>
#include <boost/range/rend.hpp>
#include <boost/range/value_type.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace range_detail_microsoft {
template< class Range1, class Range2 >
bool test_equals(Range1 const& rng1, Range2 const& rng2)
{
return
boost::distance(rng1) == boost::distance(rng2) &&
std::equal(boost::begin(rng1), boost::end(rng1), boost::begin(rng2))
;
}
template< class AssocContainer, class PairT >
bool test_find_key_and_mapped(AssocContainer const& ac, PairT const& pa)
{
typedef typename boost::range_const_iterator<AssocContainer>::type iter_t;
for (iter_t it = boost::const_begin(ac), last = boost::const_end(ac); it != last; ++it) {
if (it->first == pa.first && it->second == pa.second)
return true;
}
return false;
}
// test functions
//
template< class Range >
bool test_emptiness(Range& )
{
bool result = true;
Range emptyRng;
result = result && boost::empty(emptyRng);
return result;
}
template< class Range >
bool test_trivial(Range& rng)
{
bool result = true;
// convertibility check
typedef typename range_const_iterator<Range>::type citer_t;
citer_t cit = boost::begin(rng);
(void)cit; // unused
// mutability check
typedef typename range_value<Range>::type val_t;
val_t v = *boost::begin(rng);
*boost::begin(rng) = v;
result = result && *boost::begin(rng) == v;
return result;
}
template< class Range >
bool test_forward(Range& rng)
{
boost::function_requires< ForwardRangeConcept<Range> >();
bool result = (test_trivial)(rng);
typedef typename range_value<Range>::type val_t;
std::vector<val_t> saved;
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
std::rotate(boost::begin(saved), boost::next(boost::begin(saved)), boost::end(saved));
std::rotate(boost::begin(rng), boost::next(boost::begin(rng)), boost::end(rng));
return result && (test_equals)(saved, rng);
};
template< class Range >
bool test_bidirectional(Range& rng)
{
boost::function_requires< BidirectionalRangeConcept<Range> >();
bool result = (test_forward)(rng);
typedef typename range_value<Range>::type val_t;
std::vector<val_t> saved;
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
result = result && (test_equals)(
boost::make_iterator_range(boost::rbegin(saved), boost::rend(saved)),
boost::make_iterator_range(boost::rbegin(rng), boost::rend(rng))
);
return result;
}
template< class Range >
bool test_random_access(Range& rng)
{
boost::function_requires< RandomAccessRangeConcept<Range> >();
bool result = (test_bidirectional)(rng);
typedef typename range_value<Range>::type val_t;
std::vector<val_t> saved;
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
std::sort(boost::begin(saved), boost::end(saved));
std::random_shuffle(boost::begin(rng), boost::end(rng));
std::sort(boost::begin(rng), boost::end(rng));
result = result && (test_equals)(rng, saved);
std::random_shuffle(boost::begin(rng), boost::end(rng));
std::stable_sort(boost::begin(rng), boost::end(rng));
result = result && (test_equals)(rng, saved);
std::random_shuffle(boost::begin(rng), boost::end(rng));
std::partial_sort(boost::begin(rng), boost::end(rng), boost::end(rng));
result = result && (test_equals)(rng, saved);
return result;
}
// initializer
//
template< class ArrayT, class SampleRange >
bool test_init_array(ArrayT& arr, SampleRange const& sample)
{
typedef typename range_const_iterator<SampleRange>::type iter_t;
typedef typename range_value<SampleRange>::type val_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
val_t v = *it; // works around ATL3 CSimpleArray
arr.Add(v);
}
return (test_equals)(arr, sample);
}
template< class ListT, class SampleRange >
bool test_init_list(ListT& lst, SampleRange const& sample)
{
typedef typename range_const_iterator<SampleRange>::type iter_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
lst.AddTail(*it);
}
return (test_equals)(lst, sample);
}
template< class StringT, class SampleRange >
bool test_init_string(StringT& str, SampleRange const& sample)
{
typedef typename range_const_iterator<SampleRange>::type iter_t;
typedef typename range_value<SampleRange>::type val_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
str += *it;
}
return (test_equals)(str, sample);
}
template< class MapT, class SampleMap >
bool test_init_map(MapT& map, SampleMap const& sample)
{
typedef typename range_const_iterator<SampleMap>::type iter_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
map.SetAt(it->first, it->second);
}
return boost::distance(map) == boost::distance(sample);
}
// metafunction test
//
template< class Range, class Iter >
struct test_mutable_iter :
boost::is_same< typename boost::BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>::type, Iter >
{ };
template< class Range, class Iter >
struct test_const_iter :
boost::is_same< typename boost::range_const_iterator<Range>::type, Iter >
{ };
} } // namespace boost::range_detail_microsoft
#endif // defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
#endif

View File

@ -0,0 +1,157 @@
// Boost.Range library
//
// Copyright Jonathan Turkanis 2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
#define BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
#include <boost/config.hpp> // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std.
#include <cstddef>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost
{
namespace range_detail
{
template< typename Case1 = mpl::true_,
typename Type1 = mpl::void_,
typename Case2 = mpl::true_,
typename Type2 = mpl::void_,
typename Case3 = mpl::true_,
typename Type3 = mpl::void_,
typename Case4 = mpl::true_,
typename Type4 = mpl::void_,
typename Case5 = mpl::true_,
typename Type5 = mpl::void_,
typename Case6 = mpl::true_,
typename Type6 = mpl::void_,
typename Case7 = mpl::true_,
typename Type7 = mpl::void_,
typename Case8 = mpl::true_,
typename Type8 = mpl::void_,
typename Case9 = mpl::true_,
typename Type9 = mpl::void_,
typename Case10 = mpl::true_,
typename Type10 = mpl::void_,
typename Case11 = mpl::true_,
typename Type11 = mpl::void_,
typename Case12 = mpl::true_,
typename Type12 = mpl::void_,
typename Case13 = mpl::true_,
typename Type13 = mpl::void_,
typename Case14 = mpl::true_,
typename Type14 = mpl::void_,
typename Case15 = mpl::true_,
typename Type15 = mpl::void_,
typename Case16 = mpl::true_,
typename Type16 = mpl::void_,
typename Case17 = mpl::true_,
typename Type17 = mpl::void_,
typename Case18 = mpl::true_,
typename Type18 = mpl::void_,
typename Case19 = mpl::true_,
typename Type19 = mpl::void_,
typename Case20 = mpl::true_,
typename Type20 = mpl::void_>
struct select {
typedef typename
mpl::eval_if<
Case1, mpl::identity<Type1>, mpl::eval_if<
Case2, mpl::identity<Type2>, mpl::eval_if<
Case3, mpl::identity<Type3>, mpl::eval_if<
Case4, mpl::identity<Type4>, mpl::eval_if<
Case5, mpl::identity<Type5>, mpl::eval_if<
Case6, mpl::identity<Type6>, mpl::eval_if<
Case7, mpl::identity<Type7>, mpl::eval_if<
Case8, mpl::identity<Type8>, mpl::eval_if<
Case9, mpl::identity<Type9>, mpl::if_<
Case10, Type10, mpl::void_ > > > > > > > > >
>::type result1;
typedef typename
mpl::eval_if<
Case11, mpl::identity<Type11>, mpl::eval_if<
Case12, mpl::identity<Type12>, mpl::eval_if<
Case13, mpl::identity<Type13>, mpl::eval_if<
Case14, mpl::identity<Type14>, mpl::eval_if<
Case15, mpl::identity<Type15>, mpl::eval_if<
Case16, mpl::identity<Type16>, mpl::eval_if<
Case17, mpl::identity<Type17>, mpl::eval_if<
Case18, mpl::identity<Type18>, mpl::eval_if<
Case19, mpl::identity<Type19>, mpl::if_<
Case20, Type20, mpl::void_ > > > > > > > > >
> result2;
typedef typename
mpl::eval_if<
is_same<result1, mpl::void_>,
result2,
mpl::identity<result1>
>::type type;
};
template<typename T>
struct remove_extent {
static T* ar;
BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0]));
typedef typename
select<
is_same<T, bool[size]>, bool,
is_same<T, char[size]>, char,
is_same<T, signed char[size]>, signed char,
is_same<T, unsigned char[size]>, unsigned char,
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
is_same<T, wchar_t[size]>, wchar_t,
#endif
is_same<T, short[size]>, short,
is_same<T, unsigned short[size]>, unsigned short,
is_same<T, int[size]>, int,
is_same<T, unsigned int[size]>, unsigned int,
is_same<T, long[size]>, long,
is_same<T, unsigned long[size]>, unsigned long,
is_same<T, float[size]>, float,
is_same<T, double[size]>, double,
is_same<T, long double[size]>, long double
>::type result1;
typedef typename
select<
is_same<T, const bool[size]>, const bool,
is_same<T, const char[size]>, const char,
is_same<T, const signed char[size]>, const signed char,
is_same<T, const unsigned char[size]>, const unsigned char,
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
is_same<T, const wchar_t[size]>, const wchar_t,
#endif
is_same<T, const short[size]>, const short,
is_same<T, const unsigned short[size]>, const unsigned short,
is_same<T, const int[size]>, const int,
is_same<T, const unsigned int[size]>, const unsigned int,
is_same<T, const long[size]>, const long,
is_same<T, const unsigned long[size]>, const unsigned long,
is_same<T, const float[size]>, const float,
is_same<T, const double[size]>, const double,
is_same<T, const long double[size]>, const long double
> result2;
typedef typename
mpl::eval_if<
is_same<result1, mpl::void_>,
result2,
mpl::identity<result1>
>::type type;
};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

20
include/boost/range/detail/sfinae.hpp Executable file → Normal file
View File

@ -28,32 +28,32 @@ namespace boost
// string
//////////////////////////////////////////////////////////////////////
yes_type is_string_impl( const char* );
yes_type is_string_impl( const wchar_t* );
yes_type is_string_impl( const char* const );
yes_type is_string_impl( const wchar_t* const );
no_type is_string_impl( ... );
template< std::size_t sz >
yes_type is_char_array_impl( char BOOST_ARRAY_REF[sz] );
yes_type is_char_array_impl( char BOOST_RANGE_ARRAY_REF()[sz] );
template< std::size_t sz >
yes_type is_char_array_impl( const char BOOST_ARRAY_REF[sz] );
yes_type is_char_array_impl( const char BOOST_RANGE_ARRAY_REF()[sz] );
no_type is_char_array_impl( ... );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( wchar_t BOOST_ARRAY_REF[sz] );
yes_type is_wchar_t_array_impl( wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( const wchar_t BOOST_ARRAY_REFx[sz] );
yes_type is_wchar_t_array_impl( const wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
no_type is_wchar_t_array_impl( ... );
yes_type is_char_ptr_impl( char* );
yes_type is_char_ptr_impl( char* const );
no_type is_char_ptr_impl( ... );
yes_type is_const_char_ptr_impl( const char* );
yes_type is_const_char_ptr_impl( const char* const );
no_type is_const_char_ptr_impl( ... );
yes_type is_wchar_t_ptr_impl( wchar_t* );
yes_type is_wchar_t_ptr_impl( wchar_t* const );
no_type is_wchar_t_ptr_impl( ... );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* const );
no_type is_const_wchar_t_ptr_impl( ... );
//////////////////////////////////////////////////////////////////////

65
include/boost/range/detail/size.hpp Executable file → Normal file
View File

@ -12,27 +12,35 @@
#ifndef BOOST_RANGE_DETAIL_SIZE_HPP
#define BOOST_RANGE_DETAIL_SIZE_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/common.hpp>
#include <iterator>
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# include <boost/range/detail/vc6/size.hpp>
#else
# include <boost/range/detail/implementation_help.hpp>
# include <boost/range/detail/size_type.hpp>
# include <boost/range/detail/common.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
# include <boost/range/detail/remove_extent.hpp>
# endif
# include <iterator>
namespace boost
{
namespace range_detail
{
template< typename T >
struct collection_size;
struct range_size_;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<std_container_>
struct range_size_<std_container_>
{
template< typename C >
static BOOST_CT_DEDUCED_TYPENAME C::size_type fun( const C& c )
static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
{
return c.size();
};
@ -43,10 +51,11 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<std_pair_>
struct range_size_<std_pair_>
{
template< typename P >
static BOOST_CT_DEDUCED_TYPENAME size_type_of<P>::type fun( const P& p )
static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type
fun( const P& p )
{
return std::distance( p.first, p.second );
}
@ -57,32 +66,40 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<array_>
struct range_size_<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return sz;
}
#else
template<typename T>
static std::size_t fun(T& t)
{
return remove_extent<T>::size;
}
#endif
};
template<>
struct collection_size<char_array_>
struct range_size_<char_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_size( array );
return boost::range_detail::array_size( boost_range_array );
}
};
template<>
struct collection_size<wchar_t_array_>
struct range_size_<wchar_t_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_size( array );
return boost::range_detail::array_size( boost_range_array );
}
};
@ -91,7 +108,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<char_ptr_>
struct range_size_<char_ptr_>
{
static std::size_t fun( const char* s )
{
@ -100,7 +117,7 @@ namespace boost
};
template<>
struct collection_size<const_char_ptr_>
struct range_size_<const_char_ptr_>
{
static std::size_t fun( const char* s )
{
@ -109,7 +126,7 @@ namespace boost
};
template<>
struct collection_size<wchar_t_ptr_>
struct range_size_<wchar_t_ptr_>
{
static std::size_t fun( const wchar_t* s )
{
@ -118,7 +135,7 @@ namespace boost
};
template<>
struct collection_size<const_wchar_t_ptr_>
struct range_size_<const_wchar_t_ptr_>
{
static std::size_t fun( const wchar_t* s )
{
@ -130,13 +147,13 @@ namespace boost
template< typename C >
BOOST_CT_DEDUCED_TYPENAME size_type_of<C>::type
BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type
size( const C& c )
{
return range_detail::collection_size< BOOST_CT_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
return range_detail::range_size_< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'
# endif
#endif

49
include/boost/range/detail/size_type.hpp Executable file → Normal file
View File

@ -30,7 +30,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME C::size_type type;
};
};
@ -54,54 +54,15 @@ namespace boost
};
};
template<>
struct range_size_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
}
template< typename C >
class size_type_of
class range_size
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
typedef typename range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
typedef typename range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}

6
include/boost/range/detail/sizer.hpp Executable file → Normal file
View File

@ -25,12 +25,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
char&
sizer( const T BOOST_ARRAY_REF[sz] )[sz];
char (& sizer( const T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz];
template< typename T, std::size_t sz >
char&
sizer( T BOOST_ARRAY_REF[sz] )[sz];
char (& sizer( T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz];
} // namespace 'boost'

View File

@ -0,0 +1,38 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_STR_TYPES_HPP
#define BOOST_RANGE_DETAIL_STR_TYPES_HPP
#include <boost/range/size_type.hpp>
#include <boost/range/iterator.hpp>
namespace boost
{
template< class T >
struct range_mutable_iterator<T*>
{
typedef T* type;
};
template< class T >
struct range_const_iterator<T*>
{
typedef const T* type;
};
template< class T >
struct range_size<T*>
{
typedef std::size_t type;
};
}
#endif

50
include/boost/range/detail/value_type.hpp Executable file → Normal file
View File

@ -12,6 +12,7 @@
#define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <boost/iterator/iterator_traits.hpp>
//////////////////////////////////////////////////////////////////////////////
@ -31,7 +32,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME C::value_type type;
};
};
@ -41,57 +42,24 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value< BOOST_CT_DEDUCED_TYPENAME P::first_type >::type type;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
};
};
template<>
struct range_value_type_<array_>; // give up
template<>
struct range_value_type_<char_ptr_>
{
template< typename S >
struct range_value_type_<array_>
{
template< typename T >
struct pts
{
typedef char type;
};
typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
};
};
template<>
struct range_value_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char type;
};
};
template<>
struct range_value_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t type;
};
};
template<>
struct range_value_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t type;
};
};
}
template< typename C >
class value_type_of
class range_value
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:

View File

@ -0,0 +1,170 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_VC6_END_HPP
#define BOOST_RANGE_DETAIL_VC6_END_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_container_>
{
template< typename C >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
fun( C& c )
{
return c.end();
};
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_pair_>
{
template< typename P >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
fun( const P& p )
{
return p.second;
}
};
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<array_>
{
template< typename T >
struct inner {
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
fun(T& t)
{
return t + remove_extent<T>::size;
}
};
};
template<>
struct range_end<char_array_>
{
template< typename T >
struct inner {
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
fun(T& t)
{
return t + remove_extent<T>::size;
}
};
};
template<>
struct range_end<wchar_t_array_>
{
template< typename T >
struct inner {
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
fun(T& t)
{
return t + remove_extent<T>::size;
}
};
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<char_ptr_>
{
template< typename T >
struct inner {
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
};
template<>
struct range_end<const_char_ptr_>
{
template< typename T >
struct inner {
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
};
template<>
struct range_end<wchar_t_ptr_>
{
template< typename T >
struct inner {
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
};
template<>
struct range_end<const_wchar_t_ptr_>
{
template< typename T >
struct inner {
static const wchar_t* fun( const wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
};
} // namespace 'range_detail'
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
end( C& c )
{
return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -0,0 +1,166 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_VC6_SIZE_HPP
#define BOOST_RANGE_DETAIL_VC6_SIZE_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <iterator>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_size_;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<std_container_>
{
template< typename C >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
{
return c.size();
};
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<std_pair_>
{
template< typename P >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type
fun( const P& p )
{
return std::distance( p.first, p.second );
}
};
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<array_>
{
template<typename T>
struct inner {
static std::size_t fun(T& t)
{
return remove_extent<T>::size;
}
};
};
template<>
struct range_size_<char_array_>
{
template<typename T>
struct inner {
static std::size_t fun(T& t)
{
return sizeof(T) / sizeof(T[0]);
}
};
};
template<>
struct range_size_<wchar_t_array_>
{
template<typename T>
struct inner {
static std::size_t fun(T& t)
{
return sizeof(T) / sizeof(T[0]);
}
};
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<char_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const char* s )
{
return boost::range_detail::str_size( s );
}
};
};
template<>
struct range_size_<const_char_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const char* s )
{
return boost::range_detail::str_size( s );
}
};
};
template<>
struct range_size_<wchar_t_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const wchar_t* s )
{
return boost::range_detail::str_size( s );
}
};
};
template<>
struct range_size_<const_wchar_t_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const wchar_t* s )
{
return boost::range_detail::str_size( s );
}
};
};
} // namespace 'range_detail'
template< typename C >
BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type
size( const C& c )
{
return range_detail::range_size_<range_detail::range<C>::type>::inner<C>::fun( c );
}
} // namespace 'boost'
#endif

88
include/boost/range/difference_type.hpp Executable file → Normal file
View File

@ -16,92 +16,14 @@
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/difference_type.hpp>
#else
#include <boost/range/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct difference_type_of
{
typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct difference_type_of< std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_difference<Iterator>::type type;
};
template< typename Iterator >
struct difference_type_of< const std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_difference<Iterator>::type type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct difference_type_of< T[sz] >
{
typedef std::ptrdiff_t type;
};
template< typename T, std::size_t sz >
struct difference_type_of< const T[sz] >
{
typedef std::ptrdiff_t type;
};
//////////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////////
template<>
struct difference_type_of< char* >
{
typedef std::ptrdiff_t type;
};
template<>
struct difference_type_of< wchar_t* >
{
typedef std::ptrdiff_t type;
};
template<>
struct difference_type_of< const char* >
{
typedef std::ptrdiff_t type;
};
template<>
struct difference_type_of< const wchar_t* >
{
typedef std::ptrdiff_t type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template< class T >
struct range_difference : iterator_difference< typename range_iterator<T>::type >
{ };
}
#endif

View File

@ -0,0 +1,34 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DISTANCE_HPP
#define BOOST_RANGE_DISTANCE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/difference_type.hpp>
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type
distance( const T& r )
{
return std::distance( boost::begin( r ), boost::end( r ) );
}
} // namespace 'boost'
#endif

38
include/boost/range/empty.hpp Executable file → Normal file
View File

@ -16,47 +16,19 @@
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/empty.hpp>
#else
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
namespace boost
{
namespace range
{
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template< typename C >
inline bool empty( const C& c )
{
return begin( c ) == end( c );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline bool empty( const char* s )
{
return s == 0 || s[0] == 0;
}
inline bool empty( const wchar_t* s )
{
return s == 0 || s[0] == 0;
}
} // namespace 'range'
using range::empty;
template< class T >
inline bool empty( const T& r )
{
return boost::begin( r ) == boost::end( r );
}
} // namepace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif

114
include/boost/range/end.hpp Executable file → Normal file
View File

@ -25,91 +25,107 @@
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
namespace boost
{
namespace range
namespace boost
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// default
// primary template
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type
end( const C& c )
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
range_end( C& c )
{
//
// If you get a compile-error here, it is most likely because
// you have not implemented range_begin() properly in
// the namespace of C
//
return c.end();
}
template< typename C >
inline BOOST_DEDUCED_TYPENAME iterator_of<C>::type
end( C& c )
{
return c.end();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator end( const std::pair<Iterator,Iterator>& p )
inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
{
return p.second;
}
template< typename Iterator >
inline Iterator end( std::pair<Iterator,Iterator>& p )
inline Iterator range_end( std::pair<Iterator,Iterator>& p )
{
return p.second;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline const T* end( const T (&array)[sz] )
inline const T* range_end( const T (&a)[sz] )
{
return range_detail::array_end( array );
return range_detail::array_end<T,sz>( a );
}
template< typename T, std::size_t sz >
inline T* end( T (&array)[sz] )
inline T* range_end( T (&a)[sz] )
{
return range_detail::array_end( array );
return range_detail::array_end<T,sz>( a );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline char* end( char* s )
{
return range_detail::str_end( s );
}
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
} // namespace 'range_detail'
#endif
inline wchar_t* end( wchar_t* s )
{
return range_detail::str_end( s );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_end( r );
}
inline const char* end( const char* s )
{
return range_detail::str_end( s );
}
inline const wchar_t* end( const wchar_t* s )
{
return range_detail::str_end( s );
}
} // namespace 'range'
using range::end;
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_end( r );
}
} // namespace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_end( const T& r )
{
return boost::end( r );
}
}
#endif

4
include/boost/range/functions.hpp Executable file → Normal file
View File

@ -1,6 +1,6 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@ -18,8 +18,10 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/range/distance.hpp>
#include <boost/range/empty.hpp>
#include <boost/range/rbegin.hpp>
#include <boost/range/rend.hpp>
#endif

118
include/boost/range/iterator.hpp Executable file → Normal file
View File

@ -11,94 +11,62 @@
#ifndef BOOST_RANGE_ITERATOR_HPP
#define BOOST_RANGE_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/iterator.hpp>
#else
#include <boost/iterator/iterator_traits.hpp>
#include <cstddef>
#include <utility>
#include <boost/range/mutable_iterator.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/mpl/eval_if.hpp>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
namespace range_detail_vc7_1
{
template< typename C, typename Sig = void(C) >
struct range_iterator
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
mpl::eval_if_c< is_const<C>::value,
range_const_iterator< typename remove_const<C>::type >,
range_mutable_iterator<C> >::type type;
};
template< typename C, typename T >
struct range_iterator< C, void(T[]) >
{
typedef T* type;
};
}
#endif
template< typename C >
struct iterator_of
struct range_iterator
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
typedef BOOST_RANGE_DEDUCED_TYPENAME
range_detail_vc7_1::range_iterator<C>::type type;
#else
typedef BOOST_RANGE_DEDUCED_TYPENAME
mpl::eval_if_c< is_const<C>::value,
range_const_iterator< typename remove_const<C>::type >,
range_mutable_iterator<C> >::type type;
#endif
};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct iterator_of< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
template< typename Iterator >
struct iterator_of< const std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct iterator_of< T[sz] >
{
typedef T* type;
};
template< typename T, std::size_t sz >
struct iterator_of< const T[sz] >
{
typedef const T* type;
};
//////////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////////
template<>
struct iterator_of< char* >
{
typedef char* type;
};
template<>
struct iterator_of< wchar_t* >
{
typedef wchar_t* type;
};
template<>
struct iterator_of< const char* >
{
typedef const char* type;
};
template<>
struct iterator_of< const wchar_t* >
{
typedef const wchar_t* type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

618
include/boost/range/iterator_range.hpp Executable file → Normal file
View File

@ -11,24 +11,99 @@
#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP
#define BOOST_RANGE_ITERATOR_RANGE_HPP
#include <boost/range/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( push )
#pragma warning( disable : 4996 )
#endif
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
#ifndef BOOST_OLD_IOSTREAMS
# if defined(__STL_CONFIG_H) && \
!defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
/**/
# define BOOST_OLD_IOSTREAMS
# endif
#endif // #ifndef BOOST_OLD_IOSTREAMS
#include <boost/assert.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/is_abstract.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/utility/enable_if.hpp>
#include <iterator>
#include <algorithm>
#include <ostream>
#ifndef _STLP_NO_IOSTREAMS
# ifndef BOOST_OLD_IOSTREAMS
# include <ostream>
# else
# include <ostream.h>
# endif
#endif // _STLP_NO_IOSTREAMS
#include <cstddef>
/*! \file
Defines the \c iterator_class and related functions.
\c iterator_range is a simple wrapper of iterator pair idiom. It provides
a rich subset of Container interface.
*/
namespace boost {
namespace boost
{
namespace iterator_range_detail
{
//
// The functions adl_begin and adl_end are implemented in a separate
// class for gcc-2.9x
//
template<typename IteratorT>
struct iterator_range_impl {
template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r )
{
return IteratorT( boost::begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
return IteratorT( boost::end( r ) );
}
};
template< class Left, class Right >
inline bool equal( const Left& l, const Right& r )
{
typedef BOOST_DEDUCED_TYPENAME boost::range_difference<Left>::type sz_type;
sz_type l_size = boost::distance( l ),
r_size = boost::distance( r );
if( l_size != r_size )
return false;
return std::equal( boost::begin(l), boost::end(l),
boost::begin(r) );
}
template< class Left, class Right >
inline bool less_than( const Left& l, const Right& r )
{
return std::lexicographical_compare( boost::begin(l),
boost::end(l),
boost::begin(r),
boost::end(r) );
}
struct range_tag { };
struct const_range_tag { };
}
// iterator range template class -----------------------------------------//
@ -52,17 +127,36 @@ namespace boost {
template<typename IteratorT>
class iterator_range
{
protected: // Used by sub_range
//! implementation class
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
public:
//! this type
typedef iterator_range<IteratorT> type;
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
//! Encapsulated value type
typedef BOOST_DEDUCED_TYPENAME boost::
typedef BOOST_DEDUCED_TYPENAME
iterator_value<IteratorT>::type value_type;
//! Difference type
typedef BOOST_DEDUCED_TYPENAME boost::
typedef BOOST_DEDUCED_TYPENAME
iterator_difference<IteratorT>::type difference_type;
//! Size type
typedef std::size_t size_type; // note: must be unsigned
//! This type
typedef iterator_range<IteratorT> this_type;
//! Refence type
//
// Needed because value-type is the same for
// const and non-const iterators
//
typedef BOOST_DEDUCED_TYPENAME
iterator_reference<IteratorT>::type reference;
//! const_iterator type
/*!
@ -73,161 +167,361 @@ namespace boost {
//! iterator type
typedef IteratorT iterator;
//! Default constructor
iterator_range() {}
private: // for return value of operator()()
typedef BOOST_DEDUCED_TYPENAME
boost::mpl::if_< boost::is_abstract<value_type>,
reference, value_type >::type abstract_value_type;
public:
iterator_range() : m_Begin( iterator() ), m_End( iterator() )
#ifndef NDEBUG
, singular( true )
#endif
{ }
//! Constructor from a pair of iterators
iterator_range( iterator Begin, iterator End ) :
m_Begin(Begin), m_End(End) {}
template< class Iterator >
iterator_range( Iterator Begin, Iterator End ) :
m_Begin(Begin), m_End(End)
#ifndef NDEBUG
, singular(false)
#endif
{}
//! Constructor from a Range
template< class Range >
iterator_range( const Range& r ) :
m_Begin( boost::begin( r ) ), m_End( boost::end( r ) ) {}
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
#ifndef NDEBUG
, singular(false)
#endif
{}
//! Constructor from a Range
template< class Range >
iterator_range( Range& r ) :
m_Begin( boost::begin( r ) ), m_End( boost::end( r ) ) {}
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
#ifndef NDEBUG
, singular(false)
#endif
{}
//! Copy constructor
iterator_range( const iterator_range& Other ) :
m_Begin(Other.begin()), m_End(Other.end()) {}
//! Constructor from a Range
template< class Range >
iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
#ifndef NDEBUG
, singular(false)
#endif
{}
//! Templated copy constructor
/*!
This constructor is provided to allow conversion between
const and mutable iterator instances of this class template
*/
template< typename OtherItT >
iterator_range( const iterator_range<OtherItT>& Other ) :
m_Begin(Other.begin()), m_End(Other.end()) {}
//! Constructor from a Range
template< class Range >
iterator_range( Range& r, iterator_range_detail::range_tag ) :
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
#ifndef NDEBUG
, singular(false)
#endif
{}
//! Assignment operator
iterator_range& operator=( const iterator_range& Other )
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
this_type& operator=( const this_type& r )
{
m_Begin=Other.begin(); m_End=Other.end();
m_Begin = r.begin();
m_End = r.end();
#ifndef NDEBUG
singular = r.singular;
#endif
return *this;
}
#endif
template< class Iterator >
iterator_range& operator=( const iterator_range<Iterator>& r )
{
m_Begin = r.begin();
m_End = r.end();
#ifndef NDEBUG
singular = r.is_singular();
#endif
return *this;
}
template< class ForwardRange >
iterator_range& operator=( ForwardRange& r )
{
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
#ifndef NDEBUG
singular = false;
#endif
return *this;
}
//! Assignment operator ( templated version )
template< typename OtherItT >
iterator_range& operator=( const iterator_range<OtherItT>& Other )
template< class ForwardRange >
iterator_range& operator=( const ForwardRange& r )
{
m_Begin=Other.begin(); m_End=Other.end();
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
#ifndef NDEBUG
singular = false;
#endif
return *this;
}
//! Comparison operator ( equal )
/*!
Compare operands for equality
*/
template< typename OtherItT >
bool operator==( const iterator_range<OtherItT>& Other ) const
{
return ! (*this != Other);
}
//! Comparison operator ( not-equal )
/*!
Compare operands for non-equality
*/
template< typename OtherItT >
bool operator!=( const iterator_range<OtherItT>& Other ) const
{
return m_Begin!=Other.begin() || m_End!=Other.end();
}
//! begin access
/*!
Retrieve the begin iterator
*/
IteratorT begin() const
{
BOOST_ASSERT( !is_singular() );
return m_Begin;
}
//! end access
/*!
Retrieve the end iterator
*/
IteratorT end() const
{
BOOST_ASSERT( !is_singular() );
return m_End;
}
//! Size of the range
/*!
Retrieve the size of the range
*/
size_type size() const
difference_type size() const
{
return std::distance( m_Begin, m_End );
BOOST_ASSERT( !is_singular() );
return m_End - m_Begin;
}
bool empty() const
{
BOOST_ASSERT( !is_singular() );
return m_Begin == m_End;
}
//! Swap
/*!
Swap two ranges
*/
void swap( iterator_range& Other )
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
operator bool() const
{
std::swap( m_Begin, Other.m_Begin );
std::swap( m_End, Other.m_End );
}
//! Safe bool conversion
/*!
Check whenever the range is empty.
Allows to use construction like this:
\code
iterator_range r;
if (!r)
{
...
}
\endcode
*/
return !empty();
}
#else
typedef iterator (iterator_range::*unspecified_bool_type) () const;
operator unspecified_bool_type() const
{
return empty() ? 0: &iterator_range::end;
}
/*
inline operator t_type() const
{
return make_tuple( m_Begin, m_End );
}*/
#endif
bool equal( const iterator_range& r ) const
{
BOOST_ASSERT( !is_singular() );
return m_Begin == r.m_Begin && m_End == r.m_End;
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
bool operator==( const iterator_range& r ) const
{
BOOST_ASSERT( !is_singular() );
return iterator_range_detail::equal( *this, r );
}
bool operator!=( const iterator_range& r ) const
{
BOOST_ASSERT( !is_singular() );
return !operator==(r);
}
bool operator<( const iterator_range& r ) const
{
BOOST_ASSERT( !is_singular() );
return iterator_range_detail::less_than( *this, r );
}
#endif
public: // convenience
reference front() const
{
BOOST_ASSERT( !empty() );
return *m_Begin;
}
reference back() const
{
BOOST_ASSERT( !empty() );
IteratorT last( m_End );
return *--last;
}
reference operator[]( difference_type at ) const
{
BOOST_ASSERT( at >= 0 && at < size() );
return m_Begin[at];
}
//
// When storing transform iterators, operator[]()
// fails because it returns by reference. Therefore
// operator()() is provided for these cases.
//
abstract_value_type operator()( difference_type at ) const
{
BOOST_ASSERT( at >= 0 && at < size() );
return m_Begin[at];
}
iterator_range& advance_begin( difference_type n )
{
BOOST_ASSERT( !is_singular() );
std::advance( m_Begin, n );
return *this;
}
iterator_range& advance_end( difference_type n )
{
BOOST_ASSERT( !is_singular() );
std::advance( m_End, n );
return *this;
}
private:
// begin and end iterators
IteratorT m_Begin;
IteratorT m_End;
#ifndef NDEBUG
bool singular;
#endif
public:
bool is_singular() const
{
#ifndef NDEBUG
return singular;
#else
return false;
#endif
}
protected:
//
// Allow subclasses an easy way to access the
// base type
//
typedef iterator_range iterator_range_;
};
// iterator range free-standing operators ---------------------------//
#ifndef _STLP_NO_IOSTREAMS
# ifndef BOOST_OLD_IOSTREAMS
//! iterator_range output operator
/*!
Output the range to an ostream. Elements are outputed
in a sequence without separators.
*/
template< typename IteratorT, typename Elem, typename Traits >
std::basic_ostream<Elem,Traits>& operator<<(
std::basic_ostream<Elem, Traits>& Os,
const iterator_range<IteratorT>& r )
inline std::basic_ostream<Elem,Traits>& operator<<(
std::basic_ostream<Elem, Traits>& Os,
const iterator_range<IteratorT>& r )
{
std::copy( begin(r), end(r), std::ostream_iterator<Elem>(Os));
std::copy( r.begin(), r.end(),
std::ostream_iterator< BOOST_DEDUCED_TYPENAME
iterator_value<IteratorT>::type,
Elem, Traits>(Os) );
return Os;
}
# else
//! iterator_range output operator
/*!
Output the range to an ostream. Elements are outputed
in a sequence without separators.
*/
template< typename IteratorT >
inline std::ostream& operator<<(
std::ostream& Os,
const iterator_range<IteratorT>& r )
{
std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os));
return Os;
}
# endif
#endif // _STLP_NO_IOSTREAMS
/////////////////////////////////////////////////////////////////////
// comparison operators
/////////////////////////////////////////////////////////////////////
template< class IteratorT, class ForwardRange >
inline bool operator==( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator!=( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator<( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::less_than( l, r );
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#else
template< class Iterator1T, class Iterator2T >
inline bool operator==( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator==( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::equal( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator!=( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator!=( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator<( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::less_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator<( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::less_than( l, r );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
// iterator range utilities -----------------------------------------//
//! iterator_range construct helper
@ -244,28 +538,101 @@ namespace boost {
{
return iterator_range<IteratorT>( Begin, End );
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
make_iterator_range( Range& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
( boost::begin( r ), boost::end( r ) );
}
#else
//! iterator_range construct helper
/*!
Construct an \c iterator_range from a \c Range containing the begin
and end iterators.
*/
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME iterator_of<Range>::type >
make_iterator_range( Range& r )
template< class ForwardRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
make_iterator_range( ForwardRange& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME iterator_of<Range>::type >
( r );
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
( r, iterator_range_detail::range_tag() );
}
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME const_iterator_of<Range>::type >
make_iterator_range( const Range& r )
template< class ForwardRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
make_iterator_range( const ForwardRange& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME const_iterator_of<Range>::type >
( r );
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
( r, iterator_range_detail::const_range_tag() );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace iterator_range_detail
{
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
make_range_impl( Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//
// Not worth the effort
//
//if( advance_begin == 0 && advance_end == 0 )
// return make_iterator_range( r );
//
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
new_begin = boost::begin( r ),
new_end = boost::end( r );
std::advance( new_begin, advance_begin );
std::advance( new_end, advance_end );
return make_iterator_range( new_begin, new_end );
}
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
make_iterator_range( Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
}
#else
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
make_iterator_range( Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
}
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
make_iterator_range( const Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//! copy a range into a sequence
/*!
Construct a new sequence of the specified type from the elements
@ -277,27 +644,16 @@ namespace boost {
template< typename SeqT, typename Range >
inline SeqT copy_range( const Range& r )
{
return SeqT( begin( r ), end( r ) );
}
//! transform a range into a sequence
/*!
Create a new sequence from the elements in the range, transformed
by a function
\param Range An input range
\param Func Transformation function
\return New sequence
*/
template< typename SeqT, typename Range, typename FuncT >
inline SeqT transform_range( const Range& r, FuncT Func )
{
SeqT Seq;
std::transform( begin( r ), end( r ), std::back_inserter(Seq), Func );
return Seq;
return SeqT( boost::begin( r ), boost::end( r ) );
}
} // namespace 'boost'
#undef BOOST_OLD_IOSTREAMS
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( pop )
#endif
#endif

View File

@ -8,21 +8,23 @@
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_TYPES_HPP
#define BOOST_RANGE_TYPES_HPP
#ifndef BOOST_RANGE_METAFUNCTIONS_HPP
#define BOOST_RANGE_METAFUNCTIONS_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/size_type.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/reverse_iterator.hpp>
#include <boost/range/const_reverse_iterator.hpp>
#include <boost/range/reverse_result_iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/size_type.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/category.hpp>
#include <boost/range/reference.hpp>
#include <boost/range/pointer.hpp>
#endif

984
include/boost/range/mfc.hpp Normal file
View File

@ -0,0 +1,984 @@
#ifndef BOOST_RANGE_MFC_HPP
#define BOOST_RANGE_MFC_HPP
// Boost.Range MFC Extension
//
// Copyright Shunsuke Sogame 2005-2006.
// 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)
// config
//
#include <afx.h> // _MFC_VER
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
#if (_MFC_VER < 0x0700) // dubious
#define BOOST_RANGE_MFC_NO_CPAIR
#endif
#endif
#if !defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
#if (_MFC_VER < 0x0700) // dubious
#define BOOST_RANGE_MFC_HAS_LEGACY_STRING
#endif
#endif
// A const collection of old MFC doesn't return const reference.
//
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
#if (_MFC_VER < 0x0700) // dubious
#define BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF
#endif
#endif
// forward declarations
//
template< class Type, class ArgType >
class CArray;
template< class Type, class ArgType >
class CList;
template< class Key, class ArgKey, class Mapped, class ArgMapped >
class CMap;
template< class BaseClass, class PtrType >
class CTypedPtrArray;
template< class BaseClass, class PtrType >
class CTypedPtrList;
template< class BaseClass, class KeyPtrType, class MappedPtrType >
class CTypedPtrMap;
// extended customizations
//
#include <cstddef> // ptrdiff_t
#include <utility> // pair
#include <boost/assert.hpp>
#include <boost/mpl/if.hpp>
#include <boost/range/atl.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/detail/microsoft.hpp>
#include <boost/range/end.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/utility/addressof.hpp>
#include <afx.h> // legacy CString
#include <afxcoll.h> // CXXXArray, CXXXList, CMapXXXToXXX
#include <tchar.h>
namespace boost { namespace range_detail_microsoft {
// mfc_ptr_array_iterator
//
// 'void **' is not convertible to 'void const **',
// so we define...
//
template< class ArrayT, class PtrType >
struct mfc_ptr_array_iterator;
template< class ArrayT, class PtrType >
struct mfc_ptr_array_iterator_super
{
typedef iterator_adaptor<
mfc_ptr_array_iterator<ArrayT, PtrType>,
std::ptrdiff_t, // Base!
PtrType, // Value
random_access_traversal_tag,
use_default,
std::ptrdiff_t // Difference
> type;
};
template< class ArrayT, class PtrType >
struct mfc_ptr_array_iterator :
mfc_ptr_array_iterator_super<ArrayT, PtrType>::type
{
private:
typedef mfc_ptr_array_iterator self_t;
typedef typename mfc_ptr_array_iterator_super<ArrayT, PtrType>::type super_t;
typedef typename super_t::reference ref_t;
public:
explicit mfc_ptr_array_iterator()
{ }
explicit mfc_ptr_array_iterator(ArrayT& arr, INT_PTR index) :
super_t(index), m_parr(boost::addressof(arr))
{ }
template< class, class > friend struct mfc_ptr_array_iterator;
template< class ArrayT_, class PtrType_ >
mfc_ptr_array_iterator(mfc_ptr_array_iterator<ArrayT_, PtrType_> const& other) :
super_t(other.base()), m_parr(other.m_parr)
{ }
private:
ArrayT *m_parr;
friend class iterator_core_access;
ref_t dereference() const
{
BOOST_ASSERT(0 <= this->base() && this->base() < m_parr->GetSize() && "out of range");
return *( m_parr->GetData() + this->base() );
}
bool equal(self_t const& other) const
{
BOOST_ASSERT(m_parr == other.m_parr && "iterators incompatible");
return this->base() == other.base();
}
};
struct mfc_ptr_array_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
return Iterator(x, 0);
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(x, x.GetSize());
}
};
// arrays
//
template< >
struct customization< ::CByteArray > :
array_functions
{
template< class X >
struct meta
{
typedef BYTE val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< >
struct customization< ::CDWordArray > :
array_functions
{
template< class X >
struct meta
{
typedef DWORD val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< >
struct customization< ::CObArray > :
mfc_ptr_array_functions
{
template< class X >
struct meta
{
typedef mfc_ptr_array_iterator<X, CObject *> mutable_iterator;
typedef mfc_ptr_array_iterator<X const, CObject const *> const_iterator;
};
};
template< >
struct customization< ::CPtrArray > :
mfc_ptr_array_functions
{
template< class X >
struct meta
{
typedef mfc_ptr_array_iterator<X, void *> mutable_iterator;
typedef mfc_ptr_array_iterator<X const, void const *> const_iterator;
};
};
template< >
struct customization< ::CStringArray > :
array_functions
{
template< class X >
struct meta
{
typedef ::CString val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< >
struct customization< ::CUIntArray > :
array_functions
{
template< class X >
struct meta
{
typedef UINT val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< >
struct customization< ::CWordArray > :
array_functions
{
template< class X >
struct meta
{
typedef WORD val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
// lists
//
template< >
struct customization< ::CObList > :
list_functions
{
template< class X >
struct meta
{
typedef list_iterator<X, ::CObject *> mutable_iterator;
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
typedef list_iterator<X const, ::CObject const *> const_iterator;
#else
typedef list_iterator<X const, ::CObject const * const, ::CObject const * const> const_iterator;
#endif
};
};
template< >
struct customization< ::CPtrList > :
list_functions
{
template< class X >
struct meta
{
typedef list_iterator<X, void *> mutable_iterator;
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
typedef list_iterator<X const, void const *> const_iterator;
#else
typedef list_iterator<X const, void const * const, void const * const> const_iterator;
#endif
};
};
template< >
struct customization< ::CStringList > :
list_functions
{
template< class X >
struct meta
{
typedef ::CString val_t;
typedef list_iterator<X, val_t> mutable_iterator;
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
typedef list_iterator<X const, val_t const> const_iterator;
#else
typedef list_iterator<X const, val_t const, val_t const> const_iterator;
#endif
};
};
// mfc_map_iterator
//
template< class MapT, class KeyT, class MappedT >
struct mfc_map_iterator;
template< class MapT, class KeyT, class MappedT >
struct mfc_map_iterator_super
{
typedef iterator_facade<
mfc_map_iterator<MapT, KeyT, MappedT>,
std::pair<KeyT, MappedT>,
forward_traversal_tag,
std::pair<KeyT, MappedT> const
> type;
};
template< class MapT, class KeyT, class MappedT >
struct mfc_map_iterator :
mfc_map_iterator_super<MapT, KeyT, MappedT>::type
{
private:
typedef mfc_map_iterator self_t;
typedef typename mfc_map_iterator_super<MapT, KeyT, MappedT>::type super_t;
typedef typename super_t::reference ref_t;
public:
explicit mfc_map_iterator()
{ }
explicit mfc_map_iterator(MapT const& map, POSITION pos) :
m_pmap(boost::addressof(map)), m_posNext(pos)
{
increment();
}
explicit mfc_map_iterator(MapT const& map) :
m_pmap(&map), m_pos(0) // end iterator
{ }
template< class, class, class > friend struct mfc_map_iterator;
template< class MapT_, class KeyT_, class MappedT_>
mfc_map_iterator(mfc_map_iterator<MapT_, KeyT_, MappedT_> const& other) :
m_pmap(other.m_pmap),
m_pos(other.m_pos), m_posNext(other.m_posNext),
m_key(other.m_key), m_mapped(other.m_mapped)
{ }
private:
MapT const *m_pmap;
POSITION m_pos, m_posNext;
KeyT m_key; MappedT m_mapped;
friend class iterator_core_access;
ref_t dereference() const
{
BOOST_ASSERT(m_pos != 0 && "out of range");
return std::make_pair(m_key, m_mapped);
}
void increment()
{
BOOST_ASSERT(m_pos != 0 && "out of range");
if (m_posNext == 0) {
m_pos = 0;
return;
}
m_pos = m_posNext;
m_pmap->GetNextAssoc(m_posNext, m_key, m_mapped);
}
bool equal(self_t const& other) const
{
BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
return m_pos == other.m_pos;
}
};
struct mfc_map_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
return Iterator(x, x.GetStartPosition());
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(x);
}
};
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
// mfc_cpair_map_iterator
//
// used by ::CMap and ::CMapStringToString
//
template< class MapT, class PairT >
struct mfc_cpair_map_iterator;
template< class MapT, class PairT >
struct mfc_pget_map_iterator_super
{
typedef iterator_facade<
mfc_cpair_map_iterator<MapT, PairT>,
PairT,
forward_traversal_tag
> type;
};
template< class MapT, class PairT >
struct mfc_cpair_map_iterator :
mfc_pget_map_iterator_super<MapT, PairT>::type
{
private:
typedef mfc_cpair_map_iterator self_t;
typedef typename mfc_pget_map_iterator_super<MapT, PairT>::type super_t;
typedef typename super_t::reference ref_t;
public:
explicit mfc_cpair_map_iterator()
{ }
explicit mfc_cpair_map_iterator(MapT& map, PairT *pp) :
m_pmap(boost::addressof(map)), m_pp(pp)
{ }
template< class, class > friend struct mfc_cpair_map_iterator;
template< class MapT_, class PairT_>
mfc_cpair_map_iterator(mfc_cpair_map_iterator<MapT_, PairT_> const& other) :
m_pmap(other.m_pmap), m_pp(other.m_pp)
{ }
private:
MapT *m_pmap;
PairT *m_pp;
friend class iterator_core_access;
ref_t dereference() const
{
BOOST_ASSERT(m_pp != 0 && "out of range");
return *m_pp;
}
void increment()
{
BOOST_ASSERT(m_pp != 0 && "out of range");
m_pp = m_pmap->PGetNextAssoc(m_pp);
}
bool equal(self_t const& other) const
{
BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
return m_pp == other.m_pp;
}
};
struct mfc_cpair_map_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
// Workaround:
// Assertion fails if empty.
// MFC document is wrong.
#if !defined(NDEBUG)
if (x.GetCount() == 0)
return Iterator(x, 0);
#endif
return Iterator(x, x.PGetFirstAssoc());
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(x, 0);
}
};
#endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)
// maps
//
template< >
struct customization< ::CMapPtrToWord > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef void *key_t;
typedef WORD mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
template< >
struct customization< ::CMapPtrToPtr > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef void *key_t;
typedef void *mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
template< >
struct customization< ::CMapStringToOb > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef ::CString key_t;
typedef ::CObject *mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
template< >
struct customization< ::CMapStringToPtr > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef ::CString key_t;
typedef void *mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
template< >
struct customization< ::CMapStringToString > :
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
mfc_cpair_map_functions
#else
mfc_map_functions
#endif
{
template< class X >
struct meta
{
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
typedef typename X::CPair pair_t;
typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
#else
typedef ::CString key_t;
typedef ::CString mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
#endif
};
};
template< >
struct customization< ::CMapWordToOb > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef WORD key_t;
typedef ::CObject *mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
template< >
struct customization< ::CMapWordToPtr > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef WORD key_t;
typedef void *mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
// templates
//
template< class Type, class ArgType >
struct customization< ::CArray<Type, ArgType> > :
array_functions
{
template< class X >
struct meta
{
typedef Type val_t;
typedef val_t *mutable_iterator;
typedef val_t const *const_iterator;
};
};
template< class Type, class ArgType >
struct customization< ::CList<Type, ArgType> > :
list_functions
{
template< class X >
struct meta
{
typedef Type val_t;
typedef list_iterator<X, val_t> mutable_iterator;
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
typedef list_iterator<X const, val_t const> const_iterator;
#else
typedef list_iterator<X const, val_t const, val_t const> const_iterator;
#endif
};
};
template< class Key, class ArgKey, class Mapped, class ArgMapped >
struct customization< ::CMap<Key, ArgKey, Mapped, ArgMapped> > :
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
mfc_cpair_map_functions
#else
mfc_map_functions
#endif
{
template< class X >
struct meta
{
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
typedef typename X::CPair pair_t;
typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
#else
typedef Key key_t;
typedef Mapped mapped_t;
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
typedef mutable_iterator const_iterator;
#endif
};
};
template< class BaseClass, class PtrType >
struct customization< ::CTypedPtrArray<BaseClass, PtrType> >
{
template< class X >
struct fun
{
typedef typename remove_pointer<PtrType>::type val_t;
typedef typename mpl::if_< is_const<X>,
val_t const,
val_t
>::type val_t_;
typedef val_t_ * const result_type;
template< class PtrType_ >
result_type operator()(PtrType_ p) const
{
return static_cast<result_type>(p);
}
};
template< class X >
struct meta
{
typedef typename compatible_mutable_iterator<BaseClass>::type miter_t;
typedef typename range_const_iterator<BaseClass>::type citer_t;
typedef transform_iterator<fun<X>, miter_t> mutable_iterator;
typedef transform_iterator<fun<X const>, citer_t> const_iterator;
};
template< class Iterator, class X >
Iterator begin(X& x)
{
return Iterator(boost::begin<BaseClass>(x), fun<X>());
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(boost::end<BaseClass>(x), fun<X>());
}
};
template< class BaseClass, class PtrType >
struct customization< ::CTypedPtrList<BaseClass, PtrType> > :
list_functions
{
template< class X >
struct meta
{
typedef typename remove_pointer<PtrType>::type val_t;
// not l-value
typedef list_iterator<X, val_t * const, val_t * const> mutable_iterator;
typedef list_iterator<X const, val_t const * const, val_t const * const> const_iterator;
};
};
template< class BaseClass, class KeyPtrType, class MappedPtrType >
struct customization< ::CTypedPtrMap<BaseClass, KeyPtrType, MappedPtrType> > :
mfc_map_functions
{
template< class X >
struct meta
{
typedef mfc_map_iterator<X, KeyPtrType, MappedPtrType> mutable_iterator;
typedef mutable_iterator const_iterator;
};
};
// strings
//
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
template< >
struct customization< ::CString >
{
template< class X >
struct meta
{
// LPTSTR/LPCTSTR is not always defined in <tchar.h>.
typedef TCHAR *mutable_iterator;
typedef TCHAR const *const_iterator;
};
template< class Iterator, class X >
typename mutable_<Iterator, X>::type begin(X& x)
{
return x.GetBuffer(0);
}
template< class Iterator, class X >
Iterator begin(X const& x)
{
return x;
}
template< class Iterator, class X >
Iterator end(X& x)
{
return begin<Iterator>(x) + x.GetLength();
}
};
#endif // defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
} } // namespace boost::range_detail_microsoft
// range customizations
//
// arrays
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CByteArray
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CDWordArray
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CStringArray
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CUIntArray
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CWordArray
)
// lists
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CObList
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CPtrList
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CStringList
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CObArray
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CPtrArray
)
// maps
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapPtrToWord
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapPtrToPtr
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapStringToOb
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapStringToPtr
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapStringToString
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapWordToOb
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMapWordToPtr
)
// templates
//
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CArray, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CList, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CMap, 4
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CTypedPtrArray, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CTypedPtrList, 2
)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CTypedPtrMap, 3
)
// strings
//
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
boost::range_detail_microsoft::using_type_as_tag,
BOOST_PP_NIL, CString
)
#endif
#endif

View File

@ -0,0 +1,64 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_MUTABLE_ITERATOR_HPP
#define BOOST_RANGE_MUTABLE_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/iterator.hpp>
#else
#include <boost/iterator/iterator_traits.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_mutable_iterator
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_mutable_iterator< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_mutable_iterator< T[sz] >
{
typedef T* type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View File

@ -0,0 +1,29 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_POINTER_TYPE_HPP
#define BOOST_RANGE_POINTER_TYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_pointer : iterator_pointer< typename range_iterator<T>::type >
{ };
}
#endif

34
include/boost/range/rbegin.hpp Executable file → Normal file
View File

@ -17,25 +17,49 @@
#include <boost/range/end.hpp>
#include <boost/range/reverse_iterator.hpp>
#include <boost/range/const_reverse_iterator.hpp>
namespace boost
{
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class C >
inline BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rbegin( C& c )
{
return BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type( end( c ) );
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::end( c ) );
}
#else
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rbegin( C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
iter_type;
return iter_type( boost::end( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
rbegin( const C& c )
{
return BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type( end( c ) );
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
iter_type;
return iter_type( boost::end( c ) );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
const_rbegin( const T& r )
{
return boost::rbegin( r );
}
} // namespace 'boost'
#endif

View File

@ -0,0 +1,29 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_REFERENCE_TYPE_HPP
#define BOOST_RANGE_REFERENCE_TYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_reference : iterator_reference< typename range_iterator<T>::type >
{ };
}
#endif

34
include/boost/range/rend.hpp Executable file → Normal file
View File

@ -17,25 +17,49 @@
#include <boost/range/begin.hpp>
#include <boost/range/reverse_iterator.hpp>
#include <boost/range/const_reverse_iterator.hpp>
namespace boost
{
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class C >
inline BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rend( C& c )
{
return BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type( begin( c ) );
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::begin( c ) );
}
#else
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rend( C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
iter_type;
return iter_type( boost::begin( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
rend( const C& c )
{
return BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type( begin( c ) );
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
iter_type;
return iter_type( boost::begin( c ) );
}
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
const_rend( const T& r )
{
return boost::rend( r );
}
} // namespace 'boost'
#endif

20
include/boost/range/result_iterator.hpp Executable file → Normal file
View File

@ -15,29 +15,19 @@
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/if.hpp>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
//
// This interface is deprecated, use range_iterator<T>
//
template< typename C >
struct result_iterator_of
{
typedef BOOST_CT_DEDUCED_TYPENAME
mpl::if_< BOOST_DEDUCED_TYPENAME is_const<C>::type,
BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type,
BOOST_DEDUCED_TYPENAME iterator_of<C>::type >::type type;
};
struct range_result_iterator : range_iterator<C>
{ };
} // namespace boost
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

4
include/boost/range/reverse_iterator.hpp Executable file → Normal file
View File

@ -27,10 +27,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct reverse_iterator_of
struct range_reverse_iterator
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME iterator_of<C>::type > type;
BOOST_DEDUCED_TYPENAME range_iterator<C>::type > type;
};

19
include/boost/range/reverse_result_iterator.hpp Executable file → Normal file
View File

@ -15,25 +15,18 @@
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/range/reverse_iterator.hpp>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
//
// This interface is deprecated, use range_reverse_iterator<T>
//
template< typename C >
struct reverse_result_iterator_of
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type > type;
};
struct range_reverse_result_iterator : range_reverse_iterator<C>
{ };
} // namespace boost
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

80
include/boost/range/size.hpp Executable file → Normal file
View File

@ -15,78 +15,22 @@
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/assert.hpp>
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/size.hpp>
#else
#include <boost/range/detail/implementation_help.hpp>
#include <cstddef>
#include <iterator>
#include <utility>
namespace boost {
namespace range
namespace boost
{
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_CT_DEDUCED_TYPENAME C::size_type
size( const C& c )
{
return c.size();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline std::size_t size( const std::pair<Iterator,Iterator>& p )
{
return std::distance( p.first, p.second );
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline std::size_t size( const T (&array)[sz] )
{
return range_detail::array_size( array );
}
template< typename T, std::size_t sz >
inline std::size_t size( T (&array)[sz] )
{
return range_detail::array_size( array );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline std::size_t size( const char* s )
{
return range_detail::str_size( s );
}
inline std::size_t size( const wchar_t* s )
{
return range_detail::str_size( s );
}
} // namespace 'range'
using range::size;
template< class T >
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type size( const T& r )
{
BOOST_ASSERT( (boost::end( r ) - boost::begin( r )) >= 0 &&
"reachability invariant broken!" );
return boost::end( r ) - boost::begin( r );
}
} // namespace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif

105
include/boost/range/size_type.hpp Executable file → Normal file
View File

@ -21,83 +21,58 @@
#include <boost/range/detail/size_type.hpp>
#else
#include <boost/type_traits/remove_const.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
namespace detail
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct size_type_of
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
template< typename C >
struct range_size
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct size_type_of< std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct size_type_of< const std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
template< typename Iterator >
struct range_size< std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_size< T[sz] >
{
typedef std::size_t type;
};
}
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct size_type_of< T[sz] >
{
typedef std::size_t type;
};
template< typename T, std::size_t sz >
struct size_type_of< const T[sz] >
{
typedef std::size_t type;
};
//////////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////////
template<>
struct size_type_of< char* >
{
typedef std::size_t type;
};
template<>
struct size_type_of< wchar_t* >
{
typedef std::size_t type;
};
template<>
struct size_type_of< const char* >
{
typedef std::size_t type;
};
template<>
struct size_type_of< const wchar_t* >
{
typedef std::size_t type;
};
template< class T >
struct range_size :
detail::range_size<T>
{ };
template< class T >
struct range_size<const T > : range_size<T>
{ };
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

193
include/boost/range/sub_range.hpp Executable file → Normal file
View File

@ -11,38 +11,73 @@
#ifndef BOOST_RANGE_SUB_RANGE_HPP
#define BOOST_RANGE_SUB_RANGE_HPP
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( push )
#pragma warning( disable : 4996 )
#endif
#include <boost/detail/workaround.hpp>
#include <boost/range/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/reverse_result_iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/size_type.hpp>
#include <boost/range/difference_type.hpp>
//#include <boost/range/rbegin.hpp>
//#include <boost/range/rend.hpp>
#include <boost/assert.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost
{
template< class Range >
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type >
template< class ForwardRange >
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
{
typedef BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type iterator_t;
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
typedef iterator_range< iterator_t > base;
typedef BOOST_DEDUCED_TYPENAME base::impl impl;
public:
using base::iterator;
using base::const_iterator;
using base::value_type;
typedef BOOST_DEDUCED_TYPENAME difference_type_of<Range>::type difference_type;
typedef BOOST_DEDUCED_TYPENAME size_type_of<Range>::type size_type;
typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type value_type;
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator;
typedef BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type const_iterator;
typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
typedef BOOST_DEDUCED_TYPENAME base::reference reference;
public: // for return value of front/back
typedef BOOST_DEDUCED_TYPENAME
boost::mpl::if_< boost::is_reference<reference>,
const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&,
reference >::type const_reference;
public:
template< class Range2 >
sub_range( Range2& r ) : base( r )
sub_range() : base()
{ }
template< class Range2 >
sub_range( const Range2& r ) : base( r )
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
sub_range( const sub_range& r )
: base( static_cast<const base&>( r ) )
{ }
#endif
template< class ForwardRange2 >
sub_range( ForwardRange2& r ) :
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
base( impl::adl_begin( r ), impl::adl_end( r ) )
#else
base( r )
#endif
{ }
template< class ForwardRange2 >
sub_range( const ForwardRange2& r ) :
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
base( impl::adl_begin( r ), impl::adl_end( r ) )
#else
base( r )
#endif
{ }
template< class Iter >
@ -50,77 +85,95 @@ namespace boost
base( first, last )
{ }
template< class Range2 >
sub_range& operator=( Range2& r )
template< class ForwardRange2 >
sub_range& operator=( ForwardRange2& r )
{
base::operator=( r );
return *this;
}
template< class Range2 >
sub_range& operator=( const Range2& r )
template< class ForwardRange2 >
sub_range& operator=( const ForwardRange2& r )
{
base::operator=( r );
return *this;
}
sub_range& operator=( const sub_range& r )
{
base::operator=( static_cast<const base&>(r) );
return *this;
}
size_type size() const
public:
iterator begin() { return base::begin(); }
const_iterator begin() const { return base::begin(); }
iterator end() { return base::end(); }
const_iterator end() const { return base::end(); }
difference_type size() const { return base::size(); }
public: // convenience
reference front()
{
//
// performance discontinuity problem!!
//
return base::size();
return base::front();
}
const_reference front() const
{
return base::front();
}
reference back()
{
return base::back();
}
const_reference back() const
{
return base::back();
}
reference operator[]( difference_type sz )
{
return base::operator[](sz);
}
const_reference operator[]( difference_type sz ) const
{
return base::operator[](sz);
}
};
/*
template< class Range >
class reverse_sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME reverse_result_iterator_of<Range>::type >
template< class ForwardRange, class ForwardRange2 >
inline bool operator==( const sub_range<ForwardRange>& l,
const sub_range<ForwardRange2>& r )
{
typedef BOOST_DEDUCED_TYPENAME reverse_result_iterator_of<Range>::type
iterator_t;
typedef iterator_range<iterator_t> base;
public:
using base::iterator;
using base::const_iterator;
using base::value_type;
using base::difference_type;
using base::size_type;
public:
template< class Range2 >
reverse_sub_range( Range2& r ) : base( rbegin( r ), rend( r ) )
{ }
template< class Range2 >
reverse_sub_range( const Range2& r ) : base( rbegin( r ), rend( r ) )
{ }
return iterator_range_detail::equal( l, r );
}
template< class Iter >
reverse_sub_range( Iter first, Iter last ) :
base( iterator_t( last ), iterator_t( first ) )
{ }
template< class ForwardRange, class ForwardRange2 >
inline bool operator!=( const sub_range<ForwardRange>& l,
const sub_range<ForwardRange2>& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class ForwardRange, class ForwardRange2 >
inline bool operator<( const sub_range<ForwardRange>& l,
const sub_range<ForwardRange2>& r )
{
return iterator_range_detail::less_than( l, r );
}
template< class Range2 >
sub_range& operator=( Range2& r )
{
base::operator=( r );
return *this;
}
template< class Range2 >
sub_range& operator=( const Range2& r )
{
base::operator=( r );
return *this;
}
};
*/
} // namespace 'boost'
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( pop )
#endif
#endif

90
include/boost/range/value_type.hpp Executable file → Normal file
View File

@ -16,93 +16,19 @@
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/value_type.hpp>
#else
//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//#include <boost/range/detail/value_type.hpp>
//#else
#include <boost/iterator/iterator_traits.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct value_type_of
{
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct value_type_of< std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_value<Iterator>::type type;
};
template< typename Iterator >
struct value_type_of< const std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_value<Iterator>::type type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct value_type_of< T[sz] >
{
typedef T type;
};
template< typename T, std::size_t sz >
struct value_type_of< const T[sz] >
{
typedef const T type;
};
//////////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////////
template<>
struct value_type_of< char* >
{
typedef char type;
};
template<>
struct value_type_of< wchar_t* >
{
typedef wchar_t type;
};
template<>
struct value_type_of< const char* >
{
typedef const char type;
};
template<>
struct value_type_of< const wchar_t* >
{
typedef const wchar_t type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template< class T >
struct range_value : iterator_value< typename range_iterator<T>::type >
{ };
}
#endif

82
index.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Documentation </title>
<link rel="stylesheet" href="doc/style.css" type="text/css">
</head>
<body>
<table border="0" >
<tr>
<td ><img src="../../boost.png" border="0" ></td>
<td >
<h1 align="center">Range Library</h1>
</td>
</tr>
</table>
<p>
Copyright <20> 2003-2007 Thorsten Ottosen
</p>
<p>
Use, modification and distribution is subject to the Boost Software License, Version 1.0
(see <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>).
</p>
<h1>Overview</h1>
<p>
Boost.Range is a collection of concepts and utilities that are particularly
useful for specifying and implementing generic algorithms. The documentation
consists of the following sections:
</p>
<ul>
<li> <a href="doc/intro.html">Introduction </a></code>
<li><a href="doc/range.html">Range concepts:</a>
<ul>
<li> <a href="doc/range.html#single_pass_range">SinglePassRange</a>
<li> <a href="doc/range.html#forward_range">ForwardRange</a>
<li> <a href="doc/range.html#bidirectional_range">BidirectionalRange</a>
<li> <a href="doc/range.html#random_access_range">RandomAccessRange</a> </ul>
<li> <a href="doc/boost_range.html">Reference</a>
<li> <a href="doc/utility_class.html"> Utilities:</a>
<ul>
<li> Class <a href="doc/utility_class.html#iter_range"><code>iterator_range</code></a>
<li> Class <a href="doc/utility_class.html#sub_range"><code>sub_range</code></a> </ul>
<li> <a href="doc/style.html">Terminology and style guidelines </a>
<li><a href="doc/headers.html">Headers</a> </li>
<li><a href="doc/examples.html">Examples</a>
<li><a href="doc/mfc_atl.html">MFC/ATL mapping (courtesy of Shunsuke
Sogame)</a></li>
<li><a href="doc/portability.html">Portability</a>
<li><a href="doc/faq.html">FAQ</a>
<li><a href="doc/history_ack.html">History and acknowledgment</a>
</ul>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>

35
test/Jamfile.v2 Normal file
View File

@ -0,0 +1,35 @@
# Boost.Range library
#
# Copyright Thorsten Ottosen 2003-2004. Use, modification and
# distribution is subject to the Boost Software License, Version
# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# For more information, see http://www.boost.org/libs/range/
#
rule range-test ( name : includes * )
{
return [
run $(name).cpp /boost/test//boost_unit_test_framework/<link>static
:
:
: <toolset>gcc:<cxxflags>"-Wall -Wunused "
] ;
}
test-suite range :
[ range-test array ]
[ range-test iterator_pair ]
[ range-test std_container ]
[ range-test string ]
[ range-test iterator_range ]
[ range-test sub_range ]
[ range-test partial_workaround ]
[ range-test algorithm_example ]
[ range-test reversible_range ]
[ range-test const_ranges ]
[ range-test extension_mechanism ]
# [ range-test mfc : <include>$(VC71_ROOT)/atlmfc/include ]
;

185
test/adl_conformance.cpp Normal file
View File

@ -0,0 +1,185 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
enum adl_types
{
unused,
boost_namespace,
templated_namespace,
non_templated_namespace,
global_namespace
};
namespace boost
{
namespace range_detail
{
template< class Range >
inline typename Range::iterator begin( Range& r )
{
return boost_namespace;
}
template< class Range >
inline typename Range::iterator begin( const Range& r )
{
return boost_namespace;
}
}
template< class Range >
inline typename Range::iterator begin( Range& r )
{
using range_detail::begin; // create ADL hook
return begin( r );
}
template< class Range >
inline typename Range::iterator begin( const Range& r )
{
using range_detail::begin; // create ADL hook
return begin( r );
}
}
namespace find_templated
{
template< class T >
struct range
{
typedef adl_types iterator;
range() { /* allow const objects */ }
iterator begin() { return unused; }
iterator begin() const { return unused; }
iterator end() { return unused; }
iterator end() const { return unused; }
};
//
// A fully generic version here will create
// ambiguity.
//
template< class T >
inline typename range<T>::iterator begin( range<T>& r )
{
return templated_namespace;
}
template< class T >
inline typename range<T>::iterator begin( const range<T>& r )
{
return templated_namespace;
}
}
namespace find_non_templated
{
struct range
{
typedef adl_types iterator;
range() { /* allow const objects */ }
iterator begin() { return unused; }
iterator begin() const { return unused; }
iterator end() { return unused; }
iterator end() const { return unused; }
};
inline range::iterator begin( range& r )
{
return non_templated_namespace;
}
inline range::iterator begin( const range& r )
{
return non_templated_namespace;
}
}
struct range
{
typedef adl_types iterator;
range() { /* allow const objects */ }
iterator begin() { return unused; }
iterator begin() const { return unused; }
iterator end() { return unused; }
iterator end() const { return unused; }
};
inline range::iterator begin( range& r )
{
return global_namespace;
}
inline range::iterator begin( const range& r )
{
return global_namespace;
}
void check_adl_conformance()
{
find_templated::range<int> r;
const find_templated::range<int> r2;
find_non_templated::range r3;
const find_non_templated::range r4;
range r5;
const range r6;
//
// Notice how ADL kicks in even when we have qualified
// notation!
//
BOOST_CHECK( boost::begin( r ) != boost_namespace );
BOOST_CHECK( boost::begin( r2 ) != boost_namespace );
BOOST_CHECK( boost::begin( r3 ) != boost_namespace );
BOOST_CHECK( boost::begin( r4 ) != boost_namespace );
BOOST_CHECK( boost::begin( r5 ) != boost_namespace );
BOOST_CHECK( boost::begin( r6 ) != boost_namespace );
BOOST_CHECK_EQUAL( boost::begin( r ), templated_namespace ) ;
BOOST_CHECK_EQUAL( boost::begin( r2 ), templated_namespace );
BOOST_CHECK_EQUAL( boost::begin( r3 ), non_templated_namespace );
BOOST_CHECK_EQUAL( boost::begin( r4 ), non_templated_namespace );
BOOST_CHECK_EQUAL( boost::begin( r5 ), global_namespace );
BOOST_CHECK_EQUAL( boost::begin( r6 ), global_namespace );
}
#include <boost/test/included/unit_test_framework.hpp>
using boost::unit_test_framework::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_adl_conformance ) );
return test;
}

View File

@ -0,0 +1,110 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <iostream>
namespace A
{
namespace detail
{
template< typename T >
int f( const T& x )
{
// Default:
std::cout << 1 << std::endl;
return 1;
}
template< typename T >
int adl_f2( const T& x, int* )
{
return f( x );
}
template< typename T >
int adl_f( const T& x )
{
return adl_f2( x, 0 );
}
}
template< typename T >
int f( const T& x )
{
return detail::adl_f( x );
}
template< typename T >
int adl_f2( const T& x, int )
{
return detail::f( x );
}
//--------------------------------
class C {};
/*
// Optional:
int f( const C& x )
{
std::cout << 2 << std::endl;
}
*/
template< typename T >
class D {};
/*
// Optional:
template< typename T >
int f( const D< T >& x )
{
std::cout << 3 << std::endl;
}
*/
}
namespace B
{
class C {};
// Optional:
/* int f( const C& )
{
std::cout << 4 << std::endl;
}
*/
template< typename T >
class D {};
/*
// Optional:
template< typename T >
int f( const D< T >& x )
{
std::cout << 5 << std::endl;
}
*/
}
int main()
{
A::f( 42 );
A::C ac;
A::f( ac );
A::D< int > ad;
A::f( ad );
B::C bc;
A::f( bc );
B::D< int > bd;
A::f( bd );
}

View File

@ -0,0 +1,92 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/test/test_tools.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
namespace
{
//
// example: extrating bounds in a generic algorithm
//
template< typename Range, typename T >
inline typename boost::range_iterator<Range>::type
find( Range& c, const T& value )
{
return std::find( boost::begin( c ), boost::end( c ), value );
}
template< typename Range, typename T >
inline typename boost::range_iterator<Range>::type
find( const Range& c, const T& value )
{
return std::find( boost::begin( c ), boost::end( c ), value );
}
//
// replace first value and return its index
//
template< class Range, class T >
inline typename boost::range_difference<Range>::type
my_generic_replace( Range& c, const T& value, const T& replacement )
{
typename boost::range_iterator<Range>::type found = find( c, value );
if( found != boost::end( c ) )
*found = replacement;
return std::distance( boost::begin( c ), found );
}
}
void check_algorithm()
{
//
// usage
//
const int N = 5;
std::vector<int> my_vector;
int values[] = { 1,2,3,4,5,6,7,8,9 };
my_vector.assign( values, values + 9 );
typedef std::vector<int>::iterator iterator;
std::pair<iterator,iterator> my_view( boost::begin( my_vector ),
boost::begin( my_vector ) + N );
BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3 );
BOOST_CHECK_EQUAL( my_generic_replace( my_view, 4, 2 ), N );
}
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_algorithm ) );
return test;
}

83
test/array.cpp Normal file
View File

@ -0,0 +1,83 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
using namespace boost;
using namespace std;
void check_array()
{
const int sz = 9;
typedef int array_t[sz];
int my_array[sz] = { 1,2,3,4,5,6,7,8,9 };
const array_t ca = { 1,2,3,4,5,6,7,8,10 };
// BOOST_RANGE_NO_STATIC_ASSERT
#if !defined( __BORLANDC__ )
#else
BOOST_STATIC_ASSERT(( is_same< range_value<array_t>::type, int >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<array_t>::type, int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<array_t>::type, const int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<array_t>::type, std::ptrdiff_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<array_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<array_t>::type, int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_value<const array_t>::type, const int >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const array_t>::type, const int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<const array_t>::type, std::ptrdiff_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<const array_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
#endif
BOOST_CHECK_EQUAL( begin( my_array ), my_array );
BOOST_CHECK_EQUAL( end( my_array ), my_array + size( my_array ) );
BOOST_CHECK_EQUAL( empty( my_array ), false );
BOOST_CHECK_EQUAL( begin( ca ), ca );
BOOST_CHECK_EQUAL( end( ca ), ca + size( ca ) );
BOOST_CHECK_EQUAL( empty( ca ),false );
const char A[] = "\0A";
BOOST_CHECK_EQUAL( boost::size(A), 3 );
}
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_array ) );
return test;
}

623
test/atl.cpp Normal file
View File

@ -0,0 +1,623 @@
// Boost.Range ATL Extension
//
// Copyright Shunsuke Sogame 2005-2006.
// 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 <pstade/vodka/drink.hpp>
#include <boost/test/test_tools.hpp>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define BOOST_LIB_NAME boost_test_exec_monitor
#include <boost/config/auto_link.hpp>
#define BOOST_RANGE_DETAIL_MICROSOFT_TEST
#include <boost/range/atl.hpp> // can be placed first
#include <map>
#include <string>
#include <boost/concept_check.hpp>
#include <boost/mpl/if.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/distance.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/foreach.hpp>
#include <atlbase.h> // for ATL3 CSimpleArray/CSimpleValArray
#if !(_ATL_VER < 0x0700)
#include <atlcoll.h>
#include <cstringt.h>
#include <atlsimpstr.h>
#include <atlstr.h>
#endif
namespace brdm = boost::range_detail_microsoft;
#if !(_ATL_VER < 0x0700)
template< class ArrayT, class SampleRange >
bool test_init_auto_ptr_array(ArrayT& arr, SampleRange& sample)
{
typedef typename boost::range_iterator<SampleRange>::type iter_t;
for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
arr.Add(*it); // moves ownership
}
return boost::distance(arr) == boost::distance(sample);
}
template< class ListT, class SampleRange >
bool test_init_auto_ptr_list(ListT& lst, SampleRange& sample)
{
typedef typename boost::range_iterator<SampleRange>::type iter_t;
typedef typename boost::range_value<SampleRange>::type val_t;
for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
lst.AddTail(*it); // moves ownership
}
return boost::distance(lst) == boost::distance(sample);
}
// Workaround:
// CRBTree provides no easy access function, but yes, it is the range!
//
template< class AtlMapT, class KeyT, class MappedT >
bool test_atl_map_has(AtlMapT& map, const KeyT& k, const MappedT m)
{
typedef typename boost::range_iterator<AtlMapT>::type iter_t;
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
if (it->m_key == k && it->m_value == m)
return true;
}
return false;
}
template< class AtlMapT, class MapT >
bool test_atl_map(AtlMapT& map, const MapT& sample)
{
typedef typename boost::range_iterator<AtlMapT>::type iter_t;
typedef typename boost::range_const_iterator<MapT>::type siter_t;
bool result = true;
result = result && (boost::distance(map) == boost::distance(sample));
if (!result)
return false;
{
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->m_key, it->m_value));
}
}
{
for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
result = result && (test_atl_map_has)(map, it->first, it->second);
}
}
return result;
}
template< class MapT, class SampleMap >
bool test_init_atl_multimap(MapT& map, const SampleMap& sample)
{
typedef typename boost::range_const_iterator<SampleMap>::type iter_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
map.Insert(it->first, it->second);
}
return boost::distance(map) == boost::distance(sample);
}
// arrays
//
template< class Range >
void test_CAtlArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ATL::CAtlArray<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class ValT, class Range >
void test_CAutoPtrArray(Range& sample)
{
typedef ValT val_t;
typedef ATL::CAutoPtrArray<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, boost::indirect_iterator< ATL::CAutoPtr<val_t> *> >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, boost::indirect_iterator< ATL::CAutoPtr<val_t> const*> >::value ));
rng_t rng;
BOOST_CHECK( ::test_init_auto_ptr_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class I, class Range >
void test_CInterfaceArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ATL::CInterfaceArray<I> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, ATL::CComQIPtr<I> * >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, ATL::CComQIPtr<I> const* >::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// lists
//
template< class Range >
void test_CAtlList(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ATL::CAtlList<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, val_t> >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, val_t const> >::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class ValT, class Range >
void test_CAutoPtrList(Range& sample)
{
typedef ValT val_t;
typedef ATL::CAutoPtrList<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t, ATL::CAutoPtr<val_t> > > >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t const, ATL::CAutoPtr<val_t> const> > >::value ));
rng_t rng;
BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class ValT, class Range >
void test_CHeapPtrList(const Range& sample)
{
typedef ValT val_t;
typedef ATL::CHeapPtrList<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t, ATL::CHeapPtr<val_t> > > >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t const, ATL::CHeapPtr<val_t> const> > >::value ));
rng_t rng;
BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class I, class Range >
void test_CInterfaceList(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ATL::CInterfaceList<I> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, ATL::CComQIPtr<I> > >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ATL::CComQIPtr<I> const> >::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// strings
//
template< class Range >
void test_CSimpleStringT(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
ATL::CAtlStringA,
ATL::CAtlStringW
>::type derived_t;
typedef ATL::CSimpleStringT<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, typename rng_t::PCXSTR>::value ));
derived_t drng;
rng_t& rng = drng;
BOOST_CHECK( brdm::test_init_string(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
// BOOST_CHECK( brdm::test_emptiness(rng) ); no default constructible
}
template< int n, class Range >
void test_CFixedStringT(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
ATL::CAtlStringA,
ATL::CAtlStringW
>::type base_t;
typedef ATL::CFixedStringT<base_t, n> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, typename rng_t::PCXSTR>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_string(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CStringT(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
ATL::CAtlStringA, // == CStringT<char, X>
ATL::CAtlStringW // == CStringT<wchar_t, X>
>::type rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, typename rng_t::PCXSTR>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_string(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CStaticString(const Range& sample)
{
#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE)
{
typedef ATL::CStaticString<char, 20> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, char const *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, char const *>::value ));
rng_t rng("hello static string");
BOOST_CHECK( *(boost::begin(rng)+4) == 'o' );
BOOST_CHECK( *(boost::end(rng)-3) == 'i' );
}
{
typedef ATL::CStaticString<wchar_t, 40> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, wchar_t const *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, wchar_t const *>::value ));
rng_t rng(L"hello static string");
BOOST_CHECK( *(boost::begin(rng)+4) == L'o' );
BOOST_CHECK( *(boost::end(rng)-3) == L'i' );
}
#endif
(void)sample; // unused
}
#endif // !(_ATL_VER < 0x0700)
template< class Range >
void test_CComBSTR(const Range& sample)
{
typedef ATL::CComBSTR rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, OLECHAR *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, OLECHAR const*>::value ));
rng_t rng(OLESTR("hello CComBSTR range!"));
BOOST_CHECK( brdm::test_equals(rng, std::string("hello CComBSTR range!")) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
(void)sample; // unused
}
// simples
//
template< class Range >
void test_CSimpleArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ATL::CSimpleArray<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CSimpleMap(const Range& sample)
{
#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE)
typedef ATL::CSimpleMap<int, double> rng_t;
rng_t rng;
rng.Add(3, 3.0);
rng.Add(4, 2.0);
BOOST_CHECK( boost::begin(rng)->get<0>() == 3.0 );
BOOST_CHECK( (boost::end(rng)-1)->get<1>() == 2.0 );
#endif
(void)sample; // unused
}
template< class Range >
void test_CSimpleValArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ATL::CSimpleArray<val_t> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// maps
//
template< class MapT >
void test_CAtlMap(const MapT& sample)
{
typedef typename MapT::key_type k_t;
typedef typename MapT::mapped_type m_t;
typedef ATL::CAtlMap<k_t, m_t> rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_atl_map(rng, sample) );
}
template< class MapT >
void test_CRBTree(const MapT& sample)
{
typedef typename MapT::key_type k_t;
typedef typename MapT::mapped_type m_t;
typedef ATL::CRBMap<k_t, m_t> derived_t;
typedef ATL::CRBTree<k_t, m_t> rng_t;
derived_t drng;
rng_t& rng = drng;
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(drng, sample) );
BOOST_CHECK( ::test_atl_map(rng, sample) );
}
template< class MapT >
void test_CRBMap(const MapT& sample)
{
typedef typename MapT::key_type k_t;
typedef typename MapT::mapped_type m_t;
typedef ATL::CRBMap<k_t, m_t> rng_t;
rng_t rng;
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_atl_map(rng, sample) );
}
template< class MapT >
void test_CRBMultiMap(const MapT& sample)
{
typedef typename MapT::key_type k_t;
typedef typename MapT::mapped_type m_t;
typedef ATL::CRBMultiMap<k_t, m_t> rng_t;
rng_t rng;
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
BOOST_CHECK( ::test_init_atl_multimap(rng, sample) );
BOOST_CHECK( ::test_atl_map(rng, sample) );
}
// main test
//
void test_atl()
{
// ordinary ranges
//
{
std::string sample("rebecca judy and mary whiteberry chat monchy");
#if !(_ATL_VER < 0x0700)
::test_CAtlArray(sample);
::test_CAtlList(sample);
::test_CSimpleStringT(sample);
::test_CFixedStringT<44>(sample);
::test_CStringT(sample);
::test_CStaticString(sample);
#endif
::test_CComBSTR(sample);
::test_CSimpleArray(sample);
::test_CSimpleMap(sample);
::test_CSimpleValArray(sample);
}
{
std::wstring sample(L"rebecca judy and mary whiteberry chat monchy");
#if !(_ATL_VER < 0x0700)
::test_CAtlArray(sample);
::test_CAtlList(sample);
::test_CSimpleStringT(sample);
::test_CFixedStringT<44>(sample);
::test_CStringT(sample);
::test_CStaticString(sample);
#endif
::test_CComBSTR(sample);
::test_CSimpleArray(sample);
::test_CSimpleMap(sample);
::test_CSimpleValArray(sample);
}
// pointer ranges
//
#if !(_ATL_VER < 0x0700)
{
typedef ATL::CAutoPtr<int> ptr_t;
ptr_t
ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)),
ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0));
ptr_t ptrs[8] = {
ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7
};
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
::test_CAutoPtrArray<int>(workaround);
}
{
typedef ATL::CAutoPtr<int> ptr_t;
ptr_t
ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)),
ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0));
ptr_t ptrs[8] = {
ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7
};
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
::test_CAutoPtrList<int>(workaround);
}
{
typedef ATL::CHeapPtr<int> ptr_t;
ptr_t ptrs[5]; {
ptrs[0].AllocateBytes(sizeof(int));
ptrs[1].AllocateBytes(sizeof(int));
ptrs[2].AllocateBytes(sizeof(int));
ptrs[3].AllocateBytes(sizeof(int));
ptrs[4].AllocateBytes(sizeof(int));
}
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+5);
::test_CHeapPtrList<int>(workaround);
}
{
typedef ATL::CComQIPtr<IDispatch> ptr_t;
ptr_t ptrs[8];
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
::test_CInterfaceArray<IDispatch>(workaround);
::test_CInterfaceList<IDispatch>(workaround);
}
#endif
// maps
//
{
#if !(_ATL_VER < 0x0700)
std::map<int, std::string> sample; {
sample[0] = "hello";
sample[1] = "range";
sample[2] = "atl";
sample[3] = "mfc";
sample[4] = "collections";
}
::test_CAtlMap(sample);
::test_CRBTree(sample);
::test_CRBMap(sample);
::test_CRBMultiMap(sample);
#endif
}
} // test_atl
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite *
init_unit_test_suite(int argc, char* argv[])
{
test_suite *test = BOOST_TEST_SUITE("ATL Range Test Suite");
test->add(BOOST_TEST_CASE(&test_atl));
(void)argc, (void)argv; // unused
return test;
}

73
test/compat2.cpp Normal file
View File

@ -0,0 +1,73 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/config.hpp>
enum Container {};
enum String {};
template< typename T >
struct range_iterator;
template<>
struct range_iterator<Container>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
};
template<>
struct range_iterator<String>
{
template< typename C >
struct pts
{
typedef C type;
};
};
template< typename C >
class iterator_of
{
public:
typedef range_iterator<Container>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
#include <vector>
void compat1()
{
std::vector<int> v;
iterator_of< std::vector<int> >::type i = v.begin();
}
#include <boost/test/included/unit_test_framework.hpp>
using boost::unit_test_framework::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &compat1 ) );
return test;
}

73
test/compat3.cpp Normal file
View File

@ -0,0 +1,73 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/config.hpp>
enum Container {};
enum String {};
template< typename T >
struct range_iterator;
template<>
struct range_iterator<Container>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
};
template<>
struct range_iterator<String>
{
template< typename C >
struct pts
{
typedef C type;
};
};
template< typename C >
class iterator_of
{
public:
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>:: template pts<C>::type type;
};
#include <vector>
void compat1()
{
std::vector<int> v;
iterator_of< std::vector<int> >::type i = v.begin();
}
#include <boost/test/included/unit_test_framework.hpp>
using boost::unit_test_framework::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &compat1 ) );
return test;
}

66
test/const_ranges.cpp Normal file
View File

@ -0,0 +1,66 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <string>
using namespace boost;
using namespace std;
template< class T >
const T& as_const( const T& r )
{
return r;
}
void check_const_ranges()
{
std::string foo( "foo" );
const std::string bar( "bar" );
BOOST_CHECK( const_begin( foo ) == begin( as_const( foo ) ) );
BOOST_CHECK( const_end( foo ) == end( as_const( foo ) ) );
BOOST_CHECK( const_rbegin( foo ) == rbegin( as_const( foo ) ) );
BOOST_CHECK( const_rend( foo ) == rend( as_const( foo ) ) );
BOOST_CHECK( const_begin( bar ) == begin( as_const( bar ) ) );
BOOST_CHECK( const_end( bar ) == end( as_const( bar ) ) );
BOOST_CHECK( const_rbegin( bar ) == rbegin( as_const( bar ) ) );
BOOST_CHECK( const_rend( bar ) == rend( as_const( bar ) ) );
}
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_const_ranges ) );
return test;
}

View File

@ -0,0 +1,107 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <vector>
//
// Generic range algorithm
//
template< class Rng >
typename boost::range_iterator<Rng>::type foo_algo( Rng& r )
{
//
// This will only compile for Rng = UDT if the qualified calls
// find boost_range_XXX via ADL.
//
return boost::size(r) == 0u ? boost::begin(r) : boost::end(r);
}
namespace Foo
{
//
// Our sample UDT
//
struct X
{
typedef std::vector<int> data_t;
typedef data_t::iterator iterator;
typedef data_t::const_iterator const_iterator;
data_t vec;
void push_back( int i )
{ vec.push_back(i); }
};
//
// The required functions. No type-traits need
// to be defined because X defines the proper set of
// nested types.
//
inline X::iterator range_begin( X& x )
{
return x.vec.begin();
}
inline X::const_iterator range_begin( const X& x )
{
return x.vec.begin();
}
inline X::iterator range_end( X& x )
{
return x.vec.end();
}
inline X::const_iterator range_end( const X& x )
{
return x.vec.end();
}
}
void check_extension()
{
Foo::X x;
x.push_back(3);
const Foo::X x2;
foo_algo( x );
foo_algo( x2 );
}
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_extension ) );
return test;
}

99
test/iterator_pair.cpp Normal file
View File

@ -0,0 +1,99 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/concepts.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/test/test_tools.hpp>
#include <vector>
using namespace boost;
void check_iterator_pair()
{
typedef std::vector<int> vec_t;
vec_t vec;
vec.push_back( 4 );
typedef std::pair<vec_t::iterator,vec_t::iterator>
pair_t;
typedef std::pair<vec_t::const_iterator,vec_t::const_iterator>
const_pair_t;
typedef const pair_t const_pair_tt;
pair_t pair = std::make_pair( begin( vec ), end( vec ) );
const_pair_t const_pair = std::make_pair( begin( vec ), end( vec ) );
const_pair_tt constness_pair( pair );
BOOST_STATIC_ASSERT(( is_same< range_value<pair_t>::type,
detail::iterator_traits<pair_t::first_type>::value_type>::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<pair_t>::type, pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<pair_t>::type, pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<pair_t>::type,
detail::iterator_traits<pair_t::first_type>::difference_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<pair_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<pair_t>::type, pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_value<const_pair_tt>::type,
detail::iterator_traits<const_pair_t::first_type>::value_type>::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
//
// This behavior is not supported with v2.
//BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<const_pair_tt>::type,
detail::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<const_pair_tt>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
BOOST_CHECK( begin( pair ) == pair.first );
BOOST_CHECK( end( pair ) == pair.second );
BOOST_CHECK( empty( pair ) == (pair.first == pair.second) );
BOOST_CHECK( size( pair ) == std::distance( pair.first, pair.second ) );
BOOST_CHECK( begin( const_pair ) == const_pair.first );
BOOST_CHECK( end( const_pair ) == const_pair.second );
BOOST_CHECK( empty( const_pair ) == (const_pair.first == const_pair.second) );
BOOST_CHECK( size( const_pair ) == std::distance( const_pair.first, const_pair.second ) );
BOOST_CHECK( begin( constness_pair ) == constness_pair.first );
BOOST_CHECK( end( constness_pair ) == constness_pair.second );
BOOST_CHECK( empty( constness_pair ) == (constness_pair.first == const_pair.second) );
BOOST_CHECK( size( constness_pair ) == std::distance( constness_pair.first, constness_pair.second ) );
}
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_iterator_pair ) );
return test;
}

150
test/iterator_range.cpp Normal file
View File

@ -0,0 +1,150 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen & Larry Evans 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
//#include <boost/range/as_array.hpp>
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/iterator_range.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
using namespace boost;
using namespace std;
void check_reference_type();
void check_iterator_range()
{
typedef string::iterator iterator;
typedef string::const_iterator const_iterator;
typedef iterator_range<iterator> irange;
typedef iterator_range<const_iterator> cirange;
string str = "hello world";
const string cstr = "const world";
irange r = make_iterator_range( str );
r = make_iterator_range( str.begin(), str.end() );
cirange r2 = make_iterator_range( cstr );
r2 = make_iterator_range( cstr.begin(), cstr.end() );
r2 = make_iterator_range( str );
BOOST_CHECK( !r.empty() );
BOOST_CHECK( !r2.empty() );
//#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// if( !(bool)r )
// BOOST_CHECK( false );
// if( !(bool)r2 )
// BOOST_CHECK( false );
//#else
if( !r )
BOOST_CHECK( false );
if( !r2 )
BOOST_CHECK( false );
//#endif
BOOST_CHECK_EQUAL( r.size(), size( r ) );
BOOST_CHECK_EQUAL( r2.size(), size( r2 ) );
BOOST_CHECK_EQUAL( distance( r.begin(), r.end() ),
distance( begin( r2 ), end( r2 ) ) );
cout << r << r2;
#ifndef BOOST_NO_STD_WSTRING
wcout << make_iterator_range( wstring( L"a wide string" ) )
<< make_iterator_range( L"another wide string" );
#endif
string res = copy_range<string>( r );
BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) );
irange rr = make_iterator_range( str );
BOOST_CHECK( rr.equal( r ) );
rr = make_iterator_range( str.begin(), str.begin() + 5 );
BOOST_CHECK( rr == as_literal("hello") );
BOOST_CHECK( rr != as_literal("hell") );
BOOST_CHECK( rr < as_literal("hello dude") );
BOOST_CHECK( as_literal("hello") == rr );
BOOST_CHECK( as_literal("hell") != rr );
BOOST_CHECK( ! (as_literal("hello dude") < rr ) );
irange rrr = rr;
BOOST_CHECK( rrr == rr );
BOOST_CHECK( !( rrr != rr ) );
BOOST_CHECK( !( rrr < rr ) );
const irange cr = make_iterator_range( str );
BOOST_CHECK_EQUAL( cr.front(), 'h' );
BOOST_CHECK_EQUAL( cr.back(), 'd' );
BOOST_CHECK_EQUAL( cr[1], 'e' );
BOOST_CHECK_EQUAL( cr(1), 'e' );
rrr = make_iterator_range( str, 1, -1 );
BOOST_CHECK( rrr == as_literal("ello worl") );
rrr = make_iterator_range( rrr, -1, 1 );
BOOST_CHECK( rrr == str );
check_reference_type();
}
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_iterator_range ) );
return test;
}
//
//
// Check that constness is propgated correct from
// the iterator types.
//
// Test contributed by Larry Evans.
//
template< class Container >
int test_iter_range( Container& a_cont )
{
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type citer_type;
typedef iterator_range<citer_type> riter_type;
riter_type a_riter( make_iterator_range( a_cont ) );
a_riter.front();
a_riter.back();
int i = a_riter[0];
return i;
}
void check_reference_type()
{
typedef vector<int> veci_type;
veci_type a_vec;
a_vec.push_back( 999 );
test_iter_range<veci_type>(a_vec);
test_iter_range<veci_type const>(a_vec);
}

743
test/mfc.cpp Normal file
View File

@ -0,0 +1,743 @@
// Boost.Range MFC Extension
//
// Copyright Shunsuke Sogame 2005-2006.
// 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 <afx.h> // must be here
// #include <pstade/vodka/drink.hpp>
#include <boost/test/test_tools.hpp>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define BOOST_LIB_NAME boost_test_exec_monitor
#include <boost/config/auto_link.hpp>
#define BOOST_RANGE_DETAIL_MICROSOFT_TEST
#include <boost/range/mfc.hpp> // can be placed first
#include <map>
#include <boost/concept_check.hpp>
// #include <boost/foreach.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/end.hpp>
#include <boost/static_assert.hpp>
#include <boost/algorithm/string.hpp>
#include <afx.h>
#include <afxcoll.h>
#include <afxtempl.h>
#if !(_ATL_VER < 0x0700)
#include <cstringt.h>
#include <atlsimpstr.h>
#include <atlstr.h>
#endif
namespace brdm = boost::range_detail_microsoft;
// helpers
//
template< class MfcMapT, class MapT >
bool test_mfc_map(MfcMapT& map, const MapT& sample)
{
typedef typename boost::range_iterator<MfcMapT>::type iter_t;
typedef typename boost::range_const_iterator<MapT>::type siter_t;
bool result = true;
result = result && (boost::distance(map) == boost::distance(sample));
if (!result)
return false;
{
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
result = result && brdm::test_find_key_and_mapped(sample, *it);
}
}
{
for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
result = result && (map[it->first] == it->second);
}
}
return result;
}
template< class MfcMapT, class MapT >
bool test_mfc_cpair_map(MfcMapT& map, const MapT& sample)
{
typedef typename boost::range_iterator<MfcMapT>::type iter_t;
typedef typename boost::range_const_iterator<MapT>::type siter_t;
bool result = true;
result = result && (boost::distance(map) == boost::distance(sample));
if (!result)
return false;
{
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->key, it->value));
}
}
{
for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
result = result && (map[it->first] == it->second);
}
}
return result;
}
// arrays
//
template< class Range >
void test_CByteArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CByteArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, BYTE *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, BYTE const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CDWordArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CDWordArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, DWORD *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, DWORD const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CObArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CObArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, brdm::mfc_ptr_array_iterator<rng_t, ::CObject *> >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, brdm::mfc_ptr_array_iterator<const rng_t, const ::CObject *> >::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CPtrArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CPtrArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, brdm::mfc_ptr_array_iterator<rng_t, void *> >::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, brdm::mfc_ptr_array_iterator<const rng_t, const void *> >::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CStringArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CStringArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, ::CString *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, ::CString const *>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CUIntArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CUIntArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, UINT *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, UINT const *>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CWordArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CWordArray rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, WORD *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, WORD const *>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// lists
//
template< class Range >
void test_CObList(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CObList rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, ::CObject *> >::value ));
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CObject const *> >::value ));
#else
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CObject const * const, ::CObject const * const> >::value ));
#endif
rng_t rng;
BOOST_CHECK( brdm::test_init_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CPtrList(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CPtrList rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, void *> >::value ));
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, void const *> >::value ));
#else
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, void const * const, void const * const> >::value ));
#endif
rng_t rng;
BOOST_CHECK( brdm::test_init_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CStringList(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CStringList rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, ::CString> >::value ));
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CString const> >::value ));
#else
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CString const, ::CString const> >::value ));
#endif
rng_t rng;
BOOST_CHECK( brdm::test_init_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// maps
//
template< class MapT >
void test_CMapPtrToWord(const MapT& sample)
{
typedef ::CMapPtrToWord rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_mfc_map(rng, sample) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMapPtrToPtr(const MapT& sample)
{
typedef ::CMapPtrToPtr rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_mfc_map(rng, sample) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMapStringToOb(const MapT& sample)
{
typedef ::CMapStringToOb rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_mfc_map(rng, sample) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMapStringToPtr(const MapT& sample)
{
typedef ::CMapStringToPtr rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_mfc_map(rng, sample) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMapStringToString(const MapT& sample)
{
typedef ::CMapStringToString rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
BOOST_CHECK( ::test_mfc_cpair_map(rng, sample) );
#endif
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMapWordToOb(const MapT& sample)
{
typedef ::CMapWordToOb rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_mfc_map(rng, sample) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMapWordToPtr(const MapT& sample)
{
typedef ::CMapWordToPtr rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
BOOST_CHECK( ::test_mfc_map(rng, sample) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// templates
//
template< class Range >
void test_CArray(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CArray<val_t, const val_t&> rng_t; // An old MFC needs the second template argument.
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_array(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class Range >
void test_CList(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CList<val_t, const val_t&> rng_t;
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, val_t> >::value ));
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, val_t const> >::value ));
#else
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, val_t const, val_t const> >::value ));
#endif
rng_t rng;
BOOST_CHECK( brdm::test_init_list(rng, sample) );
BOOST_CHECK( brdm::test_bidirectional(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
template< class MapT >
void test_CMap(const MapT& sample)
{
typedef typename MapT::key_type k_t;
typedef typename MapT::mapped_type m_t;
typedef ::CMap<k_t, const k_t&, m_t, const m_t&> rng_t;
rng_t rng;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
BOOST_CHECK( brdm::test_init_map(rng, sample) );
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
BOOST_CHECK( ::test_mfc_cpair_map(rng, sample) );
#endif
BOOST_CHECK( brdm::test_emptiness(rng) );
}
void test_CTypedPtrArray()
{
typedef ::CTypedPtrArray< ::CPtrArray, int * > rng_t;
boost::function_requires< boost::RandomAccessRangeConcept<rng_t> >();
rng_t rng;
int o1, o2, o3, o4, o5;
int *data[] = { &o1, &o2, &o3, &o4, &o5 };
BOOST_CHECK( brdm::test_init_array(rng, boost::make_iterator_range(data, data+5)) );
BOOST_CHECK( *(boost::begin(rng) + 2) == &o3 );
BOOST_CHECK( *(boost::end(rng) - 1) == &o5 );
// BOOST_CHECK( brdm::test_random_access(rng) ); this range is not mutable
BOOST_CHECK( brdm::test_emptiness(rng) );
}
void test_CTypedPtrList()
{
typedef ::CTypedPtrList< ::CObList, ::CObList * > rng_t;
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
rng_t rng;
::CObList o1, o2, o3, o4, o5;
::CObList *data[] = { &o1, &o2, &o3, &o4, &o5 };
BOOST_CHECK( brdm::test_init_list(rng, data) );
boost::range_iterator<rng_t>::type it = boost::begin(rng);
std::advance(it, 1);
BOOST_CHECK( *it == &o2 );
std::advance(it, 2);
BOOST_CHECK( *it == &o4 );
// BOOST_CHECK( brdm::test_bidirectional(rng) ); this range is not mutable
BOOST_CHECK( brdm::test_emptiness(rng) );
}
void test_CTypedPtrMap()
{
typedef ::CTypedPtrMap< ::CMapStringToPtr, ::CString, int *> rng_t;
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
rng_t rng;
::CString o0(_T('a')), o1(_T('c')), o2(_T('f')), o3(_T('q')), o4(_T('g'));
int d0, d1, d2, d3, d4;
std::map< ::CString, int * > data;
data[o0] = &d0, data[o1] = &d1, data[o2] = &d2, data[o3] = &d3, data[o4] = &d4;
BOOST_CHECK( brdm::test_init_map(rng, data) );
BOOST_CHECK( ::test_mfc_map(rng, data) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
// strings
//
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
template< class Range >
void test_CString(const Range& sample)
{
typedef typename boost::range_value<Range>::type val_t;
typedef ::CString rng_t; // An old MFC needs the second template argument.
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, TCHAR *>::value ));
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, TCHAR const*>::value ));
rng_t rng;
BOOST_CHECK( brdm::test_init_string(rng, sample) );
BOOST_CHECK( brdm::test_random_access(rng) );
BOOST_CHECK( brdm::test_emptiness(rng) );
}
#endif
struct CPerson
{
void hello_range() { };
};
void test_mfc()
{
#if 0
// overview
//
{
CTypedPtrArray<CPtrArray, CList<CString> *> myArray;
// ...
BOOST_FOREACH (CList<CString> *theList, myArray)
{
BOOST_FOREACH (CString& str, *theList)
{
boost::to_upper(str);
std::sort(boost::begin(str), boost::end(str));
// ...
}
}
}
#endif
// arrays
//
{
BYTE data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
::test_CByteArray(boost::make_iterator_range(data, data+22));
}
{
DWORD data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
test_CDWordArray(boost::make_iterator_range(data, data+22));
}
{
::CObArray o1, o2, o3, o4, o5;
::CObject *data[] = { &o1, &o2, &o3, &o4, &o5 };
::test_CObArray(boost::make_iterator_range(data, data+5));
}
{
::CPtrArray o1, o2, o3, o4, o5;
void *data[] = { &o1, &o2, &o3, &o4, &o5 };
::test_CPtrArray(boost::make_iterator_range(data, data+5));
}
{
::CString data[] = {
::CString(_T('0')), ::CString(_T('1')), ::CString(_T('2')), ::CString(_T('3')),
::CString(_T('4')), ::CString(_T('5')), ::CString(_T('6')), ::CString(_T('7'))
};
::test_CStringArray(boost::make_iterator_range(data, data+8));
}
{
::CUIntArray rng;
UINT data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
::test_CUIntArray(boost::make_iterator_range(data, data+22));
}
{
::CWordArray rng;
WORD data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
::test_CWordArray(boost::make_iterator_range(data, data+22));
}
// lists
//
{
::CObList rng;
::CObList o1, o2, o3, o4, o5;
::CObject *data[] = { &o1, &o2, &o3, &o4, &o5 };
::test_CObList(boost::make_iterator_range(data, data+5));
}
{
::CPtrList rng;
::CPtrList o1, o2, o3, o4, o5;
void *data[] = { &o1, &o2, &o3, &o4, &o5 };
::test_CPtrList(boost::make_iterator_range(data, data+5));
}
{
::CString data[] = {
::CString(_T('0')), ::CString(_T('1')), ::CString(_T('2')), ::CString(_T('3')),
::CString(_T('4')), ::CString(_T('5')), ::CString(_T('6')), ::CString(_T('7'))
};
::test_CStringList(boost::make_iterator_range(data, data+8));
}
// maps
//
{
std::map<void *, WORD> data;
int o0, o1, o2, o3, o4;
data[&o0] = 15, data[&o1] = 14, data[&o2] = 3, data[&o3] = 6, data[&o4] = 1;
::test_CMapPtrToWord(data);
}
{
std::map<void *, void*> data;
int o0, o1, o2, o3, o4;
data[&o0] = &o3, data[&o1] = &o2, data[&o2] = &o1, data[&o3] = &o0, data[&o4] = &o4;
::test_CMapPtrToPtr(data);
}
{
std::map< ::CString, CObject * > data;
CObArray o0, o1, o2, o3, o4;
data[ ::CString('0') ] = &o0, data[ ::CString('1') ] = &o1, data[ ::CString('2') ] = &o2,
data[ ::CString('3') ] = &o3, data[ ::CString('4') ] = &o4;
::test_CMapStringToOb(data);
}
{
std::map< ::CString, void * > data;
CObArray o0, o1, o2, o3, o4;
data[ ::CString('0') ] = &o0, data[ ::CString('1') ] = &o1, data[ ::CString('2') ] = &o2,
data[ ::CString('3') ] = &o3, data[ ::CString('4') ] = &o4;
::test_CMapStringToPtr(data);
}
{
std::map< ::CString, ::CString > data;
CString o0('a'), o1('b'), o2('c'), o3('d'), o4('e');
data[ ::CString('0') ] = o0, data[ ::CString('1') ] = o1, data[ ::CString('2') ] = o2,
data[ ::CString('3') ] = o3, data[ ::CString('4') ] = o4;
::test_CMapStringToString(data);
}
{
std::map< WORD, CObject * > data;
::CDWordArray o0, o1, o2, o3, o4;
data[21] = &o3, data[52] = &o2, data[12] = &o1, data[76] = &o0, data[54] = &o4;
::test_CMapWordToOb(data);
}
{
std::map< WORD, void * > data;
::CDWordArray o0, o1, o2, o3, o4;
data[21] = &o3, data[52] = &o2, data[12] = &o1, data[76] = &o0, data[54] = &o4;
::test_CMapWordToPtr(data);
}
// templates
//
{
std::string data("0987654321qwertyuiop");
::test_CArray(data);
::test_CList(data);
}
{
std::wstring data(L"asdfghjklzxcvbnm");
::test_CArray(data);
::test_CList(data);
}
{
std::map< int, std::string > data;
data[0] = "abcde", data[1] = "ajfie", data[2] = "lij", data[3] = "abc", data[4] = "ioiu";
::test_CMap(data);
}
// typed
//
{
::test_CTypedPtrArray();
::test_CTypedPtrList();
::test_CTypedPtrMap();
}
// strings
//
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
{
std::string data("123456789 abcdefghijklmn");
::test_CString(data);
}
#endif
} // test_mfc
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite *
init_unit_test_suite(int argc, char* argv[])
{
test_suite *test = BOOST_TEST_SUITE("MFC Range Test Suite");
test->add(BOOST_TEST_CASE(&test_mfc));
(void)argc, (void)argv; // unused
return test;
}

114
test/partial_workaround.cpp Normal file
View File

@ -0,0 +1,114 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/range/detail/implementation_help.hpp>
#include <boost/test/test_tools.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//#define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 1
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/size_type.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <iostream>
#include <vector>
using namespace boost;
using namespace std;
void check_partial_workaround()
{
using namespace range_detail;
using type_traits::yes_type;
using type_traits::no_type;
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
char* c_ptr;
const char* cc_ptr;
wchar_t* w_ptr;
const wchar_t* cw_ptr;
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( c_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cc_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( w_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cw_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_char_ptr_impl( c_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_char_ptr_impl( cc_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_wchar_t_ptr_impl( w_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_wchar_t_ptr_impl( cw_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( c_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( cc_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( w_ptr ) ) );
BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( cw_ptr ) ) );
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_,
boost::range_detail::range< vector<int> >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_pair_,
boost::range_detail::range< pair<int,int> >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::array_,
boost::range_detail::range< int[42] >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::char_ptr_,
boost::range_detail::range< char* >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_char_ptr_,
boost::range_detail::range< const char* >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::wchar_t_ptr_,
boost::range_detail::range< wchar_t* >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_wchar_t_ptr_,
boost::range_detail::range< const wchar_t* >::type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_,
boost::range_detail::range< vector<int> >::type >::value ));
}
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
void check_partial_workaround()
{
//
// test if warnings are generated
//
std::size_t s = boost::range_detail::array_size( "foo" );
BOOST_CHECK_EQUAL( s, 4u );
}
#endif
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_partial_workaround ) );
return test;
}

79
test/reversible_range.cpp Normal file
View File

@ -0,0 +1,79 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/rbegin.hpp>
#include <boost/range/rend.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <vector>
#include <algorithm>
using namespace boost;
using namespace std;
void check_iterator()
{
typedef vector<int> vec_t;
typedef vec_t::iterator iterator;
typedef pair<iterator,iterator> pair_t;
typedef range_reverse_iterator<pair_t>::type rev_iterator;
typedef pair<rev_iterator,rev_iterator> rev_pair_t;
vec_t vec;
pair_t p = make_pair( vec.begin(), vec.end() );
rev_pair_t rp = make_pair( rbegin( p ), rend( p ) );
int a[] = {1,2,3,4,5,6,7,8,9,10};
const int ca[] = {1,2,3,4,5,6,7,8,9,10,11,12};
BOOST_CHECK( rbegin( vec ) == range_reverse_iterator<vec_t>::type( vec.end() ) );
BOOST_CHECK( rend( vec ) == range_reverse_iterator<vec_t>::type( vec.begin() ) );
BOOST_CHECK( std::distance( rbegin( vec ), rend( vec ) ) == std::distance( begin( vec ), end( vec ) ) );
BOOST_CHECK( rbegin( p ) == begin( rp ) );
BOOST_CHECK( rend( p ) == end( rp ) );
BOOST_CHECK( std::distance( rbegin( p ), rend( p ) ) == std::distance( begin( rp ), end( rp ) ) );
BOOST_CHECK( std::distance( begin( p ), end( p ) ) == std::distance( rbegin( rp ), rend( rp ) ) );
BOOST_CHECK_EQUAL( &*begin( a ), &*( rend( a ) - 1 ) );
BOOST_CHECK_EQUAL( &*( end( a ) - 1 ), &*rbegin( a ) );
BOOST_CHECK_EQUAL( &*begin( ca ), &*( rend( ca ) - 1 ) );
BOOST_CHECK_EQUAL( &*( end( ca ) - 1 ), &*rbegin( ca ) );
}
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_iterator ) );
return test;
}

77
test/std_container.cpp Normal file
View File

@ -0,0 +1,77 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <vector>
using namespace boost;
void check_std_container()
{
typedef std::vector<int> vec_t;
vec_t vec;
vec.push_back( 3 ); vec.push_back( 4 );
const vec_t cvec( vec );
BOOST_STATIC_ASSERT(( is_same< range_value<vec_t>::type, vec_t::value_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<vec_t>::type, vec_t::difference_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<vec_t>::type, vec_t::size_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
BOOST_STATIC_ASSERT(( is_same< range_value<const vec_t>::type, vec_t::value_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<const vec_t>::type, vec_t::difference_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<const vec_t>::type, vec_t::size_type >::value ));
BOOST_CHECK( begin( vec ) == vec.begin() );
BOOST_CHECK( end( vec ) == vec.end() );
BOOST_CHECK( empty( vec ) == vec.empty() );
BOOST_CHECK( (std::size_t)size( vec ) == vec.size() );
BOOST_CHECK( begin( cvec ) == cvec.begin() );
BOOST_CHECK( end( cvec ) == cvec.end() );
BOOST_CHECK( empty( cvec ) == cvec.empty() );
BOOST_CHECK( (std::size_t)size( cvec ) == cvec.size() );
}
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_std_container ) );
return test;
}

236
test/string.cpp Normal file
View File

@ -0,0 +1,236 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
//#define _MSL_USING_NAMESPACE 1
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/as_array.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/config.hpp>
#include <vector>
#include <fstream>
#include <algorithm>
template< class T >
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<T>::type
str_begin( T& r )
{
return boost::begin( boost::as_literal(r) );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<T>::type
str_end( T& r )
{
return boost::end( boost::as_literal(r) );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME boost::range_size<T>::type
str_size( const T& r )
{
return boost::size( boost::as_literal(r) );
}
template< class T >
inline bool
str_empty( T& r )
{
return boost::empty( boost::as_literal(r) );
}
template< typename Container, typename T >
BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type
find( Container& c, T value )
{
return std::find( str_begin(c), str_end(c),
value );
}
template< typename Container, typename T >
BOOST_DEDUCED_TYPENAME boost::range_iterator<const Container>::type
find( const Container& c, T value )
{
return std::find( str_begin(c), str_end(c),
value );
}
template< typename Container, typename T >
BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type
find_mutable( Container& c, T value )
{
str_size( c );
return std::find( str_begin(c), str_end(c),
value );
}
template< typename Container, typename T >
BOOST_DEDUCED_TYPENAME boost::range_iterator<const Container>::type
find_const( const Container& c, T value )
{
str_size( c );
return std::find( str_begin(c), str_end(c),
value );
}
std::vector<char>
check_rvalue_return()
{
return std::vector<char>( 10, 'm' );
}
using namespace boost;
void check_char()
{
typedef char* char_iterator_t;
typedef char char_array_t[10];
const char* char_s = "a string";
char my_string[] = "another string";
const char my_const_string[] = "another string";
const unsigned my_string_length = 14;
char* char_s2 = "a string";
BOOST_STATIC_ASSERT(( is_same< range_value<char_iterator_t>::type,
detail::iterator_traits<char_iterator_t>::value_type>::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_iterator_t>::type, char_iterator_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<char_iterator_t>::type,
::std::ptrdiff_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<char_iterator_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_iterator_t>::type, char_iterator_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const char*>::type, const char* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_value<char_array_t>::type,
char>::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_array_t>::type, char* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const char_array_t>::type, const char* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<char_array_t>::type,
::std::ptrdiff_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<char_array_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_array_t>::type, char* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const char_array_t>::type, const char* >::value ));
BOOST_CHECK_EQUAL( str_begin( char_s ), char_s );
std::size_t sz = str_size(char_s);
const char* str_end1 = str_begin( char_s ) + sz;
BOOST_CHECK_EQUAL( str_end( char_s ), str_end1 );
BOOST_CHECK_EQUAL( str_empty( char_s ), (char_s == 0 || char_s[0] == char()) );
BOOST_CHECK_EQUAL( sz, std::char_traits<char>::length( char_s ) );
BOOST_CHECK_EQUAL( str_begin( my_string ), my_string );
range_iterator<char_array_t>::type str_end2 = str_begin( my_string ) + str_size(my_string);
range_iterator<char_array_t>::type str_end3 = str_end(my_string);
BOOST_CHECK_EQUAL( str_end3, str_end2 );
BOOST_CHECK_EQUAL( str_empty( my_string ), (my_string == 0 || my_string[0] == char()) );
BOOST_CHECK_EQUAL( str_size( my_string ), my_string_length );
BOOST_CHECK_EQUAL( str_size( my_string ), std::char_traits<char>::length( my_string ) );
char to_search = 'n';
BOOST_CHECK( find_mutable( char_s, to_search ) != str_end( char_s ) );
BOOST_CHECK( find_const( char_s, to_search ) != str_end(char_s) );
BOOST_CHECK( find_mutable( my_string, to_search ) != str_end(my_string) );
BOOST_CHECK( find_const( my_string, to_search ) != str_end(my_string) );
BOOST_CHECK( find_mutable( char_s2, to_search ) != str_end(char_s) );
BOOST_CHECK( find_const( char_s2, to_search ) != str_end(char_s2) );
BOOST_CHECK( find_const( as_array( my_string ), to_search ) != str_end(my_string) );
BOOST_CHECK( find_const( as_array( my_const_string ), to_search ) != str_end(my_string) );
//
// Test that as_literal() always scan for null terminator
//
char an_array[] = "foo\0bar";
BOOST_CHECK_EQUAL( str_begin( an_array ), an_array );
BOOST_CHECK_EQUAL( str_end( an_array ), an_array + 3 );
BOOST_CHECK_EQUAL( str_size( an_array ), 3 );
const char a_const_array[] = "foobar\0doh";
BOOST_CHECK_EQUAL( str_begin( a_const_array ), a_const_array );
BOOST_CHECK_EQUAL( str_end( a_const_array ), a_const_array + 6 );
BOOST_CHECK_EQUAL( str_size( a_const_array ), 6 );
}
void check_string()
{
check_char();
#ifndef BOOST_NO_STD_WSTRING
typedef wchar_t* wchar_iterator_t;
const wchar_t* char_ws = L"a wide string";
wchar_t my_wstring[] = L"another wide string";
wchar_t* char_ws2 = L"a wide string";
BOOST_STATIC_ASSERT(( is_same< range_value<wchar_iterator_t>::type,
detail::iterator_traits<wchar_iterator_t>::value_type>::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<wchar_iterator_t>::type, wchar_iterator_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const wchar_t*>::type, const wchar_t* >::value ));
BOOST_STATIC_ASSERT(( is_same< range_difference<wchar_iterator_t>::type,
detail::iterator_traits<wchar_iterator_t>::difference_type >::value ));
BOOST_STATIC_ASSERT(( is_same< range_size<wchar_iterator_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<wchar_iterator_t>::type, wchar_iterator_t >::value ));
BOOST_STATIC_ASSERT(( is_same< range_iterator<const wchar_t*>::type, const wchar_t* >::value ));
std::size_t sz = str_size( char_ws );
BOOST_CHECK_EQUAL( str_begin( char_ws ), char_ws );
BOOST_CHECK_EQUAL( str_end(char_ws), (str_begin( char_ws ) + sz) );
BOOST_CHECK_EQUAL( str_empty( char_ws ), (char_ws == 0 || char_ws[0] == wchar_t()) );
BOOST_CHECK_EQUAL( sz, std::char_traits<wchar_t>::length( char_ws ) );
wchar_t to_search = L'n';
BOOST_CHECK( find( char_ws, to_search ) != str_end(char_ws) );
#if BOOST_WORKAROUND(_MSC_VER, BOOST_TESTED_AT(1300))
BOOST_CHECK( find( my_wstring, to_search ) != str_end(my_wstring) );
#endif
#endif
find( check_rvalue_return(), 'n' );
}
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_string ) );
return test;
}

157
test/sub_range.cpp Normal file
View File

@ -0,0 +1,157 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# pragma warn -8091 // supress warning in Boost.Test
# pragma warn -8057 // unused argument argc/argv in Boost.Test
#endif
#include <boost/range/sub_range.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/test/test_tools.hpp>
#include <iostream>
#include <string>
#include <vector>
using namespace boost;
using namespace std;
void check_sub_range()
{
typedef string::iterator iterator;
typedef string::const_iterator const_iterator;
typedef iterator_range<iterator> irange;
typedef iterator_range<const_iterator> cirange;
string str = "hello world";
const string cstr = "const world";
irange r = make_iterator_range( str );
r = make_iterator_range( str.begin(), str.end() );
cirange r2 = make_iterator_range( cstr );
r2 = make_iterator_range( cstr.begin(), cstr.end() );
r2 = make_iterator_range( str );
typedef sub_range<string> srange;
typedef sub_range<const string> csrange;
srange s = r;
BOOST_CHECK( r == r );
BOOST_CHECK( s == r );
s = make_iterator_range( str );
csrange s2 = r;
s2 = r2;
s2 = make_iterator_range( cstr );
BOOST_CHECK( r2 == r2 );
BOOST_CHECK( s2 != r2 );
s2 = make_iterator_range( str );
BOOST_CHECK( !(s != s) );
BOOST_CHECK( r.begin() == s.begin() );
BOOST_CHECK( r2.begin()== s2.begin() );
BOOST_CHECK( r.end() == s.end() );
BOOST_CHECK( r2.end() == s2.end() );
BOOST_CHECK_EQUAL( r.size(), s.size() );
BOOST_CHECK_EQUAL( r2.size(), s2.size() );
//#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// if( !(bool)r )
// BOOST_CHECK( false );
// if( !(bool)r2 )
// BOOST_CHECK( false );
// if( !(bool)s )
// BOOST_CHECK( false );
// if( !(bool)s2 )
// BOOST_CHECK( false );
//#else
if( !r )
BOOST_CHECK( false );
if( !r2 )
BOOST_CHECK( false );
if( !s )
BOOST_CHECK( false );
if( !s2 )
BOOST_CHECK( false );
//#endif
cout << r << r2 << s << s2;
string res = copy_range<string>( r );
BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) );
r.empty();
s.empty();
r.size();
s.size();
//
// As of range v2 not legal anymore.
//
//irange singular_irange;
//BOOST_CHECK( singular_irange.empty() );
//BOOST_CHECK( singular_irange.size() == 0 );
//
//srange singular_srange;
//BOOST_CHECK( singular_srange.empty() );
//BOOST_CHECK( singular_srange.size() == 0 );
//
//BOOST_CHECK( empty( singular_irange ) );
//BOOST_CHECK( empty( singular_srange ) );
//
srange rr = make_iterator_range( str );
BOOST_CHECK( rr.equal( r ) );
rr = make_iterator_range( str.begin(), str.begin() + 5 );
BOOST_CHECK( rr == as_literal("hello") );
BOOST_CHECK( rr != as_literal("hell") );
BOOST_CHECK( rr < as_literal("hello dude") );
BOOST_CHECK( as_literal("hello") == rr );
BOOST_CHECK( as_literal("hell") != rr );
BOOST_CHECK( ! (as_literal("hello dude") < rr ) );
irange rrr = rr;
BOOST_CHECK( rrr == rr );
BOOST_CHECK( !( rrr != rr ) );
BOOST_CHECK( !( rrr < rr ) );
const irange cr = make_iterator_range( str );
BOOST_CHECK_EQUAL( cr.front(), 'h' );
BOOST_CHECK_EQUAL( cr.back(), 'd' );
BOOST_CHECK_EQUAL( cr[1], 'e' );
BOOST_CHECK_EQUAL( cr(1), 'e' );
rrr = make_iterator_range( str, 1, -1 );
BOOST_CHECK( rrr == as_literal("ello worl") );
rrr = make_iterator_range( rrr, -1, 1 );
BOOST_CHECK( rrr == str );
rrr.front() = 'H';
rrr.back() = 'D';
rrr[1] = 'E';
BOOST_CHECK( rrr == as_literal("HEllo worlD") );
}
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add( BOOST_TEST_CASE( &check_sub_range ) );
return test;
}