RE: [boost] Container Traits

This library is an interesting concept but when I looked in it, it didn't have what I would have thought were "container traits" the way I think of "iterator traits". From the VTL library I wanted to be able to query the container to see if it was an associative container, or a sequence container or a random access container, i.e. had an operator[]() etc. Can one of the authors explain the purpose of this library? Yours, -Gary-

"Powell, Gary" <powellg@amazon.com> wrote in message news:16D81990DBE42642A8CA977A55FF116A02D9F636@ex-mail-sea-02.ant.amazon.com...
This library is an interesting concept but when I looked in it, it didn't have what I would have thought were "container traits" the way I think of "iterator traits". From the VTL library I wanted to be able to query the container to see if it was an associative container, or a sequence container or a random access container, i.e. had an operator[]() etc.
Can one of the authors explain the purpose of this library?
Thorsten Ottosen is the authorative source on this point, but I think the library is mostly to provide support for algorithms which treat standard constainers, built-in arrays and iterator ranges uniformly. (I'm leaving out one case.) I, too, would like traits of the type you suggest, and I wish they would be added to the library. One problem, of course, is that theoretcially you could have a type which look like a container, because of its member types, but doesn't have the correct semantics. Also, the amount of introspection required to be reasonably sure you have a container has some compile-time cost. I think these problems are negligible if the traits are named and documented with these considerations in mind. Probably I've been reading the FC++ docs too much recently, but one might call them 'maybe_is_container', 'maybe_is_sequence', ... ;-) I think there should at least be traits for detecting standard container types (is_basic_string, is_vector, is_standard_sequence). One problem is that you might end up including the whole STL just to define these traits. Jonathan

Hi, Purpose of this library is to unify an access to an arbitrary "collection". Concept of the collection is defined in a paper which is currently perfectly hidden in boost/libs/utility/Collection.html Major benefit it brings is, that it is possible to define non-intrusive, yet uniform stl-like access to containers where is would not be possible otherwise. This allows us to create generic algorithm, that work on wider range of containers, not just those in stl. container traits (or collection traits as it should be renamed) concept is heavily used by string_algo library. For instance the library can handle c-char arrays in much the same way as std::string Classification has been proposed, but without a little help from stl, it is rather hard to implement satisfactory. Because it is forbiden to introduce a code into std namespace, we cannot make forward declaration of std containers. So to make specialization needed for clasification, we would have to include all container headers. Regards, Pavol On Tue, Mar 02, 2004 at 01:50:21PM -0800, Powell, Gary wrote:
This library is an interesting concept but when I looked in it, it didn't have what I would have thought were "container traits" the way I think of "iterator traits". From the VTL library I wanted to be able to query the container to see if it was an associative container, or a sequence container or a random access container, i.e. had an operator[]() etc.
Can one of the authors explain the purpose of this library?
Yours, -Gary-
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Pavol Droba <droba@topmail.sk> writes:
Hi,
Purpose of this library is to unify an access to an arbitrary "collection". Concept of the collection is defined in a paper which is currently perfectly hidden in boost/libs/utility/Collection.html
Major benefit it brings is, that it is possible to define non-intrusive, yet uniform stl-like access to containers where is would not be possible otherwise. This allows us to create generic algorithm, that work on wider range of containers, not just those in stl.
container traits (or collection traits as it should be renamed) concept is heavily used by string_algo library. For instance the library can handle c-char arrays in much the same way as std::string
I hope we can move away from the use of the term "traits" to mean "any old non-intrusive interface that can be customized for a particular type". Behaviors like push_back, IMO, just don't belong in something called "traits" -- traits is a very passive term. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (4)
-
David Abrahams
-
Jonathan Turkanis
-
Pavol Droba
-
Powell, Gary