diff --git a/stl/inc/filesystem b/stl/inc/filesystem index e15989c589e..36a1b772eca 100644 --- a/stl/inc/filesystem +++ b/stl/inc/filesystem @@ -4337,6 +4337,20 @@ namespace filesystem { return _STD filesystem::copy(_From, _To, copy_options::none); } } // namespace filesystem + +#ifdef __cpp_lib_concepts +namespace ranges { + template <> + inline constexpr bool enable_borrowed_range = true; + template <> + inline constexpr bool enable_borrowed_range = true; + template <> + inline constexpr bool enable_view = true; + template <> + inline constexpr bool enable_view = true; +} // namespace ranges +#endif // __cpp_lib_concepts + _STD_END #pragma pop_macro("new") diff --git a/tests/std/test.lst b/tests/std/test.lst index 8ef66c88176..c5b579efb76 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -192,6 +192,7 @@ tests\GH_002120_streambuf_seekpos_and_seekoff tests\LWG2597_complex_branch_cut tests\LWG3018_shared_ptr_function tests\LWG3422_seed_seq_ctors +tests\LWG3480_directory_iterator_range tests\P0019R8_atomic_ref tests\P0024R2_parallel_algorithms_adjacent_difference tests\P0024R2_parallel_algorithms_adjacent_find diff --git a/tests/std/tests/LWG3480_directory_iterator_range/env.lst b/tests/std/tests/LWG3480_directory_iterator_range/env.lst new file mode 100644 index 00000000000..18e2d7c71ec --- /dev/null +++ b/tests/std/tests/LWG3480_directory_iterator_range/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\concepts_latest_matrix.lst diff --git a/tests/std/tests/LWG3480_directory_iterator_range/test.compile.pass.cpp b/tests/std/tests/LWG3480_directory_iterator_range/test.compile.pass.cpp new file mode 100644 index 00000000000..f08b28ef0f8 --- /dev/null +++ b/tests/std/tests/LWG3480_directory_iterator_range/test.compile.pass.cpp @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std::filesystem; +using namespace std::ranges; + +bool is_tiff(const directory_entry& entry) { + return entry.is_regular_file() && entry.path().extension().native() == L"tiff"; +} + +void test(directory_iterator dir) { + [[maybe_unused]] auto tif_files = dir | views::filter(is_tiff); + [[maybe_unused]] auto first_5_files = dir | views::take(5); + static_assert(borrowed_range); +} + +void test_recursive(recursive_directory_iterator dir) { + [[maybe_unused]] auto tif_files = dir | views::filter(is_tiff); + [[maybe_unused]] auto first_5_files = dir | views::take(5); + static_assert(borrowed_range); +} + +int main() {} // COMPILE-ONLY