Thread overview | |||||
---|---|---|---|---|---|
|
July 14, 2007 WINSTL basic_findfile_sequence has no iterator typedef | ||||
---|---|---|---|---|
| ||||
Hello! The basic_findfile_sequence in winstl has no iterator type defined, only a const_iterator. I noticed that when I tried to use it with BOOST_FOREACH, which requires an iterator type. So Long... Gabor |
July 14, 2007 Re: WINSTL basic_findfile_sequence has no iterator typedef | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gabor Fischer | Gabor Fischer Wrote:
> Hello!
>
>
> The basic_findfile_sequence in winstl has no iterator type defined, only a const_iterator. I noticed that when I tried to use it with BOOST_FOREACH, which requires an iterator type.
That's by design. A collection that represents a file-system cannot be mutating.
The problem is with BOOST_FOREACH. I don't know how it's implemented, but it clearly makes an invalid assumption - namely, that an STL collection must be mutating. What it should be doing is to use IIA (Inferred Interface Adaptation) to deduce the mutability of the collection, and using the appropriate iterator member type.
Cheers
Matt
|
July 18, 2007 Re: WINSTL basic_findfile_sequence has no iterator typedef | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Hello Matthew! >> Hello! >> >> >> The basic_findfile_sequence in winstl has no iterator type defined, only a const_iterator. I noticed that when I tried to use it with BOOST_FOREACH, which requires an iterator type. > That's by design. A collection that represents a file-system cannot be mutating. Makes sense. > The problem is with BOOST_FOREACH. I don't know how it's implemented, but it clearly makes an invalid assumption - namely, that an STL collection must be mutating. What it should be doing is to use IIA (Inferred Interface Adaptation) to deduce the mutability of the collection, and using the appropriate iterator member type. I have researched a bit more about BOOST_FOREACH and found out how to adapt it so that it can be used with findfile_sequence. One has to add following template specialisation: namespace boost { // specialize range_iterator in namespace boost template<typename C, typename T> struct range_iterator<winstl::basic_findfile_sequence<C, T> > { typedef typename winstl::basic_findfile_sequence<C, T>::const_iterator type; }; } That's all, and BOOST_FOREACH can be used to iterate over files. I have only tested it with VC++ 2005. So Long... Gabor |
Copyright © 1999-2021 by the D Language Foundation