Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2005-09-01 03:53:43


Hi Eric,

On Wed, Aug 31, 2005 at 03:46:32PM -0700, Eric Niebler wrote:
>
> While investigating test failures with Boost.Foreach, I found this in
> Boost.Range's documentation for extending the Range library:
>
> http://boost.org/libs/range/doc/boost_range.html#minimal_interface
>
> This seems to suggest that the only way to extend Boost.Range is for
> user-defined types to implement a std-container-like interface, with
> nested iterator and const_iterator types, and begin() and end() member
> functions. Is this really the intention? I seem to recall some
> discussion about a more accomodating extensibility mechanism that makes
> allowances for non-std-container-like user-defined range types. In fact,
> Boost.Foreach assumes such an interface, with disastrous results. What
> became of Boost.Range's extensibility mechanism? Is it documented
> anywhere, and I'm just not seeing it?
>

It might a problem with documentation, but it seems that you have misunderstood
the basic idea of the Range library.

Core of the range library is not in the code, rather in concepts that are defined
there.

http://boost.org/libs/range/doc/range.html

These concepts define a uniform way for accessing range-like structures.
They are wholy defined in terms of external (free-standing) functions like
begin(r), end(r) and etc. and specializations of metafuctions like
boost::range_value<>.

Therefor if a structure is to be considered to be a range, it has to provide
this interface.

In addition to this, library implements this interface for some common range types
available in the C++ and the standard library.
The page you have refered to actualy describes this implementation.

To sumarize, if you want to provide a support for a user-defined class, you
have two options.

- Either you provide external range accessors. In other words, you make your class to
  be a model of Range Concept.
- Or you make it look like std-container and than you actualy use the accessors
  provided in the range library.

Best regards,
Pavol.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk