mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 13:41:47 +00:00
Fix BOOST_FOREACH support; add test
This commit is contained in:
parent
5a93351bfd
commit
f13aa18a93
@ -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
|
||||
|
@ -38,6 +38,7 @@ path-constant HERE : . ;
|
||||
[ 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
62
test/foreach_test.cpp
Normal 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user