diff --git a/include/boost/filesystem/operations.hpp b/include/boost/filesystem/operations.hpp index b0ea42a..91aa2eb 100644 --- a/include/boost/filesystem/operations.hpp +++ b/include/boost/filesystem/operations.hpp @@ -968,6 +968,9 @@ namespace detail directory_iterator range_begin(const directory_iterator& iter) BOOST_NOEXCEPT {return iter;} inline + directory_iterator range_end(directory_iterator&) BOOST_NOEXCEPT + {return directory_iterator();} + inline directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT {return directory_iterator();} } // namespace filesystem @@ -1320,6 +1323,9 @@ namespace filesystem range_begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT {return iter;} inline + recursive_directory_iterator range_end(recursive_directory_iterator&) BOOST_NOEXCEPT + {return recursive_directory_iterator();} + inline recursive_directory_iterator range_end(const recursive_directory_iterator&) BOOST_NOEXCEPT {return recursive_directory_iterator();} } // namespace filesystem diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 51556f3..fa4a01a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -6,7 +6,7 @@ import testing ; -project +project : requirements /boost/filesystem//boost_filesystem /boost/system//boost_system @@ -24,20 +24,21 @@ path-constant HERE : . ; [ run convenience_test.cpp ] [ compile macro_default_test.cpp ] [ run odr1_test.cpp odr2_test.cpp ] - [ run deprecated_test.cpp ] + [ run deprecated_test.cpp ] [ run fstream_test.cpp ] [ run large_file_support_test.cpp ] [ run locale_info.cpp : : : always_show_run_output ] [ run operations_test.cpp : : : shared always_show_run_output ] [ run operations_test.cpp : : : static : operations_test_static ] [ run operations_unit_test.cpp : $(HERE) : : shared always_show_run_output ] - [ run path_test.cpp : : : shared ] - [ run path_test.cpp : : : static : path_test_static ] - [ run path_unit_test.cpp : : : shared ] + [ run path_test.cpp : : : shared ] + [ run path_test.cpp : : : static : path_test_static ] + [ run path_unit_test.cpp : : : shared ] [ run path_unit_test.cpp : : : static : path_unit_test_static ] - [ run relative_test.cpp ] + [ run relative_test.cpp ] [ run ../example/simple_ls.cpp ] [ run ../example/file_status.cpp ] + [ run foreach_test.cpp ] # `quick` target (for CI) [ run quick.cpp ] diff --git a/test/foreach_test.cpp b/test/foreach_test.cpp new file mode 100644 index 0000000..c6280f7 --- /dev/null +++ b/test/foreach_test.cpp @@ -0,0 +1,62 @@ + +// Copyright 2018 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/filesystem + +#include +#include +#include + +namespace fs = boost::filesystem; + +int main() +{ + { + fs::directory_iterator const it; + + BOOST_FOREACH( fs::path const& p, it ) + { + p.string(); + } + } + +#if !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) + + { + fs::directory_iterator const it; + + for( fs::path const& p: it ) + { + p.string(); + } + } + +#endif + + { + fs::recursive_directory_iterator it; + + BOOST_FOREACH( fs::path const& p, it ) + { + p.string(); + } + } + +#if !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) + + { + fs::recursive_directory_iterator const it; + + for( fs::path const& p: it ) + { + p.string(); + } + } + +#endif +}