[Range] Interest in range concept checks

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Range] Interest in range concept checks

Daniel Walker-4
Hello,

I've been using the Boost Range library a lot lately and felt the need for
some compile-time concept checks. They're pretty simple to write using the
Boost Concept Check library. So, I wrote concept checking classes for the
four range concepts mentioned in the documentation. To illustrate their
usage, the following checks if a type X models the ForwardRange concept.

function_requires<ForwardRangeConcept<X> >();

I've been checking the value access property of the range separately using
iterator concept checks on the range's iterator. So, for a
ForwardReadableRange ...

function_requires<ForwardRangeConcept<X> >();
function_requires<
    ReadableIteratorConcept<
        typename range_iterator<X>::type
    >
>();

Implementing the concept checking classes is pretty straight forward using
the range documentation. As an example, here's my implementation for
BidierctionalRange.

template<typename X>
struct BidirectionalRangeConcept {
    typedef typename range_reverse_iterator<X>::type range_reverse_iterator;
    typedef typename range_const_reverse_iterator<X>::type
range_const_reverse_iterator;
    void constraints()
    {
        function_requires<ForwardRangeConcept<X> >();
        function_requires<
            boost_concepts::BidirectionalTraversalConcept<
                typename range_iterator<X>::type
            >
        >();
        i = rbegin(a);
        i = rend(a);
        const_constraints(a);
    }
    void const_constraints(const X& a)
    {
        ci = rbegin(a);
        ci = rend(a);
    }
    X a;
    range_reverse_iterator i;
    range_const_reverse_iterator ci;
};

Anyway, I hope there's enough interest to include concept checks like these
in the Boost Range library for a future release. I'd be glad to submit a
file containing my implementations. Please, let me know what you think!

Thanks,
 Daniel Walker
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [Range] Interest in range concept checks

Thorsten Ottosen
Daniel Walker wrote:
> Hello,
>
> I've been using the Boost Range library a lot lately and felt the need for
> some compile-time concept checks. They're pretty simple to write using the
> Boost Concept Check library. So, I wrote concept checking classes for the
> four range concepts mentioned in the documentation. To illustrate their
> usage, the following checks if a type X models the ForwardRange concept.

> Anyway, I hope there's enough interest to include concept checks like these
> in the Boost Range library for a future release. I'd be glad to submit a
> file containing my implementations. Please, let me know what you think!

I haven't got time to look at you implementation, but I'm confident
it would be a nice addition to the concept-check library. Try
to contact the author/maintainer of that library directly.

-Thorsten
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [Range] Interest in range concept checks

Daniel Walker-4
Thorsten Ottosen wrote:
> Daniel Walker wrote:
> > Anyway, I hope there's enough interest to include concept checks like these
> > in the Boost Range library for a future release. I'd be glad to submit a
> > file containing my implementations. Please, let me know what you think!
>
> I haven't got time to look at you implementation, but I'm confident
> it would be a nice addition to the concept-check library. Try
> to contact the author/maintainer of that library directly.

OK, I just e-mailed Jeremy Siek. However, I was under the impression
that new concept checking classes would be included in the library
that defines the new concepts. For example, Boost.Graph and
Boost.Iterator both include their own concept checks. That's why I
thought range concept checks should go in the Boost Range library
rather than the Boost Concept Check library. Thoughts?

Daniel Walker

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [Range] Interest in range concept checks

David Abrahams
In reply to this post by Thorsten Ottosen
Thorsten Ottosen <[hidden email]> writes:

> Daniel Walker wrote:
>> Hello,
>>
>> I've been using the Boost Range library a lot lately and felt the need for
>> some compile-time concept checks. They're pretty simple to write using the
>> Boost Concept Check library. So, I wrote concept checking classes for the
>> four range concepts mentioned in the documentation. To illustrate their
>> usage, the following checks if a type X models the ForwardRange concept.
>
>> Anyway, I hope there's enough interest to include concept checks like these
>> in the Boost Range library for a future release. I'd be glad to submit a
>> file containing my implementations. Please, let me know what you think!
>
> I haven't got time to look at you implementation, but I'm confident
> it would be a nice addition to the concept-check library. Try
> to contact the author/maintainer of that library directly.

Concept checks for the Range concepts belong in the range library.
The concept check library shouldn't be grown to include checks for
every concept defined by another library author.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost