Sponsored Link •
|
The value_type for readdir_sequence is struct dirent const*. If it was something that was implicitly convertible to std::string, then you�d be able to write the succinct[1]:
readdir_sequence dir(HOME, readdir_sequence::directories); vector<string> dirNames; std::copy(dir.begin(), dir.end(), std::back_inserter(dirNames));or the positively parsimonious:
readdir_sequence dir(HOME, readdir_sequence::directories); vector<string> dirNames(dir.begin(), dir.end());Since
d_name
is the only member of struct dirent
that is guaranteed to be available on any platform, it's clear, in
hindsight — that great friend of the library writer — that
readdir_sequence::const_iterator
should have been designed to
have a value type char const*
. Unfortunately, we are stuck
with it [1], since consideration for its users
constrains us from making breaking changes to existing classes.
Subsequent STLSoft sequence classes have learned from this, and generally
provide more manipulable value types.
readdir_sequence
and a whole variety of other sequence types
whose value_types are not implicitly convertible to string
,
but which are logically strings or things meaningfully expressible
strings. But that's going to have to be a whole 'nuther article.
Sponsored Links
|