Compare commits

..

148 Commits

Author SHA1 Message Date
910fa2cebf This commit was manufactured by cvs2svn to create branch
'thread_rewrite'.

[SVN r30953]
2005-09-13 14:20:32 +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
40 changed files with 2939 additions and 536 deletions

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

@ -24,92 +24,171 @@
#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_const_iterator<C>::type
boost_range_begin( const C& c )
{
return c.begin();
return c.begin();
}
template< typename C >
inline BOOST_DEDUCED_TYPENAME iterator_of<C>::type
begin( C& c )
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
boost_range_begin( C& c )
{
return c.begin();
return c.begin();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator begin( const std::pair<Iterator,Iterator>& p )
inline Iterator boost_range_begin( const std::pair<Iterator,Iterator>& p )
{
return p.first;
}
template< typename Iterator >
inline Iterator begin( std::pair<Iterator,Iterator>& p )
inline Iterator boost_range_begin( std::pair<Iterator,Iterator>& p )
{
return p.first;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline const T* begin( const T (&array)[sz] )
inline const T* boost_range_begin( const T (&array)[sz] )
{
return array;
}
template< typename T, std::size_t sz >
inline T* begin( T (&array)[sz] )
inline T* boost_range_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 )
#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// CW up to 9.3 and borland have troubles with function ordering
inline const char* boost_range_begin( const char* s )
{
return s;
}
} // namespace 'range'
inline char* boost_range_begin( char* s )
{
return s;
}
using range::begin;
inline const wchar_t* boost_range_begin( const wchar_t* s )
{
return s;
}
inline wchar_t* boost_range_begin( wchar_t* s )
{
return s;
}
#else
inline const char* boost_range_begin( const char*& s )
{
return s;
}
inline char* boost_range_begin( char*& s )
{
return s;
}
inline const wchar_t* boost_range_begin( const wchar_t*& s )
{
return s;
}
inline wchar_t* boost_range_begin( wchar_t*& s )
{
return s;
}
#endif
#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 boost_range_begin( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type begin( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_begin( r );
}
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB and CW are not able to overload pointer when class overloads are also available.
template<>
inline range_const_iterator<const char*>::type begin<const char*>( const char*& r )
{
return r;
}
template<>
inline range_const_iterator<const wchar_t*>::type begin<const wchar_t*>( const wchar_t*& r )
{
return r;
}
#endif
} // namespace boost
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
const_begin( const T& r )
{
return begin( r );
}
}
#endif

View File

@ -11,35 +11,42 @@
#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 ) || __MWERKS__ <= 0x3003
#if _MSC_VER <= 1300 && !defined( __COMO__ ) && !defined( __GNUC__ ) && __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

View File

@ -31,7 +31,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct const_iterator_of
struct range_const_iterator
{
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
};
@ -41,13 +41,13 @@ 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> >
struct range_const_iterator< const std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
@ -57,13 +57,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
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] >
struct range_const_iterator< const T[sz] >
{
typedef const T* type;
};
@ -73,25 +73,49 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct const_iterator_of< char* >
struct range_const_iterator< char* >
{
typedef const char* type;
};
template<>
struct const_iterator_of< wchar_t* >
struct range_const_iterator< wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct const_iterator_of< const char* >
struct range_const_iterator< const char* >
{
typedef const char* type;
};
template<>
struct const_iterator_of< const wchar_t* >
struct range_const_iterator< const wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct range_const_iterator< char* const >
{
typedef const char* type;
};
template<>
struct range_const_iterator< wchar_t* const >
{
typedef const wchar_t* type;
};
template<>
struct range_const_iterator< const char* const >
{
typedef const char* type;
};
template<>
struct range_const_iterator< const wchar_t* const >
{
typedef const wchar_t* type;
};

View File

@ -26,10 +26,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct const_reverse_iterator_of
struct range_const_reverse_iterator
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type > type;
BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type > type;
};
} // namespace boost

View File

@ -11,8 +11,13 @@
#ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
#define BOOST_RANGE_DETAIL_BEGIN_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#include <boost/range/result_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_result_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_result_iterator<P>::type fun( const P& p )
{
return p.first;
}
@ -57,11 +62,19 @@ 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
};
//////////////////////////////////////////////////////////////////////
@ -105,13 +118,13 @@ namespace boost
}
};
} // 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_result_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

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'

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,12 +41,32 @@ 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
struct range_const_iterator_<array_>
{
template< typename T >
struct pts
{
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
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_>
@ -90,7 +111,7 @@ namespace boost
}
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

@ -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;
};
}

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'

View File

@ -11,26 +11,37 @@
#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/detail/implementation_help.hpp>
# include <boost/range/result_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_result_iterator<C>::type
fun( C& c )
{
return c.end();
};
@ -41,10 +52,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_result_iterator<P>::type
fun( const P& p )
{
return p.second;
}
@ -55,33 +67,41 @@ 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 );
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
{
return t + remove_extent<T>::size;
}
#endif
};
template<>
struct collection_end<char_array_>
struct range_end<char_array_>
{
template< typename T, std::size_t sz >
static std::size_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<wchar_t_array_>
struct range_end<wchar_t_array_>
{
template< typename T, std::size_t sz >
static std::size_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 );
}
};
@ -90,7 +110,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<char_ptr_>
struct range_end<char_ptr_>
{
static char* fun( char* s )
{
@ -99,7 +119,7 @@ namespace boost
};
template<>
struct collection_end<const_char_ptr_>
struct range_end<const_char_ptr_>
{
static const char* fun( const char* s )
{
@ -108,7 +128,7 @@ namespace boost
};
template<>
struct collection_end<wchar_t_ptr_>
struct range_end<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
@ -118,7 +138,7 @@ namespace boost
template<>
struct collection_end<const_wchar_t_ptr_>
struct range_end<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
@ -129,13 +149,13 @@ namespace boost
} // namespace 'range_detail'
template< typename C >
inline BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type
inline BOOST_RANGE_DEDUCED_TYPENAME range_result_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

View File

@ -51,106 +51,107 @@ 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], int )
{
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], int )
{
return array + sz - 1;
return boost_range_array + sz;
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz] )
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
return boost_range_array + sz - 1;
}
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
{
return boost_range_array + sz - 1;
}
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
{
typedef BOOST_RANGE_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 array_end<T,sz>( boost_range_array, tag() );
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz] )
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
typedef BOOST_RANGE_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 array_end<T,sz>( boost_range_array, tag() );
}
/////////////////////////////////////////////////////////////////////
// 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], int )
{
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], int )
{
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 )
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_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 )
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_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] )
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<const char,T>::value || is_same<const wchar_t,T>::value ||
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() );
return array_size<T,sz>( boost_range_array, tag() );
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T (&array)[sz] )
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
typedef BOOST_RANGE_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() );
return array_size<T,sz>( boost_range_array, tag() );
}
} // namespace 'range_detail'

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,12 +49,31 @@ 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
struct range_iterator_<array_>
{
template< typename T >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
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_>
@ -86,15 +114,14 @@ namespace boost
typedef const wchar_t* type;
};
};
}
template< typename C >
class iterator_of
class range_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,97 @@
// 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/
//
#if !defined( BOOST_RANGE_DETAIL_MFC_CARRAY_HPP ) && defined( BOOST_RANGE_ENABLE_MCF_CARRAY )
#define BOOST_RANGE_DETAIL_MFC_CARRAY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <afxtempl.h> // for CArray
#include <boost/range/config.hpp>
#include <boost/range/metafunctions.hpp>
namespace boost
{
template< class T, class U >
struct range_iterator< CArray<T,U> >
{
typedef T* type;
};
//
// Why is this needed?!?
//
template< class T, class U >
struct range_iterator< const CArray<T,U> >
{
typedef T* type;
};
template< class T, class U >
struct range_const_iterator< CArray<T,U> >
{
typedef const T* type;
};
template< class T, class U >
struct range_difference< CArray<T,U> >
{
typedef std::ptrdiff_t type;
};
template< class T, class U >
struct range_size< CArray<T,U> >
{
typedef int type;
};
template< class T, class U >
struct range_value< CArray<T,U> >
{
typedef T type;
};
template< class T, class U >
T* boost_range_begin( CArray<T,U>& r )
{
return r.GetData();
}
template< class T, class U >
const T* boost_range_begin( const CArray<T,U>& r )
{
return r.GetData();
}
template< class T, class U >
int boost_range_size( const CArray<T,U>& r )
{
return r.GetSize();
}
template< class T, class U >
T* boost_range_end( CArray<T,U>& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
template< class T, class U >
const T* boost_range_end( const CArray<T,U>& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
// default 'empty()' ok
} // namespace 'boost'
#endif

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/
//
#if !defined(BOOST_RANGE_DETAIL_MFC_CSTRING_HPP) && defined(BOOST_RANGE_ENABLE_MFC)
#define BOOST_RANGE_DETAIL_MFC_CSTRING_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <afx.h> // for CString
#include <boost/range/config.hpp>
#include <boost/range/metafunctions.hpp>
namespace boost
{
template<>
struct range_iterator< CString >
{
typedef TCHAR* type;
};
//
// Why is this needed?!?
//
template<>
struct range_iterator< const CString >
{
typedef TCHAR* type;
};
template<>
struct range_const_iterator< CString >
{
typedef const TCHAR* type;
};
template<>
struct range_difference< CString >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_size< CString >
{
typedef int type;
};
template<>
struct range_value< CString >
{
typedef TCHAR type;
};
TCHAR* boost_range_begin( CString& r )
{
return r.GetBuffer(0);
}
const TCHAR* boost_range_begin( const CString& r )
{
return (LPCTSTR)r;
}
int boost_range_size( const CString& r )
{
return r.GetLength();
}
TCHAR* boost_range_end( CString& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
const TCHAR* range_adl_end( const CString& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
// default 'empty()' ok
} // namespace 'boost'
#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

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( ... );
//////////////////////////////////////////////////////////////////////

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

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,6 +54,16 @@ namespace boost
};
};
template<>
struct range_size_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<char_ptr_>
{
@ -92,16 +102,15 @@ namespace boost
{
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;
};
}

View File

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

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,12 +42,29 @@ 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
struct range_value_type_<array_>
{
template< typename T >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
};
};
template<>
struct range_value_type_<char_array_>
{
template< typename T >
struct pts
{
typedef char type;
};
};
template<>
struct range_value_type_<char_ptr_>
@ -91,7 +109,7 @@ namespace boost
}
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

View File

@ -32,7 +32,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct difference_type_of
struct range_difference
{
typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
};
@ -42,14 +42,14 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct difference_type_of< std::pair<Iterator,Iterator> >
struct range_difference< 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> >
struct range_difference< const std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_difference<Iterator>::type type;
@ -61,13 +61,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct difference_type_of< T[sz] >
struct range_difference< T[sz] >
{
typedef std::ptrdiff_t type;
};
template< typename T, std::size_t sz >
struct difference_type_of< const T[sz] >
struct range_difference< const T[sz] >
{
typedef std::ptrdiff_t type;
};
@ -77,25 +77,49 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct difference_type_of< char* >
struct range_difference< char* >
{
typedef std::ptrdiff_t type;
};
template<>
struct difference_type_of< wchar_t* >
struct range_difference< wchar_t* >
{
typedef std::ptrdiff_t type;
};
template<>
struct difference_type_of< const char* >
struct range_difference< const char* >
{
typedef std::ptrdiff_t type;
};
template<>
struct difference_type_of< const wchar_t* >
struct range_difference< const wchar_t* >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< char* const >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< wchar_t* const >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< const char* const >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< const wchar_t* const >
{
typedef std::ptrdiff_t type;
};

View File

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

View File

@ -26,24 +26,29 @@
#include <boost/range/const_iterator.hpp>
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
end( const C& c )
inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
boost_range_end( const C& c )
{
return c.end();
}
template< typename C >
inline BOOST_DEDUCED_TYPENAME iterator_of<C>::type
end( C& c )
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
boost_range_end( C& c )
{
return c.end();
}
@ -53,13 +58,13 @@ namespace range
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator end( const std::pair<Iterator,Iterator>& p )
inline Iterator boost_range_end( const std::pair<Iterator,Iterator>& p )
{
return p.second;
}
template< typename Iterator >
inline Iterator end( std::pair<Iterator,Iterator>& p )
inline Iterator boost_range_end( std::pair<Iterator,Iterator>& p )
{
return p.second;
}
@ -69,47 +74,125 @@ namespace range
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline const T* end( const T (&array)[sz] )
inline const T* boost_range_end( const T (&array)[sz] )
{
return range_detail::array_end( array );
return range_detail::array_end<T,sz>( array );
}
template< typename T, std::size_t sz >
inline T* end( T (&array)[sz] )
inline T* boost_range_end( T (&array)[sz] )
{
return range_detail::array_end( array );
return range_detail::array_end<T,sz>( array );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline char* end( char* s )
#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// CW up to 9.3 and borland have troubles with function ordering
inline char* boost_range_end( char* s )
{
return range_detail::str_end( s );
}
inline wchar_t* end( wchar_t* s )
inline wchar_t* boost_range_end( wchar_t* s )
{
return range_detail::str_end( s );
}
inline const char* end( const char* s )
inline const char* boost_range_end( const char* s )
{
return range_detail::str_end( s );
}
inline const wchar_t* end( const wchar_t* s )
inline const wchar_t* boost_range_end( const wchar_t* s )
{
return range_detail::str_end( s );
}
#else
inline char* boost_range_end( char*& s )
{
return range_detail::str_end( s );
}
} // namespace 'range'
using range::end;
inline wchar_t* boost_range_end( wchar_t*& s )
{
return range_detail::str_end( s );
}
inline const char* boost_range_end( const char*& s )
{
return range_detail::str_end( s );
}
inline const wchar_t* boost_range_end( const wchar_t*& s )
{
return range_detail::str_end( s );
}
#endif
#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 end( T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_end( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type end( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_end( r );
}
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB and CW are not able to overload pointer when class overloads are also available.
template<>
inline range_const_iterator<const char*>::type end<const char*>( const char*& r )
{
return range_detail::str_end( r );
}
template<>
inline range_const_iterator<const wchar_t*>::type end<const wchar_t*>( const wchar_t*& r )
{
return range_detail::str_end( r );
}
#endif
} // namespace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
const_end( const T& r )
{
return end( r );
}
}
#endif

View File

@ -32,7 +32,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct iterator_of
struct range_iterator
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
@ -42,13 +42,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct iterator_of< std::pair<Iterator,Iterator> >
struct range_iterator< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
template< typename Iterator >
struct iterator_of< const std::pair<Iterator,Iterator> >
struct range_iterator< const std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
@ -58,13 +58,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct iterator_of< T[sz] >
struct range_iterator< T[sz] >
{
typedef T* type;
};
template< typename T, std::size_t sz >
struct iterator_of< const T[sz] >
struct range_iterator< const T[sz] >
{
typedef const T* type;
};
@ -74,25 +74,49 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct iterator_of< char* >
struct range_iterator< char* >
{
typedef char* type;
};
template<>
struct iterator_of< wchar_t* >
struct range_iterator< wchar_t* >
{
typedef wchar_t* type;
};
template<>
struct iterator_of< const char* >
struct range_iterator< const char* >
{
typedef const char* type;
};
template<>
struct iterator_of< const wchar_t* >
struct range_iterator< const wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct range_iterator< char* const >
{
typedef char* type;
};
template<>
struct range_iterator< wchar_t* const >
{
typedef wchar_t* type;
};
template<>
struct range_iterator< const char* const >
{
typedef const char* type;
};
template<>
struct range_iterator< const wchar_t* const >
{
typedef const wchar_t* type;
};

View File

@ -11,14 +11,29 @@
#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>
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
#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/detail/workaround.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/assert.hpp>
#include <iterator>
#include <algorithm>
#include <ostream>
#ifndef BOOST_OLD_IOSTREAMS
# include <ostream>
#else
# include <ostream.h>
#endif
#include <cstddef>
@ -28,7 +43,60 @@
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 )
{
using boost::begin;
return IteratorT( begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
using boost::end;
return IteratorT( end( r ) );
}
};
template< class Left, class Right >
inline bool equal( const Left& l, const Right& r )
{
typedef BOOST_DEDUCED_TYPENAME boost::range_size<Left>::type sz_type;
sz_type l_size = size( l ),
r_size = size( r );
if( l_size != r_size )
return false;
return std::equal( begin(l), end(l),
begin(r) );
}
template< class Left, class Right >
inline bool less_than( const Left& l, const Right& r )
{
return std::lexicographical_compare( begin(l),
end(l),
begin(r),
end(r) );
}
struct range_tag { };
struct const_range_tag { };
}
// iterator range template class -----------------------------------------//
@ -52,17 +120,28 @@ 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;
//! const_iterator type
/*!
@ -73,161 +152,309 @@ namespace boost {
//! iterator type
typedef IteratorT iterator;
//! Default constructor
iterator_range() {}
iterator_range() : m_Begin( iterator() ), m_End( iterator() ),
singular( true )
{ }
/*
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
iterator_range( this_type r ) :
: m_Begin(r.begin()), m_End(r.end())
{ }
this_type& operator=( this_type r )
{
m_Begin = r.begin();
m_End = r.end();
return *this;
}
#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), singular(false) {}
//! 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 ) ),
singular(false) {}
//! 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 ) ),
singular(false) {}
//! 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 ) ),
singular(false) {}
//! 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 ) ),
singular(false) {}
//! 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();
//
// remark: this need not necessarily be true, but it does no harm
//
singular = r.singular;
return *this;
}
#endif
template< class Iterator >
iterator_range& operator=( const iterator_range<Iterator>& r )
{
m_Begin = r.begin();
m_End = r.end();
//
// remark: this need not necessarily be true, but it does no harm
//
singular = r.empty();
return *this;
}
template< class ForwardRange >
iterator_range& operator=( ForwardRange& r )
{
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
singular = false;
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 );
singular = false;
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
{
return m_Begin;
}
//! end access
/*!
Retrieve the end iterator
*/
IteratorT end() const
{
return m_End;
}
//! Size of the range
/*!
Retrieve the size of the range
*/
size_type size() const
{
if( singular )
return 0;
return std::distance( m_Begin, m_End );
}
bool empty() const
{
if( singular )
return true;
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
{
return singular == r.singular && m_Begin == r.m_Begin && m_End == r.m_End;
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
bool operator==( const iterator_range& r ) const
{
return iterator_range_detail::equal( *this, r );
}
bool operator!=( const iterator_range& r ) const
{
return !operator==(r);
}
bool operator<( const iterator_range& r ) const
{
return iterator_range_detail::less_than( *this, r );
}
#endif
public: // convenience
value_type& front() const
{
BOOST_ASSERT( !empty() );
return *m_Begin;
}
value_type& back() const
{
BOOST_ASSERT( !empty() );
IteratorT last( m_End );
return *--last;
}
value_type& operator[]( size_type sz ) const
{
//BOOST_STATIC_ASSERT( is_random_access );
BOOST_ASSERT( sz < size() );
return m_Begin[sz];
}
private:
// begin and end iterators
IteratorT m_Begin;
IteratorT m_End;
bool singular;
};
// iterator range free-standing operators ---------------------------//
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#else
template< class Iterator >
inline bool empty( const iterator_range<Iterator>& r )
{
//
// this will preserve the well-defined empty() even
// though 'r' is singular.
//
return r.empty();
}
#endif
#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<Elem>(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
/////////////////////////////////////////////////////////////////////
// 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 +471,97 @@ namespace boost {
{
return iterator_range<IteratorT>( Begin, End );
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
make_iterator_range( Range& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
( begin( r ), 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_const_iterator<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_const_iterator<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_result_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 )
{
if( advance_begin == 0 && advance_end == 0 )
return make_iterator_range( r );
BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type
new_begin = begin( r ),
new_end = 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_result_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_const_iterator<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
@ -280,24 +576,8 @@ namespace boost {
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;
}
} // namespace 'boost'
#undef BOOST_OLD_IOSTREAMS
#endif

View File

@ -8,8 +8,8 @@
// 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

View File

@ -16,26 +16,51 @@
#endif
#include <boost/range/end.hpp>
#include <boost/range/reverse_result_iterator.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_result_iterator<C>::type
rbegin( C& c )
{
return BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type( end( c ) );
return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type( 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( end( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
rbegin( const C& c )
{
return BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type( end( c ) );
typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
iter_type;
return iter_type( end( c ) );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<T>::type
const_rbegin( const T& r )
{
return rbegin( r );
}
} // namespace 'boost'
#endif

View File

@ -16,24 +16,49 @@
#endif
#include <boost/range/begin.hpp>
#include <boost/range/reverse_result_iterator.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_result_iterator<C>::type
rend( C& c )
{
return BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type( begin( c ) );
return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type( 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( begin( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
rend( const C& c )
{
return BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type( begin( c ) );
typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
iter_type;
return iter_type( begin( c ) );
}
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<T>::type
const_rend( const T& r )
{
return rend( r );
}
} // namespace 'boost'

View File

@ -28,12 +28,12 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct result_iterator_of
struct range_result_iterator
{
typedef BOOST_CT_DEDUCED_TYPENAME
typedef BOOST_RANGE_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;
BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type,
BOOST_DEDUCED_TYPENAME range_iterator<C>::type >::type type;
};
} // namespace boost

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;
};

View File

@ -26,14 +26,12 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct reverse_result_iterator_of
struct range_reverse_result_iterator
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type > type;
BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type > type;
};
} // namespace boost
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View File

@ -22,21 +22,25 @@
#else
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/size_type.hpp>
#include <cstddef>
#include <iterator>
#include <utility>
namespace boost {
namespace range
namespace boost
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// default
// primary template
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_CT_DEDUCED_TYPENAME C::size_type
size( const C& c )
inline BOOST_DEDUCED_TYPENAME C::size_type
boost_range_size( const C& c )
{
return c.size();
}
@ -46,7 +50,7 @@ namespace range
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline std::size_t size( const std::pair<Iterator,Iterator>& p )
inline std::size_t boost_range_size( const std::pair<Iterator,Iterator>& p )
{
return std::distance( p.first, p.second );
}
@ -56,34 +60,61 @@ namespace range
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline std::size_t size( const T (&array)[sz] )
inline std::size_t boost_range_size( const T (&array)[sz] )
{
return range_detail::array_size( array );
return range_detail::array_size<T,sz>( array );
}
template< typename T, std::size_t sz >
inline std::size_t size( T (&array)[sz] )
inline std::size_t boost_range_size( T (&array)[sz] )
{
return range_detail::array_size( array );
return boost::range_detail::array_size<T,sz>( array );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline std::size_t size( const char* s )
inline std::size_t boost_range_size( const char* const& s )
{
return range_detail::str_size( s );
return boost::range_detail::str_size( s );
}
inline std::size_t size( const wchar_t* s )
inline std::size_t boost_range_size( const wchar_t* const& s )
{
return range_detail::str_size( s );
return boost::range_detail::str_size( s );
}
} // namespace 'range'
using range::size;
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
} // namespace 'range_detail'
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_size<T>::type size( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
using namespace range_detail;
#endif
return boost_range_size( r );
}
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB and CW are not able to overload pointer when class overloads are also available.
inline range_size<const char*>::type size( const char* r ) {
return range_detail::str_size( r );
}
inline range_size<char*>::type size( char* r ) {
return range_detail::str_size( r );
}
inline range_size<const wchar_t*>::type size( const wchar_t* r ) {
return range_detail::str_size( r );
}
inline range_size<wchar_t*>::type size( wchar_t* r ) {
return range_detail::str_size( r );
}
#endif
} // namespace 'boost'

View File

@ -31,7 +31,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct size_type_of
struct range_size
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
@ -41,13 +41,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct size_type_of< std::pair<Iterator,Iterator> >
struct range_size< std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
template< typename Iterator >
struct size_type_of< const std::pair<Iterator,Iterator> >
struct range_size< const std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
@ -57,13 +57,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct size_type_of< T[sz] >
struct range_size< T[sz] >
{
typedef std::size_t type;
};
template< typename T, std::size_t sz >
struct size_type_of< const T[sz] >
struct range_size< const T[sz] >
{
typedef std::size_t type;
};
@ -73,25 +73,49 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct size_type_of< char* >
struct range_size< char* >
{
typedef std::size_t type;
};
template<>
struct size_type_of< wchar_t* >
struct range_size< wchar_t* >
{
typedef std::size_t type;
};
template<>
struct size_type_of< const char* >
struct range_size< const char* >
{
typedef std::size_t type;
};
template<>
struct size_type_of< const wchar_t* >
struct range_size< const wchar_t* >
{
typedef std::size_t type;
};
template<>
struct range_size< char* const >
{
typedef std::size_t type;
};
template<>
struct range_size< wchar_t* const >
{
typedef std::size_t type;
};
template<>
struct range_size< const char* const >
{
typedef std::size_t type;
};
template<>
struct range_size< const wchar_t* const >
{
typedef std::size_t type;
};

View File

@ -13,36 +13,65 @@
#include <boost/range/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/reverse_result_iterator.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>
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_result_iterator<ForwardRange>::type >
{
typedef BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type iterator_t;
typedef BOOST_DEDUCED_TYPENAME range_result_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_result_iterator<ForwardRange>::type iterator;
typedef BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type const_iterator;
typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
public:
template< class Range2 >
sub_range( Range2& r ) : base( r )
sub_range() : base()
{ }
/*
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
typedef sub_range<ForwardRange> this_type;
sub_range( this_type r ) :
: base( r )
{ }
this_type& operator=( this_type r )
{
base::operator=( r );
return *this;
}
#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 Range2 >
sub_range( const Range2& r ) : base( r )
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 +79,84 @@ 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;
}
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(); }
size_type size() const { return base::size(); }
public: // convenience
value_type& front()
{
//
// performance discontinuity problem!!
//
return base::size();
return base::front();
}
const value_type& front() const
{
return base::front();
}
value_type& back()
{
return base::back();
}
const value_type& back() const
{
return base::back();
}
value_type& operator[]( size_type sz )
{
return base::operator[](sz);
}
const value_type& operator[]( size_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'
#endif

View File

@ -33,7 +33,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct value_type_of
struct range_value
{
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
};
@ -43,7 +43,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct value_type_of< std::pair<Iterator,Iterator> >
struct range_value< std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_value<Iterator>::type type;
@ -51,7 +51,7 @@ namespace boost
template< typename Iterator >
struct value_type_of< const std::pair<Iterator,Iterator> >
struct range_value< const std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_value<Iterator>::type type;
@ -62,13 +62,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct value_type_of< T[sz] >
struct range_value< T[sz] >
{
typedef T type;
};
template< typename T, std::size_t sz >
struct value_type_of< const T[sz] >
struct range_value< const T[sz] >
{
typedef const T type;
};
@ -78,25 +78,49 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct value_type_of< char* >
struct range_value< char* >
{
typedef char type;
};
template<>
struct value_type_of< wchar_t* >
struct range_value< wchar_t* >
{
typedef wchar_t type;
};
template<>
struct value_type_of< const char* >
struct range_value< const char* >
{
typedef const char type;
};
template<>
struct value_type_of< const wchar_t* >
struct range_value< const wchar_t* >
{
typedef const wchar_t type;
};
template<>
struct range_value< char* const >
{
typedef char type;
};
template<>
struct range_value< wchar_t* const >
{
typedef wchar_t type;
};
template<>
struct range_value< const char* const >
{
typedef const char type;
};
template<>
struct range_value< const wchar_t* const >
{
typedef const wchar_t type;
};