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
|
directory_iterator range_begin(const directory_iterator& iter) BOOST_NOEXCEPT
|
||||||
{return iter;}
|
{return iter;}
|
||||||
inline
|
inline
|
||||||
|
directory_iterator range_end(directory_iterator&) BOOST_NOEXCEPT
|
||||||
|
{return directory_iterator();}
|
||||||
|
inline
|
||||||
directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT
|
directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT
|
||||||
{return directory_iterator();}
|
{return directory_iterator();}
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
@ -1320,6 +1323,9 @@ namespace filesystem
|
|||||||
range_begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT
|
range_begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT
|
||||||
{return iter;}
|
{return iter;}
|
||||||
inline
|
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
|
recursive_directory_iterator range_end(const recursive_directory_iterator&) BOOST_NOEXCEPT
|
||||||
{return recursive_directory_iterator();}
|
{return recursive_directory_iterator();}
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import testing ;
|
import testing ;
|
||||||
|
|
||||||
project
|
project
|
||||||
: requirements
|
: requirements
|
||||||
<library>/boost/filesystem//boost_filesystem
|
<library>/boost/filesystem//boost_filesystem
|
||||||
<library>/boost/system//boost_system
|
<library>/boost/system//boost_system
|
||||||
@ -24,20 +24,21 @@ path-constant HERE : . ;
|
|||||||
[ run convenience_test.cpp ]
|
[ run convenience_test.cpp ]
|
||||||
[ compile macro_default_test.cpp ]
|
[ compile macro_default_test.cpp ]
|
||||||
[ run odr1_test.cpp odr2_test.cpp ]
|
[ run odr1_test.cpp odr2_test.cpp ]
|
||||||
[ run deprecated_test.cpp ]
|
[ run deprecated_test.cpp ]
|
||||||
[ run fstream_test.cpp ]
|
[ run fstream_test.cpp ]
|
||||||
[ run large_file_support_test.cpp ]
|
[ run large_file_support_test.cpp ]
|
||||||
[ run locale_info.cpp : : : <test-info>always_show_run_output ]
|
[ 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>shared <test-info>always_show_run_output ]
|
||||||
[ run operations_test.cpp : : : <link>static : operations_test_static ]
|
[ run operations_test.cpp : : : <link>static : operations_test_static ]
|
||||||
[ run operations_unit_test.cpp : $(HERE) : : <link>shared <test-info>always_show_run_output ]
|
[ 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>shared ]
|
||||||
[ run path_test.cpp : : : <link>static : path_test_static ]
|
[ run path_test.cpp : : : <link>static : path_test_static ]
|
||||||
[ run path_unit_test.cpp : : : <link>shared ]
|
[ run path_unit_test.cpp : : : <link>shared ]
|
||||||
[ run path_unit_test.cpp : : : <link>static : path_unit_test_static ]
|
[ 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/simple_ls.cpp ]
|
||||||
[ run ../example/file_status.cpp ]
|
[ run ../example/file_status.cpp ]
|
||||||
|
[ run foreach_test.cpp ]
|
||||||
|
|
||||||
# `quick` target (for CI)
|
# `quick` target (for CI)
|
||||||
[ run quick.cpp ]
|
[ 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