|
Boost : |
From: Hartmut Kaiser (hartmutkaiser_at_[hidden])
Date: 2004-04-28 09:31:12
Hi all,
The review of the Collection Traits library, written by Thorsten Ottosen
starts today (April 28th, 2004) and runs for 10 days (until May 7th, 2004).
The Latest version of the library is available at (yahoo files sections):
http://tinyurl.com/ysbaj (72 kB) or in the Boost sandbox.
What is it?
The Collection Traits library is mainly a tool for writing generic
algorithms that work on External Collections.
A Collection is a subset of the container requirements; it is so small and
essential that it can be made to work with standard containers,
iterator-views, built-in arrays and strings by defining a new requirement,
the External Collection
Concept, where typedefs and functions have been made free-standing instead
of members.
The library consists of two components:
(1) type generators and
(2) free-standing functions.
The type-generators provide types such as iterators and size_type of
external collections whereas the
Free-standing functions are for extracting iterators and size of the
external collections.
Here is a small example:
// 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 )
{
boost::iterator_of<EC>::type found = find( c, v );
*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' );
As the External Concepts idea is a rather new one, I would like to ask you
to comment on this.
Please always state in your review, whether you think the library should be
accepted as a Boost library!
Additionally please consider giving feedback on the following general
topics:
- What is your evaluation of the design?
- What is your evaluation of the implementation?
- What is your evaluation of the documentation?
- What is your evaluation of the potential usefulness of the library?
- Did you try to use the library? With what compiler? Did you have any
problems?
- How much effort did you put into your evaluation? A glance? A quick
reading? In-depth study?
- Are you knowledgeable about the problem domain?
Regards Hartmut
Review Manager
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk