Boost logo

Boost :

Subject: Re: [boost] A design for geometric objects
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-11-15 21:06:00


Steven Watanabe wrote:

> Wait. How does that work:
>
> Right triangle models Triangle.
> Equilateral triangle models Triangle.
> Therefore, right triangle can be converted to equilateral triangle?

Actually I meant only the concept it directly models, not the ones which
are indirectly so.
A model of Right triangle can be constructed from any model of Right
triangle, but not from a model of Triangle.

The idea is to be able to have similar mechanisms to that of
containers/ranges with adaptors, such as this example:

SomeContainer a = transform(some_range, some_function);
(actually you have to write
SomeContainer a(
     begin(transform(some_range, some_function)),
     end(transform(some_range, some_function))
);)

with transform = make_transform_range from Boost.RangeEx.

This results in something fairly equivalent to

SomeContainer a;
std::transform(
     some_range.begin(), some_range.end(),
     std::back_inserter(a),
     some_function
);

Maybe it shouldn't be required however. For ranges which are proxies or
adaptors it makes little sense to be able to be constructed from any range.


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