Fix BOOST_FOREACH support; add test

This commit is contained in:
Peter Dimov 2018-09-05 07:59:20 +03:00
parent 5a93351bfd
commit f13aa18a93
3 changed files with 75 additions and 6 deletions

View File

@ -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

View File

@ -6,7 +6,7 @@
import testing ;
project
project
: requirements
<library>/boost/filesystem//boost_filesystem
<library>/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 : : : <test-info>always_show_run_output ]
[ run operations_test.cpp : : : <link>shared <test-info>always_show_run_output ]
[ run operations_test.cpp : : : <link>static : operations_test_static ]
[ run operations_unit_test.cpp : $(HERE) : : <link>shared <test-info>always_show_run_output ]
[ run path_test.cpp : : : <link>shared ]
[ run path_test.cpp : : : <link>static : path_test_static ]
[ run path_unit_test.cpp : : : <link>shared ]
[ run path_test.cpp : : : <link>shared ]
[ run path_test.cpp : : : <link>static : path_test_static ]
[ run path_unit_test.cpp : : : <link>shared ]
[ run path_unit_test.cpp : : : <link>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 ]

62
test/foreach_test.cpp Normal file
View File

@ -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 <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/config.hpp>
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
}