|
Boost Users : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-08-07 16:16:59
I wrote an iterator to do recursive directory iteration. The heart of it
is:
template< typename Predicate >
class recursive_directory_iterator
: public boost::iterator_adaptor<
boost::shared_ptr< detail::rdi_imp< Predicate > >,
detail::rdi_policies,
const boost::filesystem::path,
const boost::filesystem::path &,
const boost::filesystem::path *,
std::input_iterator_tag,
std::ptrdiff_t >
{ ... };
Works fine as long as you stay away from operator->.
For example,
fs::recursive_directory_iterator<pred_type> rdi( dir , dummy );
fs::recursive_directory_iterator<pred_type> rdi_end;
for ( ; rdi != rdi_end; ++rdi )
{
// std::cout << rdi->generic_path() << std::endl;
std::cout << (*rdi).generic_path() << std::endl;
}
works as expected. But if you uncomment the commented line, the program
fails in the call to operator->. What "fails" means depends on the
execution environment; whatever is happening seems to confuse the debugger,
stepping doesn't shed much light on the problem. Same symptoms with both
VC++7 and Intel 6.0.
I suppose I'm doing something stupid, but don't have a clue as to what.
I notice in iterator_adaptor_test.cpp that operator-> is not actually
exercised. Is it possible there is a bug in it for input iterators? I've
not had similar problems with iterator_adaptor for bidirectional iterators.
Any help appreciated,
--Beman
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net