| 1 |
// { dg-do run { target c++20 } } |
| 2 |
// { dg-require-filesystem-ts "" } |
| 3 |
|
| 4 |
#include <filesystem> |
| 5 |
#include <iterator> |
| 6 |
#include <testsuite_hooks.h> |
| 7 |
|
| 8 |
// LWG 3719. Directory iterators should be usable with default sentinel |
| 9 |
|
| 10 |
void |
| 11 |
test_dir_iter() |
| 12 |
{ |
| 13 |
std::filesystem::directory_iterator d0; |
| 14 |
VERIFY( d0 == std::default_sentinel ); |
| 15 |
std::filesystem::directory_iterator d1("."); |
| 16 |
VERIFY( d1 != std::default_sentinel ); |
| 17 |
|
| 18 |
static_assert( noexcept(d0 == std::default_sentinel) ); |
| 19 |
static_assert( noexcept(d0 != std::default_sentinel) ); |
| 20 |
} |
| 21 |
|
| 22 |
void |
| 23 |
test_recursive_dir_iter() |
| 24 |
{ |
| 25 |
std::filesystem::recursive_directory_iterator d0; |
| 26 |
VERIFY( d0 == std::default_sentinel ); |
| 27 |
std::filesystem::recursive_directory_iterator d1("."); |
| 28 |
VERIFY( d1 != std::default_sentinel ); |
| 29 |
|
| 30 |
static_assert( noexcept(d0 == std::default_sentinel) ); |
| 31 |
static_assert( noexcept(d0 != std::default_sentinel) ); |
| 32 |
} |
| 33 |
|
| 34 |
int main() |
| 35 |
{ |
| 36 |
test_dir_iter(); |
| 37 |
test_recursive_dir_iter(); |
| 38 |
} |