Custom Containers & Iterators for STL-Friendly Code
By Ethan McCallum, March 01, 2005
Need to add functionality to containers to make classes more STL friendly, or create new containers and iterators from scratch to make legacy code available to STL algorithms? Here's how.
March, 2005: Custom Containers & Iterators for STL-Friendly Code
Listing 1
class STLGlob {
private:
glob_t pglob_ ;
STLGlob( const std::string& pattern )
:
glob_()
{
push_back( pattern ) ;
}
void push_back( const std::string& pattern ){
glob( pattern.c_str() , /* ... */ , &glob_ ) ;
}
size_type size(){
return( pglob_.gl_pathc ) ;
}
STLGlob::~STLGlob() {
globfree( &glob_ ) ;
}
} ;