forked from boostorg/range
Compare commits
2 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
dbc625549d | |||
7f604c6126 |
@ -25,17 +25,17 @@
|
||||
[def __implementation_of_metafunctions__ [link boost.range.reference.semantics.metafunctions implementation of metafunctions]]
|
||||
[def __implementation_of_functions__ [link boost.range.reference.semantics.functions implementation of functions]]
|
||||
|
||||
[def __single_pass_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#singls-pass-iterators-lib-single-pass-iterators Single Pass Iterator]]
|
||||
[def __forward_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators Forward Traversal Iterator]]
|
||||
[def __bidirectional_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators Bidirectional Traversal Iterator]]
|
||||
[def __random_access_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators Random Access Traversal Iterator]]
|
||||
[def __new_style_iterators__ [@../../libs/iterator/doc/new-iter-concepts.html new style iterators]]
|
||||
[def __iterator_concepts__ [@../../libs/iterator/doc/iterator_concepts.html Iterator concepts]]
|
||||
[def __single_pass_iterator__ [@/libs/iterator/doc/new-iter-concepts.html#singls-pass-iterators-lib-single-pass-iterators Single Pass Iterator]]
|
||||
[def __forward_traversal_iterator__ [@/libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators Forward Traversal Iterator]]
|
||||
[def __bidirectional_traversal_iterator__ [@/libs/iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators Bidirectional Traversal Iterator]]
|
||||
[def __random_access_traversal_iterator__ [@/libs/iterator/doc/new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators Random Access Traversal Iterator]]
|
||||
[def __new_style_iterators__ [@/libs/iterator/doc/new-iter-concepts.html new style iterators]]
|
||||
[def __iterator_concepts__ [@/libs/iterator/doc/iterator_concepts.html Iterator concepts]]
|
||||
|
||||
[def __container__ [@http://www.sgi.com/Technology/STL/Container.html Container]]
|
||||
[def __metafunctions__ [@../../libs/mpl/doc/refmanual/metafunction.html metafunctions]]
|
||||
[def __concept_check__ [@../../libs/concept_check/index.html Boost Concept Check library]]
|
||||
[def __boost_array__ [@../../libs/array/index.html boost::array]]
|
||||
[def __metafunctions__ [@/libs/mpl/doc/refmanual/metafunction.html metafunctions]]
|
||||
[def __concept_check__ [@/libs/concept_check/index.html Boost Concept Check library]]
|
||||
[def __boost_array__ [@/libs/array/index.html boost::array]]
|
||||
[def __the_forwarding_problem__ [@http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]]
|
||||
|
||||
|
||||
@ -134,9 +134,9 @@ The motivation for the Range concept is that there are many useful Container-lik
|
||||
|
||||
Because of the second requirement, a Range object must be passed by (const or non-const) reference in generic code.
|
||||
|
||||
The operations that can be performed on a Range is dependent on the [@../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal traversal category] of the underlying iterator type. Therefore the range concepts are named to reflect which traversal category its iterators support. See also terminology and style guidelines. for more information about naming of ranges.
|
||||
The operations that can be performed on a Range is dependent on the [@/libs/range/iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal traversal category] of the underlying iterator type. Therefore the range concepts are named to reflect which traversal category its iterators support. See also terminology and style guidelines. for more information about naming of ranges.
|
||||
|
||||
The concepts described below specifies associated types as [@../../libs/mpl/doc/refmanual/metafunction.html metafunctions] and all functions as free-standing functions to allow for a layer of indirection.
|
||||
The concepts described below specifies associated types as [@/libs/mpl/doc/refmanual/metafunction.html metafunctions] and all functions as free-standing functions to allow for a layer of indirection.
|
||||
|
||||
[endsect]
|
||||
|
||||
@ -332,7 +332,7 @@ __bidirectional_range__
|
||||
|
||||
[section Concept Checking]
|
||||
|
||||
Each of the range concepts has a corresponding concept checking class in the file [@../../boost/range/concepts.hpp `boost/range/concepts.hpp`]. These classes may be used in conjunction with the __concept_check__ to insure that the type of a template parameter is compatible with a range concept. If not, a meaningful compile time error is generated. Checks are provided for the range concepts related to iterator traversal categories. For example, the following line checks that the type `T` models the __forward_range__ concept.
|
||||
Each of the range concepts has a corresponding concept checking class in the file [@/boost/range/concepts.hpp `boost/range/concepts.hpp`]. These classes may be used in conjunction with the __concept_check__ to insure that the type of a template parameter is compatible with a range concept. If not, a meaningful compile time error is generated. Checks are provided for the range concepts related to iterator traversal categories. For example, the following line checks that the type `T` models the __forward_range__ concept.
|
||||
|
||||
``
|
||||
function_requires<ForwardRangeConcept<T> >();
|
||||
|
@ -24,7 +24,7 @@
|
||||
to a somewhat clumsy use of the algorithms with redundant specification
|
||||
of container names. Therefore we would like to raise the abstraction level
|
||||
for algorithms so they specify their interface in terms of <a
|
||||
href="range.html">Ranges</a> as much as possible.
|
||||
href=range.html>Ranges</a> as much as possible.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -53,7 +53,7 @@
|
||||
<a href="range.html#bidirectional_range">Bidirectional Range</a> <li>
|
||||
<a href="range.html#random_access_range">Random Access Range</a> </ul>
|
||||
</ul>
|
||||
Notice how we have used the categories from the <a href="../../iterator/doc/new-iter-concepts.html">new
|
||||
Notice how we have used the categories from the <a href=../../iterator/doc/new-iter-concepts.html>new
|
||||
style iterators</a>.
|
||||
|
||||
<p>
|
||||
|
@ -27,9 +27,9 @@
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Class <a href="#iter_range"><code>iterator_range</code></a>
|
||||
Class <a href=#iter_range><code>iterator_range</code></a>
|
||||
<li>
|
||||
Class <a href="#sub_range"><code>sub_range</code></a>
|
||||
Class <a href=#sub_range><code>sub_range</code></a>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
@ -329,7 +329,7 @@ class can propagate constness since it knows what a corresponding
|
||||
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>& </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>difference_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>:
|
||||
</span><span class=comment>// rest of interface inherited from <a href="#iter_range"><code>iterator_range</code></a>
|
||||
</span><span class=comment>// rest of interface inherited from <a href=#iter_range><code>iterator_range</code></a>
|
||||
</span><span class=special>};
|
||||
</span>
|
||||
<span class=special>} </span><span class=comment>// namespace 'boost'</span>
|
||||
|
@ -8,8 +8,8 @@
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_AS_LITERAL_HPP
|
||||
#define BOOST_RANGE_AS_LITERAL_HPP
|
||||
#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
|
||||
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
@ -25,9 +25,7 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -38,12 +36,10 @@ namespace boost
|
||||
return strlen( s );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
inline std::size_t length( const wchar_t* s )
|
||||
{
|
||||
return wcslen( s );
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Remark: the compiler cannot choose between T* and T[sz]
|
||||
@ -61,7 +57,7 @@ namespace boost
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
|
||||
inline bool is_char_ptr( wchar_t* )
|
||||
{
|
||||
return true;
|
||||
@ -71,7 +67,6 @@ namespace boost
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class T >
|
||||
inline long is_char_ptr( T /* r */ )
|
||||
@ -112,13 +107,22 @@ namespace boost
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
|
||||
{
|
||||
return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
|
||||
return boost::make_iterator_range<Char*>( arr, arr + sz - 1 );
|
||||
#else
|
||||
return boost::make_iterator_range( arr, arr + sz - 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
|
||||
{
|
||||
return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
|
||||
return boost::make_iterator_range<const Char*>( arr, arr + sz - 1 );
|
||||
#else
|
||||
return boost::make_iterator_range( arr, arr + sz - 1 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,15 +73,15 @@ namespace range_detail
|
||||
// May this be discarded? Or is it needed for bad compilers?
|
||||
//
|
||||
template< typename T, std::size_t sz >
|
||||
inline const T* range_begin( const T (&a)[sz] )
|
||||
inline const T* range_begin( const T (&array)[sz] )
|
||||
{
|
||||
return a;
|
||||
return array;
|
||||
}
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline T* range_begin( T (&a)[sz] )
|
||||
inline T* range_begin( T (&array)[sz] )
|
||||
{
|
||||
return a;
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
|
||||
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
|
||||
#ifndef BOOST_RANGE_AS_LITERAL_HPP
|
||||
#define BOOST_RANGE_AS_LITERAL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
|
@ -71,15 +71,15 @@ namespace range_detail
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline const T* range_end( const T (&a)[sz] )
|
||||
inline const T* range_end( const T (&array)[sz] )
|
||||
{
|
||||
return range_detail::array_end<T,sz>( a );
|
||||
return range_detail::array_end<T,sz>( array );
|
||||
}
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline T* range_end( T (&a)[sz] )
|
||||
inline T* range_end( T (&array)[sz] )
|
||||
{
|
||||
return range_detail::array_end<T,sz>( a );
|
||||
return range_detail::array_end<T,sz>( array );
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
|
@ -185,7 +185,7 @@ namespace boost
|
||||
m_Begin(Begin), m_End(End)
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
@ -210,7 +210,7 @@ namespace boost
|
||||
template< class Range >
|
||||
iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
@ -219,7 +219,7 @@ namespace boost
|
||||
template< class Range >
|
||||
iterator_range( Range& r, iterator_range_detail::range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
@ -390,15 +390,13 @@ namespace boost
|
||||
bool singular;
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
public:
|
||||
bool is_singular() const
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
return singular;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
//
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -43,12 +41,6 @@ namespace boost
|
||||
typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME base::reference reference;
|
||||
|
||||
public: // for return value of front/back
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::mpl::if_< boost::is_reference<reference>,
|
||||
const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&,
|
||||
reference >::type const_reference;
|
||||
|
||||
public:
|
||||
sub_range() : base()
|
||||
@ -120,7 +112,7 @@ namespace boost
|
||||
return base::front();
|
||||
}
|
||||
|
||||
const_reference front() const
|
||||
const value_type& front() const
|
||||
{
|
||||
return base::front();
|
||||
}
|
||||
@ -130,7 +122,7 @@ namespace boost
|
||||
return base::back();
|
||||
}
|
||||
|
||||
const_reference back() const
|
||||
const value_type& back() const
|
||||
{
|
||||
return base::back();
|
||||
}
|
||||
@ -140,7 +132,7 @@ namespace boost
|
||||
return base::operator[](sz);
|
||||
}
|
||||
|
||||
const_reference operator[]( difference_type sz ) const
|
||||
const value_type& operator[]( difference_type sz ) const
|
||||
{
|
||||
return base::operator[](sz);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
</p>
|
||||
<p>
|
||||
Use, modification and distribution is subject to the Boost Software License, Version 1.0
|
||||
(see <a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
(see <a href=http://www.boost.org/LICENSE_1_0.txt>
|
||||
http://www.boost.org/LICENSE_1_0.txt</a>).
|
||||
</p>
|
||||
|
||||
|
@ -12,9 +12,9 @@ rule range-test ( name : includes * )
|
||||
{
|
||||
return [
|
||||
run $(name).cpp /boost/test//boost_unit_test_framework/<link>static
|
||||
:
|
||||
:
|
||||
: <toolset>gcc:<cxxflags>"-Wall -Wunused "
|
||||
:
|
||||
: $(includes)
|
||||
] ;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,14 @@ void check_char()
|
||||
BOOST_CHECK_EQUAL( str_end( char_s ), str_end1 );
|
||||
BOOST_CHECK_EQUAL( str_empty( char_s ), (char_s == 0 || char_s[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( sz, std::char_traits<char>::length( char_s ) );
|
||||
|
||||
/*
|
||||
BOOST_CHECK_EQUAL( str_begin( char_s2 ), char_s2 );
|
||||
std::size_t sz2 = size( char_s2 );
|
||||
const char* str_end12 = str_begin( char_s2 ) + sz;
|
||||
BOOST_CHECK_EQUAL( str_end( char_s2 ), str_end12 );
|
||||
BOOST_CHECK_EQUAL( empty( char_s2 ), (char_s2 == 0 || char_s2[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( sz2, std::char_traits<char>::length( char_s2 ) );
|
||||
*/
|
||||
BOOST_CHECK_EQUAL( str_begin( my_string ), my_string );
|
||||
range_iterator<char_array_t>::type str_end2 = str_begin( my_string ) + str_size(my_string);
|
||||
range_iterator<char_array_t>::type str_end3 = str_end(my_string);
|
||||
@ -158,20 +165,6 @@ void check_char()
|
||||
|
||||
BOOST_CHECK( find_const( as_array( my_string ), to_search ) != str_end(my_string) );
|
||||
BOOST_CHECK( find_const( as_array( my_const_string ), to_search ) != str_end(my_string) );
|
||||
|
||||
//
|
||||
// Test that as_literal() always scan for null terminator
|
||||
//
|
||||
char an_array[] = "foo\0bar";
|
||||
BOOST_CHECK_EQUAL( str_begin( an_array ), an_array );
|
||||
BOOST_CHECK_EQUAL( str_end( an_array ), an_array + 3 );
|
||||
BOOST_CHECK_EQUAL( str_size( an_array ), 3 );
|
||||
|
||||
const char a_const_array[] = "foobar\0doh";
|
||||
BOOST_CHECK_EQUAL( str_begin( a_const_array ), a_const_array );
|
||||
BOOST_CHECK_EQUAL( str_end( a_const_array ), a_const_array + 6 );
|
||||
BOOST_CHECK_EQUAL( str_size( a_const_array ), 6 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -179,6 +172,9 @@ void check_char()
|
||||
void check_string()
|
||||
{
|
||||
check_char();
|
||||
// check_char<volatile char>();
|
||||
// check_char<const char>();
|
||||
// check_char<const volatile char>();
|
||||
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
typedef wchar_t* wchar_iterator_t;
|
||||
@ -201,7 +197,13 @@ void check_string()
|
||||
BOOST_CHECK_EQUAL( str_end(char_ws), (str_begin( char_ws ) + sz) );
|
||||
BOOST_CHECK_EQUAL( str_empty( char_ws ), (char_ws == 0 || char_ws[0] == wchar_t()) );
|
||||
BOOST_CHECK_EQUAL( sz, std::char_traits<wchar_t>::length( char_ws ) );
|
||||
|
||||
/*
|
||||
std::size_t sz2 = size( char_ws2 );
|
||||
BOOST_CHECK_EQUAL( str_begin( char_ws2 ), char_ws2 );
|
||||
BOOST_CHECK_EQUAL( str_end( char_ws2 ), (begin( char_ws2 ) + sz2) );
|
||||
BOOST_CHECK_EQUAL( empty( char_ws2 ), (char_ws2 == 0 || char_ws2[0] == wchar_t()) );
|
||||
BOOST_CHECK_EQUAL( sz2, std::char_traits<wchar_t>::length( char_ws2 ) );
|
||||
*/
|
||||
wchar_t to_search = L'n';
|
||||
BOOST_CHECK( find( char_ws, to_search ) != str_end(char_ws) );
|
||||
|
||||
|
Reference in New Issue
Block a user