foreach_test.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2018 Peter Dimov.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. //
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. // See library home page at http://www.boost.org/libs/filesystem
  8. #include <boost/filesystem.hpp>
  9. #include <boost/foreach.hpp>
  10. #include <boost/config.hpp>
  11. namespace fs = boost::filesystem;
  12. int main()
  13. {
  14. {
  15. fs::directory_iterator const it;
  16. BOOST_FOREACH( fs::path const& p, it )
  17. {
  18. p.string();
  19. }
  20. }
  21. #if !defined(BOOST_NO_CXX11_RANGE_BASED_FOR)
  22. {
  23. fs::directory_iterator const it;
  24. for( fs::path const& p: it )
  25. {
  26. p.string();
  27. }
  28. }
  29. #endif
  30. {
  31. fs::recursive_directory_iterator it;
  32. BOOST_FOREACH( fs::path const& p, it )
  33. {
  34. p.string();
  35. }
  36. }
  37. #if !defined(BOOST_NO_CXX11_RANGE_BASED_FOR)
  38. {
  39. fs::recursive_directory_iterator const it;
  40. for( fs::path const& p: it )
  41. {
  42. p.string();
  43. }
  44. }
  45. #endif
  46. }