Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Struct template collection_traits

boost::algorithm::collection_traits — collection_traits class


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. 


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