| Home | Libraries | People | FAQ | More

## Struct template collection_traits

boost::algorithm::collection_traits — collection_traits class

## Synopsis

    template<typename T>
    struct collection_traits {
      // types
      typedef container_helper_type                  function_type;    // Function type.
      typedef container_helper_type::value_type      value_type;       // Value type.
      typedef container_helper_type::size_type       size_type;        // Size type.
      typedef container_helper_type::iterator        iterator;         // Iterator type.
      typedef container_helper_type::const_iterator  const_iterator;   // Const iterator type.
      typedef container_helper_type::result_iterator result_iterator;  // Result iterator type ( iterator of const_iterator, depending on the constness of the container ).
      typedef container_helper_type::difference_type difference_type;  // Difference type.
    };

## Description

Collection traits provide uniform access to different types of collections. This functionality allows to write generic algorithms which work with several different kinds of collections.

Currently following collection types are supported:

- containers with STL compatible container interface ( see ContainerConcept ) ( i.e. `std::vector<>` , `std::list<>` , `std::string<>` ... )

- c-style array ( `char` [10], `int` [15] ... )

- null-terminated c-strings ( `char*` , `wchar_T*` )

- std::pair of iterators ( i.e `std::pair<vector<int>::iterator` ,vector<int>::iterator> )

Collection traits provide an external collection interface operations. All are accessible using free-standing functions.

The following operations are supported:

- `size()`

- `empty()`

- `begin()`

- `end()`

Container traits have somewhat limited functionality on compilers not supporting partial template specialization and partial template ordering.

| Copyright © 2002-2004 Pavol Droba