how to make a copy of boost::filesystem::directory_iterator?

前端 未结 1 1595
迷失自我
迷失自我 2021-01-18 19:48

I know this sounds stupid, but look at this simple example (working dir should have more than one item):

#define BOOST_FILESYSTEM_VERSION 3
#include 

        
相关标签:
1条回答
  • 2021-01-18 20:24

    If you take a look at the reference you will notice that it is advertised to be a boost::single_pass_traversal_tag.

    This is the equivalent (in boost terminology) of the Input Iterator in the STL (think of it as an iterator delivering packets from a network connection, you cannot rewind).

    Also note (from this same page):

    i == j does not imply that ++i == ++j.

    At this point, one may wonder why it can be copied. The reason is that STL algorithms have set the norm taking their arguments by copy. Therefore it would not be usable with STL algorithms if it could not be copied.

    0 讨论(0)
提交回复
热议问题