From 4300becb584455375d34a73435474c67c39224cd Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 23 Jul 2004 02:16:28 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'SPIRIT_1_6'. [SVN r23968] --- doc/boost_range.html | 168 ---------- doc/cboost.gif | Bin 8819 -> 0 bytes doc/external_concepts.html | 38 --- doc/range.htm | 612 ------------------------------------ index.html | 8 - test/Jamfile | 59 ---- test/TODO | 86 ----- test/algorithm_example.cpp | 65 ---- test/array.cpp | 81 ----- test/iterator_pair.cpp | 92 ------ test/iterator_range.cpp | 99 ------ test/partial_workaround.cpp | 106 ------- test/reversible_range.cpp | 97 ------ test/std_container.cpp | 74 ----- test/string.cpp | 152 --------- 15 files changed, 1737 deletions(-) delete mode 100644 doc/boost_range.html delete mode 100644 doc/cboost.gif delete mode 100644 doc/external_concepts.html delete mode 100755 doc/range.htm delete mode 100755 index.html delete mode 100755 test/Jamfile delete mode 100644 test/TODO delete mode 100755 test/algorithm_example.cpp delete mode 100755 test/array.cpp delete mode 100755 test/iterator_pair.cpp delete mode 100755 test/iterator_range.cpp delete mode 100755 test/partial_workaround.cpp delete mode 100755 test/reversible_range.cpp delete mode 100755 test/std_container.cpp delete mode 100755 test/string.cpp diff --git a/doc/boost_range.html b/doc/boost_range.html deleted file mode 100644 index b92a786..0000000 --- a/doc/boost_range.html +++ /dev/null @@ -1,168 +0,0 @@ - Collection Traits


Collection Traits


Introduction

This library makes it possible to treat different types as if they have - implemented a subset of the container requirements - (see §23.1of the C++ standard). Formally, that subset is defined by - the CollectionConcept. - The subset deals mostly with - iterator returning functions and nested typedefs. - The main goal is to treat built-in arrays, standard containers, - pairs of iterators and some iterators uniformly. Formally, this library is an implementation - of the ExternalCollectionConcept (see also this explanation of External Concepts ).

The main advantages are

Below are given a small example (the complete example can be found here ):

-       //
-       // Example: extracting bounds in generic algorithms
-       //                
-                       
-       template< typename ExternalCollection, typename T >
-       inline typename boost::iterator_of<ExternalCollection>::type
-       find( ExternalCollection& c, const T& value )
-       {
-           return std::find( boost::begin( c ), boost::end( c ), value );
-       }
-
-       template< typename ExternalCollection, typename T >
-       inline typename boost::const_iterator_of<ExternalCollection>::type 
-       find( const ExternalCollection& c, const T& value )
-       {
-           return std::find( boost::begin( c ), boost::end( c ), value );
-       }
-                       
-       // 
-       // replace first value and return its index
-       //                                
-       template< typename EC, typename T >
-       inline typename boost::size_type_of< EC >::type
-       my_generic_replace( EC& c, const T& value, const T& replacement )
-       {
-           typename boost::const_iterator_of<EC>::type found = find( c, value );
-           *found = replacement;
-           return std::distance( boost::begin( c ), found );
-       }                  
-                       
-       // 
-       // usage
-       //                                
-       std::vector<int>              my_vector;
-       typedef vector<int>::iterator iterator;
-       std::pair<iterator,iterator>  my_view( my_vector.begin(), my_vector.begin() + N );
-       char str[] = "a string";
-       // ...
-       std::cout << my_generic_replace( my_vector, 4, 2 )
-                 << my_generic_replace( my_view, 4, 2 )
-                 << my_generic_replace( str, 'a', 'b' );
-       
By using the free-standing functions and type-generators, the code automatically - works for all the types supported by this library. Notice that we have to provide - two version of find() since we cannot - forward a non-const rvalue with reference arguments (see this article about The Forwarding Problem ).


Reference

#include <boost/collection_traits.hpp>

Five types of objects are currently supported by the library:

It is worth noticing that some functionality requires partial template specialization, in particular, - full array support does (remark: this is a very small problem since one would use boost::array<> - anyway). Also note that arrays and pointers of char or whar_t are treated special because of their use in string algorithms.

ExternalCollectionConcept

The concept is defined by the type-generators and the - functions below. Even though these functions are defined in - namespace boost, there is no such general requirement, that is, - if one wants to extend the list of supported types, it can be done in any - namespace.

Synopsis

-    namespace boost 
-    {
-        //             
-        // type generators
-        //              
-        
-        template< typename EC >                                     
-        struct value_type_of
-        {
-            typedef ... type; // type of stored objects 
-        };
-                     
-        template< typename EC >                                     
-        struct iterator_of 
-        {
-            typedef ... type; // iterator over stored objects
-        };
-        
-        template< typename EC >                                     
-        struct const_iterator_of      
-        {
-            typedef ... type; // iterator over immutable stored objects 
-        };
-
-        template< typename EC >                                     
-        struct difference_type_of
-        {
-            typedef ... type; 
-            BOOST_STATIC_ASSERT( boost::is_signed< type >::value );
-            //
-            // remark: if std::iterator_traits<> works for the type, this assertion must hold
-            //
-            BOOST_STATIC_ASSERT( boost::is_same< type, std::iterator_traits< typename 
-                                                       iterator_of< EC >::type >::difference_type>::value );         
-        };
-
-        template< typename EC >                                     
-        struct size_type_of
-        {
-            typedef ... type;
-            BOOST_STATIC_ASSERT( boost::is_unsigned< type >::value );
-            BOOST_STATIC_ASSERT( sizeof( type ) >= sizeof( difference_type_of< EC >::type ) );                   
-        };
-
-        template< typename EC >                                     
-        struct result_iterator_of     
-        {
-            typedef ... type; 
-            // iterator_of< EC >::type if EC is non-const, const_iterator_of< EC >::type otherwise         
-        };
-                     
-        //
-        // funtions
-        //
-        
-        template< typename EC >
-        inline typename iterator_of::type
-        begin( EC& c );               
-    
-        template< typename EC >
-        inline typename const_iterator_of< EC >::type
-        begin( const EC& c );                       
-            
-        template< typename EC >
-        inline typename iterator_of< EC >::type
-        end( EC& c );  
-                          
-        template< typename EC >
-        inline typename const_iterator_of< EC >::type
-        end( const EC& c );
-        
-        template< typename EC >
-        inline bool
-        empty( const EC& c );         
-                   
-        template< typename EC >
-        inline typename size_type_of< EC >::type
-        size( const EC& c );
-                     
-     } // namespace 'boost' 

Library headers

HeaderIncludes
<boost/collection_traits.hpp>everything
<boost/collection_traits/types.hpp>every type-generator
<boost/collection_traits/functions.hpp>every function
<boost/collection_traits/value_type.hpp>value_type_of
<boost/collection_traits/iterator.hpp>iterator_of
<boost/collection_traits/const_iterator.hpp>const_iterator_of
<boost/collection_traits/difference_type.hpp>difference_type_of
<boost/collection_traits/size_type.hpp>size_type_of
<boost/collection_traits/result_iterator.hpp>result_iterator_of
<boost/collection_traits/begin.hpp>begin
<boost/collection_traits/end.hpp>end
<boost/collection_traits/empty.hpp>empty
<boost/collection_traits/size.hpp>size

Semantics

In the table C is a type that conforms to the ExternalCollectionConcept and c is an object of that type. SC will denote a standard - container, T[sz] will denote an array of type T of size sz, P will denote std::pair<>, I means an iterator which default construction - denotes the end of the range and sc,t,p,i are objects of these types, - respectively. Special cases for char* and wchar_t* are described explicitly.

ExpressionReturn typeComplexity
value_type_of<C>::typeSC::value_type
T
std::iterator_traits<P::first_type>::value_type
std::iterator_traits<I>::value_type
compile time
iterator_of<C>::typeSC::iterator
T*
P::first_type
I
compile time
const_iterator_of<C>::typeSC::const_iterator
const T*
P::first_type
I
compile time
difference_type_of<C>::typeSC::difference_type
std::ptrdiff_t
std::iterator_traits<P::first_type>::difference_type
std::iterator_traits<I>::difference_type
compile time
size_type_of<C>::typeSC::size_type
std::size_t
std::size_t
std::size_t
compile time
result_iterator_of<C>::typeconst_iterator_of<C>::type if C is const
iterator_of<C>::type otherwise
compile time

ExpressionReturn typeEffectsComplexity
begin( c )result_iterator_of<C>::typesc.begin()
t
p.first
i
constant time
end( c )result_iterator_of<C>::typesc.end()
t + std::char_traits<C>::length( t ) if C is char* or wchar_t*
t + sz - 1 if C is char[sz] or wchar_t[sz]
t + sz otherwise
p.second
I()
linear if C is char* or wchar_t*
constant time otherwise
empty( c )Convertible to boolsc.empty()
size( t ) == 0
p.first == p.second
begin( i ) == end( i )
linear if C is char* or wchar_t*
constant time otherwise
size( c )size_type_of<C>::typesc.size()
end( t ) - begin( t )
distance( p.first, p.second )
not available for iterators
linear if C is char* or wchar_t*
or if std::distance() is linear
constant time otherwise

Please note that char*,whar_t*,char[], and wchar_t[] behaves differently from - normal arrays only for size() and end(). - Note that the null pointer is allowed as an argument in these cases.



Examples

Some examples are given in the accompanying test - files:


Portability

Full support for built-in arrays require that the - compiler supports class template partial specialization.

Notice that some compilers cannot do function template ordering - properly. In that case one cannot rely of result_iterator_of<> and a single function definition; instead one needs to supply - a function overloaded for const and non-const arguments if it is required.

Full support for iterators like std::istream_iterator<> depends very - much on a conforming standard library.

Most of the tests have been run successfully on these compilers


FAQ

  1. Why is there no difference between iterator_of<C>::type and const_iterator_of<C>::type for std::pair<iterator,iterator> or iterators which default construction denotes the end of the range?
  2. In general it is not possible nor desirable to find a corresponding const_iterator. When it is possible to come up with - one, the client might choose to - construct a std::pair<const_iterator,const_iterator> object.

  3. Why does the traits not supply more types or more functions?

    The traits class have been kept small because its current interface - will serve most purposes. If and when a genuine need arises for - more functionality, it can be implemented.

  4. How should I implement generic algorithms for external collections?

    One should always start with a generic algorithm that takes two iterators as input. Then use the - collection traits to build handier versions on top of the base algorithm.


History

The library have been under way for a long time. Dietmar Kühl originally - intended to submit an array_traits<> class template which had most - of the functionality present now, but only for arrays and standard containers. - Meanwhile work on container algorithms - in various context showed the need for handling pairs of iterators, and - string libraries needed special treatment of character arrays. - Thorsten Ottosen wrote everything from the ground up including the first - work-around for missing partial template specialization. Pavol Droba helped to - improve the work-around for handicapped compilers and the special character support. - The naming scheme of type-generators was suggested by Peter Dimov.


© Thorsten Ottosen 2003-2004 (nesotto_AT_cs.auc.dk). - Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears - in all copies. This software is provided "as is" without express or implied warranty, and with no - claim as to its suitability for any purpose.































- \ No newline at end of file diff --git a/doc/cboost.gif b/doc/cboost.gif deleted file mode 100644 index 58be431a3fafbd5adfa01e829ce8d80a03a83ed0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8819 zcmZ?wbhEHb6lDx!_|CwzZQFbH(K6ngWKJ ziiVnsJ(`+|nwo~1nogRU#hRMcnwmYDhC!N^Q#37?YC7%JbULQ#bxbqrnr8BQL(ODE zLoY+8V}?P;41=y2MlCgrx@H*l+%Wl?Ve)gs?C+L}mX?N=mWDx=hSipqQ!JgPSURn> z^vbpjT56g6-Lm?-WzTmf!(=DJY9}WzC#NVUr)(#u7ALR0PC?a9L35m__ikjmUwbv`^m{;;Wuj=n!J>P?zs)M|u zg1oYWg0h2x<^%<;4T`!KlsqLUd1+Ac+Mw)XLD|=WvhM|DKM$(D7F7K{sO5W5&-0+3 z??H3EM|mYj1#OK2ftIN3wNcggqSp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#d0= zVV2oj5oW$XaLI&*$KpLZIqan_HqDN0>Ak7Tro88b+P@1|ZWs$6JnnKue8F*D?b=?) zjkV6wYB_JG7cyo|*fwR4d8Nn_h0HhaqUXA~?P_}5C;rksq}8)0KIJ=4+JzJPlRk34 z=(@}kzV1Xqec{?8jE8tS4{{_P&J@fPVV2ELnm^%d%*=L=C0k;IUJJfF$p7xk_T8;{ z?5&qR^3`zcxcKNoj_s?1x25)r%G59Av2~epH+{kOBh%FiAJtt<>Yj1<)UmG3mJF|W z3j&;#e=T4$eDYCEM!4@p^|7z+Wnn4pZ=B`+bDIhs zp272;Y;n*2 z{OG1NpCiA|f7$s7FOOf4TN2r3^2Gk%3L)nw3;WMV&Aw5swezu!b8fc&Qdu$ATh=W1 z9_H;>oVn&L+Z^jlyk{;Yue#b^`%opU3=oSpr%~ki<~5JQji;JxWPB4V%(6NB`TUQo#$ArQu`m89 zeQ3(G-2NtTYo5ba*_RpZDk}wZJ=J^VoEE!V?K14W$R8;8a>8Ggw;PMvJUr#@EjVVf zB9ZR_^M2{uAKa|JCcG~{Wm5rX_ww!QeeOTV*8nj z4)0si4<@UW7_dKEJVDoK50hrcAq^$2os;Tr?Rc+z@O$F?qcc0Sx_ah2>Rxu*Io-p) zEuv>r&_T99&dIwc{lCDIa9F6NfT!+&%9=$2-<^5Z-fDko&GE;oLv@Ra&c`)+H`o99 zwWdt_pq5I$u!s(4S++p>L(}xgX;slO(kd%dpQv=KP-;D)!WihRZ0-D~NT9xB{@Dz3 zlb3edTMm~OJKH@LGJJA)O}3$!%7hiW4?C(HaWXmL>~h2<Q%P5$_{Me6AeveR9N4XL17rgEatT*T~8M diff --git a/doc/external_concepts.html b/doc/external_concepts.html deleted file mode 100644 index 98ccf90..0000000 --- a/doc/external_concepts.html +++ /dev/null @@ -1,38 +0,0 @@ - Concepts and External Concepts

Concepts and External Concepts

Generic programming in C++ is characterized by the use of function and class templates where - the template parameter(s) must satisfy certain requirements.Often these - requirements are so important that we give them a name: we call - such a set of type requirements a concept. We say that a type - conforms to a concept or that it is a model of a concept if it - satisfies all of those requirements. The concept can be specified as a set - of member functions with well-defined semantics - and a set of nested typedefs with well-defined properties.

Often it much more flexible to provide free-standing functions and typedefs - which provides the exact same semantics (but a different syntax) as - specified - by the concept. This allows generic code to treat different types as if - they fulfilled the concept. In this case we say that the concept has - been externalized or that the new requirements constitutes an external - concept . We say that a type conforms to an external concept - or that it is a model of an external concept . A concept may exist - without a corresponding external concept and conversely.

Whenever a concept specifies a member function, the corresponding external - concept - must specify a free-standing function of the same name, same return type and - the same argument list except there is an extra first argument which must - be of the type (or a reference to that type) that is to fulfill the external - concept. If the corresonding member function has any cv-qulifiers, the - first argument must have the same cv-qualifiers. Whenever a concept - specifies a nested typedef, the corresponding external concept - specifies a type-generator, that is, a type with a nested typedef - named type. The type-generator has the name as the nested typedef with - _of appended. - The converse relationship of an external concept and its corresponding concept - also holds.

Example:

A type T fulfills the FooConcept if it - has the follwing public members:

void T::foo( int ) const;
- int T::bar();
- typedef implementation defined foo_type;

The corresponding external concept is the ExternalFooConcept.

A type T fullfills the ExternalFooConcept if these - free-standing functions and type-generators exists:

void foo( const T&, int );
- int bar( T& );
- foo_type_of< T >::type;



Literature


© Thorsten Ottosen 2003-2004 (nesotto_AT_cs.auc.dk). - Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears - in all copies. This software is provided "as is" without express or implied warranty, and with no - claim as to its suitability for any purpose.































- \ No newline at end of file diff --git a/doc/range.htm b/doc/range.htm deleted file mode 100755 index 2f045a0..0000000 --- a/doc/range.htm +++ /dev/null @@ -1,612 +0,0 @@ - - - -Collection - - -C++ Boost - - -
-

Collection

- - -

Description

- -A Collection is a concept similar to the STL Container -concept. A Collection provides iterators for accessing a range of -elements and provides information about the number of elements in the -Collection. However, a Collection has fewer requirements than a -Container. The motivation for the Collection concept is that there are -many useful Container-like types that do not meet the full -requirements of Container, and many algorithms that can be written -with this reduced set of requirements. To summarize the reduction -in requirements: - -
    -
  • It is not required to "own" its elements: the lifetime -of an element in a Collection does not have to match the lifetime of -the Collection object, though the lifetime of the element should cover -the lifetime of the Collection object. -
  • The semantics of copying a Collection object is not defined (it -could be a deep or shallow copy or not even support copying). -
  • The associated reference type of a Collection does -not have to be a real C++ reference. -
- - -Because of the reduced requirements, some care must be taken when -writing code that is meant to be generic for all Collection types. -In particular, a Collection object should be passed by-reference -since assumptions can not be made about the behaviour of the -copy constructor. - -

- -

Associated types

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Value type - -X::value_type - -The type of the object stored in a Collection. -If the Collection is mutable then -the value type must be Assignable. -Otherwise the value type must be CopyConstructible. -
-Iterator type - -X::iterator - -The type of iterator used to iterate through a Collection's - elements. The iterator's value type is expected to be the - Collection's value type. A conversion - from the iterator type to the const iterator type must exist. - The iterator type must be an InputIterator. -
-Const iterator type - -X::const_iterator - -A type of iterator that may be used to examine, but not to modify, - a Collection's elements. -
-Reference type - -X::reference - -A type that behaves like a reference to the Collection's value type. -[1] -
-Const reference type - -X::const_reference - -A type that behaves like a const reference to the Collection's value type. -
-Pointer type - -X::pointer - -A type that behaves as a pointer to the Collection's value type. -
-Distance type - -X::difference_type - -A signed integral type used to represent the distance between two - of the Collection's iterators. This type must be the same as - the iterator's distance type. -
-Size type - -X::size_type - -An unsigned integral type that can represent any nonnegative value - of the Collection's distance type. -
-

Notation

- - - - - - - - - - - - - -
-X - -A type that is a model of Collection. -
-a, b - -Object of type X. -
-T - -The value type of X. -
- -

Valid expressions

- -The following expressions must be valid. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Name - -Expression - -Return type -
-Beginning of range - -a.begin() - -iterator if a is mutable, const_iterator otherwise -
-End of range - -a.end() - -iterator if a is mutable, const_iterator otherwise -
-Size - -a.size() - -size_type -
-Empty Collection - -a.empty() - -Convertible to bool -
-

Expression semantics

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Name - -Expression - -Semantics - -Postcondition -
-
-Beginning of range - -a.begin() - -Returns an iterator pointing to the first element in the Collection. - -a.begin() is either dereferenceable or past-the-end. It is - past-the-end if and only if a.size() == 0. -
-End of range - -a.end() - -Returns an iterator pointing one past the last element in the - Collection. - -a.end() is past-the-end. -
-Size - -a.size() - -Returns the size of the Collection, that is, its number of elements. - -a.size() >= 0 -
-Empty Collection - -a.empty() - -Equivalent to a.size() == 0. (But possibly faster.) - -  -
-

Complexity guarantees

- -begin() and end() are amortized constant time. -

-size() is at most linear in the Collection's -size. empty() is amortized constant time. - -

Invariants

- - - - - - - - - - - - - -
-Valid range - -For any Collection a, [a.begin(), a.end()) is a valid - range. -
-Range size - -a.size() is equal to the distance from a.begin() to a.end(). -
-Completeness - -An algorithm that iterates through the range [a.begin(), a.end()) - will pass through every element of a. -
- - -

Models

-
    - - -
  • vector<bool> -
- - - -

Notes

- -

[1] - -The reference type does not have to be a real C++ reference. The -requirements of the reference type depend on the context within which -the Collection is being used. Specifically it depends on the -requirements the context places on the value type of the Collection. -The reference type of the Collection must meet the same requirements -as the value type. In addition, the reference objects must be -equivalent to the value type objects in the collection (which is -trivially true if they are the same). Also, in a mutable Collection, -an assignment to the reference object must result in an assignment to -the object in the Collection (again, which is trivially true if they -are the same object, but non-trivial if the reference type is a proxy -class). - -

See also

-Container - - -
-
- - - - -
Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame and C++ Library & Compiler Group/SGI (jsiek@engr.sgi.com) -
Copyright © 2004 -Thorsten Ottosen. -
- - - diff --git a/index.html b/index.html deleted file mode 100755 index 5a83ab6..0000000 --- a/index.html +++ /dev/null @@ -1,8 +0,0 @@ - Collection Traits - - - - - - - diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100755 index 6c15362..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,59 +0,0 @@ -subproject libs/range/test ; - -SEARCH on testing.jam = $(BOOST_BUILD_PATH) ; -include testing.jam ; -DEPENDS all : test ; - -{ -test-suite range - : [ run - array.cpp - : : - : - : array_test - ] - [ run - iterator_pair.cpp - : : - : - : iterator_pair_test - ] - [ run - std_container.cpp - : : - : - : std_container_test - ] - [ run - string.cpp - : : - : - : string_test - ] - [ run - iterator_range.cpp - : : - : - : iterator_range - ] - - [ run - partial_workaround.cpp - : : - : - : workaround_test - ] - [ run - algorithm_example.cpp - : : - : - : example_test - ] - - [ run - reversible_range.cpp - : : - : - : reversible_range_test - ] ; -} diff --git a/test/TODO b/test/TODO deleted file mode 100644 index e6f8058..0000000 --- a/test/TODO +++ /dev/null @@ -1,86 +0,0 @@ -1. ok. I should add something about extending the lib + how to rely on ADL. -2. | I'd prefer "primary specialization" to "default" in the comments. - ok. Is that the correct term? -3. A "specialization" of a template is the result of instantiating -it, so the more accurate term, as given in Vandevoorde and -Josuttis, is "primary template." - -5. new intro: -"When writing generic code that works with Standard Library -containers, one often finds it desirable to extend that code to -work with other types that offer enough functionality to satisfy -the needs of the generic code, but in an altered form. For -example, raw arrays are often suitable for use with generic code -that works with containers, provided a suitable adapter is used. -Likewise, null terminated strings can be treated as containers of -characters, if suitably adapted. This library provides the means -to adapt Standard Library containers, null terminated strings, -std::pairs of iterators, and raw arrays, such that the same -generic code can work with them all." - -6. > | The Introduction is missing discussion of the use of namespace -> | scope functions to do what heretofore would be done via member -> | functions. Instead, the example and the sentence immediately -> | following it imply this change of syntax. -> -> Wouldn't it only duplicate stuff in the two links to CollectionCocept and ExternalConcepts? - -In a sense, yes, but what I'm proposing is a much abbreviated -form: - -"To allow generic code to work with objects that conform to the -ExternalCollectionConcept, this library provides a set of -namespace scope functions and type -generators that provide a standard interface for the required -functionality. Whereas one might write, "c.end()," to get the end -iterator from a Standard Library container, c, using this -library, it would be written, "boost::end(c)." This change in -syntax is necessary to make the same interface possible with the -other supported types such as null terminated strings." - -7. [boost-book-style]I like colors, so perhaps use the boost-book stylesheets? - -9. New range explanation: - -I'd say "Iterable" if we have to use an "-able" term. 24.1/7 -suggests to me that "Range" might be OK: - - Most of the library's algorithmic templates that operate on data - structures have interfaces that use ranges. A range is a pair of - iterators that designate the beginning and end of the computation. A - range [i, i) is an empty range; in general, a range [i, j) refers to - the elements in the data structure starting with the one pointed to - by i and up to but not including the one pointed to by j. Range [i, - j) is valid if and only if j is reachable from i. The result of the - application of functions in the library to invalid ranges is - undefined. - -10. Don't make empty part of the Range concept, but have a default - implementation begin() == end() + spccial treatment of char*, - -11. documentation: table with entities before other tables - -12. Example of how result_iterator is used, necessary: -when designing templated classes - -template struct widget { - typedef result_iterator_of iterator; -}; - -13. better external concepts: Thorsten Ottosen wrote: ->> The documentation that's provided I found ->> sufficient, it's just of a different style than other concept ->> documentation. -> -> ok. I don't think the definition of concepts are that much more -> elaborate. What could be -> much better is the example which could follow normal concept -> standards. Is that what you had in mind? - -Yes. - -14. Change example code for my_generic_replace. - -15. More concepts: random-access range: which have constant -time size(); Cpm matthews latest article. diff --git a/test/algorithm_example.cpp b/test/algorithm_example.cpp deleted file mode 100755 index e51f393..0000000 --- a/test/algorithm_example.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include -#include -#include - -namespace -{ - template< typename ExternalCollection, typename T > - inline typename boost::iterator_of::type - find( ExternalCollection& c, const T& value ) - { - return std::find( boost::begin( c ), boost::end( c ), value ); - } - - template< typename ExternalCollection, typename T > - inline typename boost::const_iterator_of::type - find( const ExternalCollection& c, const T& value ) - { - return std::find( boost::begin( c ), boost::end( c ), value ); - } - - // - // replace first value and return its index - // - template< typename EC, typename T > - inline typename boost::size_type_of< EC >::type - my_generic_replace( EC& c, const T& value, const T& replacement ) - { - typename boost::iterator_of::type found = find( c, value ); - - if( found != boost::end( c ) ) - *found = replacement; - return std::distance( boost::begin( c ), found ); - } -} - - - -int main() -{ - const int N = 5; - int v[] = { 1,2,3,4,5,6,6,7,8,9 }; - std::vector my_vector; - my_vector.assign( boost::begin( v ), boost::end( v ) ); - typedef std::vector::iterator iterator; - std::pair my_view( boost::begin( my_vector ), - boost::begin( my_vector ) + N ); - char str[] = "a string"; - - std::cout << my_generic_replace( my_vector, 4, 2 ) - << my_generic_replace( my_view, 4, 2 ) - << my_generic_replace( str, 'a', 'b' ); - return 0; -} diff --git a/test/array.cpp b/test/array.cpp deleted file mode 100755 index 181fddf..0000000 --- a/test/array.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include -#include -#include -#include - -// This should be included before "using namespace boost", -// otherwise gcc headers will be confused with boost::iterator -// namespace. -#include - -using namespace boost; -using namespace std; - -void check_array() -{ - const int sz = 9; - typedef int array_t[sz]; - int my_array[sz] = { 1,2,3,4,5,6,7,8,9 }; - const array_t ca = { 1,2,3,4,5,6,7,8,10 }; - -#ifndef BOOST_CT_NO_STATIC_ASSERT - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, int >::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, int* >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, int* >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const int* >::value )); - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, const int >::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const int* >::value )); -#endif - //typedef container::result_iterator iter; - //cout << typeid( iter() ).name() << endl; - - BOOST_CHECK_EQUAL( begin( my_array ), my_array ); - BOOST_CHECK_EQUAL( end( my_array ), my_array + size( my_array ) ); - BOOST_CHECK_EQUAL( empty( my_array ), false ); - //BOOST_CHECK( size( my_array ) == sizeof( sizer( my_array ) ) ); - - BOOST_CHECK_EQUAL( begin( ca ), ca ); - BOOST_CHECK_EQUAL( end( ca ), ca + size( ca ) ); - BOOST_CHECK_EQUAL( empty( ca ),false ); - //BOOST_CHECK( size( ca ) == sizeof( sizer( ca ) ) ); - -} - - - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_array ) ); - - return test; -} - - - - - diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp deleted file mode 100755 index 792e095..0000000 --- a/test/iterator_pair.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include -#include -#include -#include - -using namespace boost; -using boost::unit_test_framework::test_suite; - -void check_iterator_pair() -{ - typedef std::vector vec_t; - vec_t vec; - vec.push_back( 4 ); - typedef std::pair - pair_t; - typedef std::pair - const_pair_t; - typedef const pair_t const_pair_tt; - pair_t pair = std::make_pair( begin( vec ), end( vec ) ); - const_pair_t const_pair = std::make_pair( begin( vec ), end( vec ) ); - const_pair_tt constness_pair( pair ); - - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, - detail::iterator_traits::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const_pair_t::first_type >::value )); - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, - detail::iterator_traits::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const_pair_tt::first_type >::value )); - - BOOST_CHECK( begin( pair ) == pair.first ); - BOOST_CHECK( end( pair ) == pair.second ); - BOOST_CHECK( empty( pair ) == (pair.first == pair.second) ); - BOOST_CHECK( size( pair ) == std::size_t( std::distance( pair.first, pair.second ) ) ); - - BOOST_CHECK( begin( const_pair ) == const_pair.first ); - BOOST_CHECK( end( const_pair ) == const_pair.second ); - BOOST_CHECK( empty( const_pair ) == (const_pair.first == const_pair.second) ); - BOOST_CHECK( size( const_pair ) == std::size_t( std::distance( const_pair.first, const_pair.second ) ) ); - - BOOST_CHECK( begin( constness_pair ) == constness_pair.first ); - BOOST_CHECK( end( constness_pair ) == constness_pair.second ); - BOOST_CHECK( empty( constness_pair ) == (constness_pair.first == const_pair.second) ); - BOOST_CHECK( size( constness_pair ) == std::size_t( std::distance( constness_pair.first, constness_pair.second ) ) ); - -} - - - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_iterator_pair ) ); - - return test; -} - - - - - - diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp deleted file mode 100755 index 79ec34a..0000000 --- a/test/iterator_range.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include -#include -#include -#include - -// This should be included before "using namespace boost", -// otherwise gcc headers will be confused with boost::iterator -// namespace. -#include - -using namespace boost; -using namespace std; - -struct add_one -{ - template< class T > - T operator()( T r ) const - { - return r + 1; - } -}; - -void check_iterator_range() -{ - typedef string::iterator iterator; - typedef string::const_iterator const_iterator; - typedef iterator_range irange; - typedef iterator_range cirange; - string str = "hello world"; - const string cstr = "const world"; - irange r = make_iterator_range( str ); - r = make_iterator_range( str.begin(), str.end() ); - cirange r2 = make_iterator_range( cstr ); - r2 = make_iterator_range( cstr.begin(), cstr.end() ); - r2 = make_iterator_range( str ); - - typedef sub_range srange; - typedef sub_range csrange; - srange s = r; - BOOST_CHECK( r == s ); - s = make_iterator_range( str ); - csrange s2 = r; - s2 = r2; - s2 = make_iterator_range( cstr ); - BOOST_CHECK( r != s2 ); - s2 = make_iterator_range( str ); - - BOOST_CHECK( r.begin() == s.begin() ); - BOOST_CHECK( r2.begin()== s2.begin() ); - BOOST_CHECK( r.end() == s.end() ); - BOOST_CHECK( r2.end() == s2.end() ); - BOOST_CHECK_EQUAL( r.size(), s.size() ); - BOOST_CHECK_EQUAL( r2.size(), s2.size() ); - - if( !r ) - BOOST_CHECK( false ); - if( !r2 ) - BOOST_CHECK( false ); - if( !s ) - BOOST_CHECK( false ); - if( !s2 ) - BOOST_CHECK( false ); - - cout << r << r2 << s << s2; - - string res = copy_range( r ); - BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) ); - string res2 = transform_range( s2, add_one() ); - BOOST_CHECK( !equal( s2.begin(), s2.end(), res2.begin() ) ); -} - - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_iterator_range ) ); - - return test; -} - - - - - diff --git a/test/partial_workaround.cpp b/test/partial_workaround.cpp deleted file mode 100755 index e5277bb..0000000 --- a/test/partial_workaround.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 1 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_partial_workaround() -{ - using namespace range_detail; - using type_traits::yes_type; - using type_traits::no_type; - - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - char* c_ptr; - const char* cc_ptr; - wchar_t* w_ptr; - const wchar_t* cw_ptr; - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( c_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cc_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( w_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cw_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_char_ptr_impl( c_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_char_ptr_impl( cc_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_wchar_t_ptr_impl( w_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_wchar_t_ptr_impl( cw_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( c_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( cc_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( w_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( cw_ptr ) ) ); - - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_, - boost::range_detail::range< vector >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_pair_, - boost::range_detail::range< pair >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::array_, - boost::range_detail::range< int[42] >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::char_ptr_, - boost::range_detail::range< char* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_char_ptr_, - boost::range_detail::range< const char* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::wchar_t_ptr_, - boost::range_detail::range< wchar_t* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_wchar_t_ptr_, - boost::range_detail::range< const wchar_t* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_, - boost::range_detail::range< vector >::type >::value )); - -} - - - - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_partial_workaround ) ); - - return test; -} - - - - - - diff --git a/test/reversible_range.cpp b/test/reversible_range.cpp deleted file mode 100755 index 8a878c6..0000000 --- a/test/reversible_range.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_iterator() -{ - typedef vector vec_t; - typedef vec_t::iterator iterator; - typedef pair pair_t; - typedef reverse_iterator_of::type rev_iterator; - typedef pair rev_pair_t; - - vec_t vec; - pair_t p = make_pair( vec.begin(), vec.end() ); - rev_pair_t rp = make_pair( rbegin( p ), rend( p ) ); - char* str = "mutable"; - const char* cstr = "not mutable"; - char a[] = "mutable"; - const char ca[] = "not mutable"; - wchar_t* wstr = L"mutable"; - const wchar_t* cwstr= L"not mutable"; - wchar_t wa[] = L"mutable"; - const wchar_t cwa[]= L"not mutable"; - - BOOST_CHECK( rbegin( vec ) == reverse_iterator_of::type( vec.end() ) ); - BOOST_CHECK( rend( vec ) == reverse_iterator_of::type( vec.begin() ) ); - BOOST_CHECK( distance( rbegin( vec ), rend( vec ) ) == distance( begin( vec ), end( vec ) ) ); - - BOOST_CHECK( rbegin( p ) == begin( rp ) ); - BOOST_CHECK( rend( p ) == end( rp ) ); - BOOST_CHECK( distance( rbegin( p ), rend( p ) ) == distance( begin( rp ), end( rp ) ) ); - BOOST_CHECK( distance( begin( p ), end( p ) ) == distance( rbegin( rp ), rend( rp ) ) ); - - BOOST_CHECK_EQUAL( &*begin( str ), &*( rend( str ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( str ) - 1 ), &*rbegin( str ) ); - BOOST_CHECK_EQUAL( &*begin( cstr ), &*( rend( cstr ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( cstr ) - 1 ), &*rbegin( cstr ) ); - - BOOST_CHECK_EQUAL( &*begin( a ), &*( rend( a ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( a ) - 1 ), &*rbegin( a ) ); - BOOST_CHECK_EQUAL( &*begin( ca ), &*( rend( ca ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( ca ) - 1 ), &*rbegin( ca ) ); - - BOOST_CHECK_EQUAL( &*begin( wstr ), &*( rend( wstr ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( wstr ) - 1 ), &*rbegin( wstr ) ); - BOOST_CHECK_EQUAL( &*begin( cwstr ), &*( rend( cwstr ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( cwstr ) - 1 ), &*rbegin( cwstr ) ); - - BOOST_CHECK_EQUAL( &*begin( wa ), &*( rend( wa ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( wa ) - 1 ), &*rbegin( wa ) ); - BOOST_CHECK_EQUAL( &*begin( cwa ), &*( rend( cwa ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( cwa ) - 1 ), &*rbegin( cwa ) ); - -} - - - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_iterator ) ); - - return test; -} - - - - - - - diff --git a/test/std_container.cpp b/test/std_container.cpp deleted file mode 100755 index c4e8c98..0000000 --- a/test/std_container.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include -#include -#include -#include - -using namespace boost; -using boost::unit_test_framework::test_suite; - -void check_std_container() -{ - typedef std::vector vec_t; - vec_t vec; - vec.push_back( 3 ); vec.push_back( 4 ); - const vec_t cvec( vec ); - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, vec_t::value_type >::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, vec_t::const_iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, vec_t::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, vec_t::size_type >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, vec_t::const_iterator >::value )); - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, vec_t::value_type >::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, vec_t::const_iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, vec_t::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, vec_t::size_type >::value )); - - BOOST_CHECK( begin( vec ) == vec.begin() ); - BOOST_CHECK( end( vec ) == vec.end() ); - BOOST_CHECK( empty( vec ) == vec.empty() ); - BOOST_CHECK( size( vec ) == vec.size() ); - - BOOST_CHECK( begin( cvec ) == cvec.begin() ); - BOOST_CHECK( end( cvec ) == cvec.end() ); - BOOST_CHECK( empty( cvec ) == cvec.empty() ); - BOOST_CHECK( size( cvec ) == cvec.size() ); - -} - - - - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_std_container ) ); - - return test; -} - - - - - - diff --git a/test/string.cpp b/test/string.cpp deleted file mode 100755 index bb00872..0000000 --- a/test/string.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::iterator_of::type -find( Container& c, T value ) -{ - return std::find( boost::begin( c ), boost::end( c ), value ); -} - -template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::const_iterator_of::type -find( const Container& c, T value ) -{ - return std::find( boost::begin( c ), boost::end( c ), value ); -} - -std::vector -check_rvalue_return() -{ - return std::vector( 10, 'm' ); -} - -using namespace boost; - - -void check_char() -{ - typedef char* char_iterator_t; - typedef char char_array_t[10]; - const char* char_s = "a string"; - char my_string[] = "another string"; - const unsigned my_string_length = 14; - - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, char_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, const char* >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, - ::std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, char_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const char* >::value )); - // - // note: why does is_same< result_iterator::type, const char* >::value - // fail?!? - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, - char>::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, char* >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, const char* >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, - ::std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, char* >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const char* >::value )); - - BOOST_CHECK_EQUAL( begin( char_s ), char_s ); - const char* end1 = begin( char_s ) + size( char_s ); - BOOST_CHECK_EQUAL( end( char_s ), end1 ); - BOOST_CHECK_EQUAL( empty( char_s ), (char_s == 0 || char_s[0] == char()) ); - BOOST_CHECK_EQUAL( size( char_s ), std::char_traits::length( char_s ) ); - - BOOST_CHECK_EQUAL( begin( my_string ), my_string ); - const char* end2 = begin( my_string ) + size( my_string ); - BOOST_CHECK_EQUAL( end( my_string ), end2 ); - BOOST_CHECK_EQUAL( empty( my_string ), (my_string == 0 || my_string[0] == char()) ); - BOOST_CHECK_EQUAL( size( my_string ), my_string_length ); - BOOST_CHECK_EQUAL( size( my_string ), std::char_traits::length( my_string ) ); - - - char to_search = 'n'; - BOOST_CHECK( find( char_s, to_search ) != end( char_s ) ); - BOOST_CHECK( find( my_string, to_search ) != end( my_string ) ); -} - - - -void check_string() -{ - check_char(); -// check_char(); -// check_char(); -// check_char(); - -#ifndef BOOST_NO_STD_WSTRING - typedef wchar_t* wchar_iterator_t; - const wchar_t* char_ws = L"a wide string"; - wchar_t my_wstring[] = L"another wide string"; - - BOOST_STATIC_ASSERT(( is_same< value_type_of::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< iterator_of::type, wchar_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< const_iterator_of::type, const wchar_t* >::value )); - BOOST_STATIC_ASSERT(( is_same< difference_type_of::type, - detail::iterator_traits::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< size_type_of::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, wchar_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< result_iterator_of::type, const wchar_t* >::value )); - - BOOST_CHECK_EQUAL( begin( char_ws ), char_ws ); - BOOST_CHECK_EQUAL( end( char_ws ), (begin( char_ws ) + size( char_ws )) ); - BOOST_CHECK_EQUAL( empty( char_ws ), (char_ws == 0 || char_ws[0] == wchar_t()) ); - BOOST_CHECK_EQUAL( size( char_ws ), std::char_traits::length( char_ws ) ); - - wchar_t to_search = L'n'; - BOOST_CHECK( find( char_ws, to_search ) != end( char_ws ) ); - BOOST_CHECK( find( my_wstring, to_search ) != end( my_wstring ) ); -#endif - - find( check_rvalue_return(), 'n' ); - -} - - - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_string ) ); - - return test; -} - - - - - -