diff --git a/Build.md b/Build.md index 92cc5e1a..dc8e9278 100644 --- a/Build.md +++ b/Build.md @@ -8,8 +8,7 @@ These compilers and OSs are regularly tested by CI: - Visual Studio on Windows Other compilers, architectures and OSs may work, but are not tested regularly. -You will need a working [Filesystem TS](https://en.cppreference.com/w/cpp/experimental/fs) -implementation in your STL, and at least C++ 14. +You will need a working Filesystem implementation in your STL, and at least C++ 17. LLFIO has your choice of header-only, static library, and shared library build modes. Note that on Microsoft Windows, the default header only configuration is unsafe diff --git a/CMakeLists.txt b/CMakeLists.txt index cb6b3c79..99ce3220 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,33 +183,13 @@ endif() include(QuickCppLibApplyDefaultDefinitions) # Set the C++ features this library requires -all_compile_features(PUBLIC - # cxx_exceptions ## Annoyingly not supported by cmake 3.6 - cxx_alias_templates - cxx_variadic_templates - cxx_noexcept - cxx_constexpr - cxx_lambda_init_captures - cxx_attributes - cxx_generic_lambdas -) -if(NOT MSVC OR CMAKE_VERSION VERSION_GREATER 3.59) - all_compile_features(PUBLIC - cxx_variable_templates - ) -endif() +all_compile_features(PUBLIC cxx_std_17) set(check_cxx_source_linkage_flags) -# If on VS2019 16.3 or later, or on Apple, we require C++ 17 -if((MSVC AND MSVC_VERSION VERSION_GREATER_EQUAL 1923) OR APPLE) - all_compile_features(PUBLIC - cxx_std_17 - ) - if(NOT CMAKE_CXX_STANDARD) - if(MSVC) - set(check_cxx_source_linkage_flags /std:c++17) - else() - set(check_cxx_source_linkage_flags -std=c++17) - endif() +if(NOT CMAKE_CXX_STANDARD) + if(MSVC) + set(check_cxx_source_linkage_flags /std:c++17) + else() + set(check_cxx_source_linkage_flags -std=c++17) endif() endif() # Set the library dependencies this library has @@ -264,93 +244,7 @@ int main() { } " CXX_HAS_CXX17_FILESYSTEM) if(NOT CXX_HAS_CXX17_FILESYSTEM) - check_cxx_source_linkage(" -#include -int main() { - try { return std::experimental::filesystem::path(\"hi\").empty(); } catch(std::experimental::filesystem::filesystem_error) { return 1; } -} -" CXX_HAS_CXX_EXPERIMENTAL_FILESYSTEM) -endif() -if(NOT CXX_HAS_CXX17_FILESYSTEM AND NOT CXX_HAS_CXX_EXPERIMENTAL_FILESYSTEM) - indented_message(STATUS "NOTE: Standard not found in the current compiler configuration (try forcing C++ 17 or later?), attempting to figure out what linker flags to use for this STL ...") - # Are we on libstdc++ or libc++? - check_cxx_source_compiles(" -#include -int main() { -#ifdef __GLIBCXX__ - std::cout << \"hi\"; - return 0; -#else - return i am not a number; -#endif -} -" CXX_IS_USING_LIBSTDCXX) - check_cxx_source_compiles(" -#include -int main() { -#ifdef _LIBCPP_VERSION - std::cout << \"hi\"; - return 0; -#else - return i am not a number; -#endif -} -" CXX_IS_USING_LIBCXX) - if(NOT CXX_IS_USING_LIBSTDCXX AND NOT CXX_IS_USING_LIBCXX) - indented_message(FATAL_ERROR "FATAL: is not available, and neither libstdc++ nor libc++ STLs will link a program") - endif() - set(stl_filesystem_link_flags) - # If on libstdc++, we need to link in stdc++fs for experimental filesystem - if(CXX_IS_USING_LIBSTDCXX) - find_library(libstdcxx_stdcxxfs stdc++fs) - if(libstdcxx_stdcxxfs MATCHES "NOTFOUND") - set(libstdcxx_stdcxxfs -lstdc++fs) - endif() - all_link_libraries(PUBLIC ${libstdcxx_stdcxxfs}) - list(APPEND stl_filesystem_link_flags ${libstdcxx_stdcxxfs}) - endif() - # If on libc++, we may need to link in c++fs or c++experimental for experimental filesystem - if(CXX_IS_USING_LIBCXX) - find_library(libcxx_cxxfs c++fs) - find_library(libcxx_cxxexperimental c++experimental) - if(libcxx_cxxfs MATCHES "NOTFOUND" AND libcxx_cxxexperimental MATCHES "NOTFOUND") - # I guess default to forcing libc++experimental? - set(libcxx_cxxexperimental -lc++experimental) - endif() - if(NOT libcxx_cxxfs MATCHES "NOTFOUND") - all_link_libraries(PUBLIC ${libcxx_cxxfs}) - list(APPEND stl_filesystem_link_flags ${libcxx_cxxfs}) - endif() - if(NOT libcxx_cxxexperimental MATCHES "NOTFOUND") - all_link_libraries(PUBLIC ${libcxx_cxxexperimental}) - list(APPEND stl_filesystem_link_flags ${libcxx_cxxexperimental}) - endif() - # Disable the irritating warnings - all_compile_definitions(PUBLIC _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM=1) - endif() - function(check_stl_filesystem_link_flags) - indented_message(STATUS "NOTE: Using STL link flags '${ARGN}'") - set(CMAKE_REQUIRED_LIBRARIES ${ARGN}) - check_cxx_source_linkage(" -#include -int main() { - try { return std::filesystem::path(\"hi\").empty(); } catch(std::filesystem::filesystem_error) { return 1; } -} -" CXX_HAS_CXX_FILESYSTEM_AFTER_FLAGS) - check_cxx_source_linkage(" -#include -int main() { - try { return std::experimental::filesystem::path(\"hi\").empty(); } catch(std::experimental::filesystem::filesystem_error) { return 1; } -} -" CXX_HAS_CXX_EXPERIMENTAL_FILESYSTEM_AFTER_FLAGS) - if(NOT CXX_HAS_CXX_FILESYSTEM_AFTER_FLAGS AND NOT CXX_HAS_CXX_EXPERIMENTAL_FILESYSTEM_AFTER_FLAGS) - indented_message(FATAL_ERROR "FATAL: After probing multiple configurations, still cannot compile and link a or based program! Please adjust the configuration and/or install missing dependencies.") - endif() - endfunction() - check_stl_filesystem_link_flags(${stl_filesystem_link_flags}) - if(NOT CXX_HAS_CXX_FILESYSTEM_AFTER_FLAGS AND CXX_HAS_CXX_EXPERIMENTAL_FILESYSTEM_AFTER_FLAGS) - all_compile_definitions(PUBLIC LLFIO_FORCE_EXPERIMENTAL_FILESYSTEM=1 KERNELTEST_FORCE_EXPERIMENTAL_FILESYSTEM=1) - endif() + indented_message(FATAL_ERROR "FATAL: C++ 17 is not available, use a LLFIO from before year 2025 if you want legacy polyfill support") endif() if(LLFIO_FORCE_DYNAMIC_THREAD_POOL_GROUP_OFF) all_compile_definitions(PUBLIC LLFIO_EXCLUDE_DYNAMIC_THREAD_POOL_GROUP=1) @@ -424,18 +318,7 @@ foreach(special ${SPECIAL_BUILDS}) target_compile_definitions(llfio_dl-${special} PRIVATE LLFIO_SOURCE=1 LLFIO_DYN_LINK=1) endforeach() if(TARGET llfio-example_single-header) - set(compiler_has_cxx_17 0) - foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) - if(feature STREQUAL "cxx_std_17") - set(compiler_has_cxx_17 1) - endif() - endforeach() - # The single header test requires C++ 17 - if(compiler_has_cxx_17) - target_compile_features(llfio-example_single-header PRIVATE cxx_std_17) - else() - set_target_properties(llfio-example_single-header PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT_BUILD ON) - endif() + target_compile_features(llfio-example_single-header PRIVATE cxx_std_17) endif() if(NOT llfio_IS_DEPENDENCY AND (NOT DEFINED BUILD_TESTING OR BUILD_TESTING)) @@ -546,29 +429,29 @@ if(NOT llfio_IS_DEPENDENCY AND (NOT DEFINED BUILD_TESTING OR BUILD_TESTING)) if(UNIT_TESTS_CXX_VERSION STREQUAL "latest") set(LATEST_CXX_FEATURE) foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) - if(feature STREQUAL "cxx_std_23") + if(feature STREQUAL "cxx_std_26") if(NOT MSVC OR MSVC_VERSION VERSION_GREATER_EQUAL 1930) - set(LATEST_CXX_FEATURE "cxx_std_23") - indented_message(STATUS "NOTE: This compiler claims to support C++ 23, enabling for header-only unit test suite") + set(LATEST_CXX_FEATURE "cxx_std_26") + indented_message(STATUS "NOTE: This compiler claims to support C++ 26, enabling for header-only unit test suite") endif() endif() endforeach() if(NOT LATEST_CXX_FEATURE) foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) - if(feature STREQUAL "cxx_std_20") + if(feature STREQUAL "cxx_std_23") if(NOT MSVC OR MSVC_VERSION VERSION_GREATER_EQUAL 1930) - set(LATEST_CXX_FEATURE "cxx_std_20") - indented_message(STATUS "NOTE: This compiler claims to support C++ 20, enabling for header-only unit test suite") + set(LATEST_CXX_FEATURE "cxx_std_23") + indented_message(STATUS "NOTE: This compiler claims to support C++ 23, enabling for header-only unit test suite") endif() endif() endforeach() endif() if(NOT LATEST_CXX_FEATURE) foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) - if(feature STREQUAL "cxx_std_17") - if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0") - set(LATEST_CXX_FEATURE "cxx_std_17") - indented_message(STATUS "NOTE: This compiler claims to support C++ 17, enabling for header-only unit test suite") + if(feature STREQUAL "cxx_std_20") + if(NOT MSVC OR MSVC_VERSION VERSION_GREATER_EQUAL 1930) + set(LATEST_CXX_FEATURE "cxx_std_20") + indented_message(STATUS "NOTE: This compiler claims to support C++ 20, enabling for header-only unit test suite") endif() endif() endforeach() diff --git a/Readme.md b/Readme.md index 43ffa0d2..0abc27bc 100644 --- a/Readme.md +++ b/Readme.md @@ -21,15 +21,12 @@ as Intel Optane. It is a complete rewrite after a Boost peer review in August 2015. LLFIO is the reference implementation for these C++ standardisations: -- `llfio::path_view` is expected to enter the C++ 26 standard ([P1030](https://wg21.link/p1030)). -- `llfio::file_handle` and `llfio::mapped_file_handle` are on track for entering the C++ 26 standard ([P1883](https://wg21.link/p1883)). +- `llfio::path_view` is expected to enter the C++ 29 standard ([P1030](https://wg21.link/p1030)). Other characteristics: -- Portable to any conforming C++ 14 compiler with a working Filesystem TS in its STL. - - Note that VS2019 16.3 and libc++ 11 dropped support for Filesystem in C++ 14, so for those LLFIO's cmake forces on C++ 17. +- Portable to any conforming C++ 17 compiler with a working Filesystem in its STL. - Fully clean with C++ 20. - - Will make use of any Coroutines, Concepts, Span, Byte etc if you have them, otherwise swaps in C++ 14 compatible alternatives. - - NOTE that Ubuntu 18.04's libstdc++ 9 does not currently provide symbols for `` if you are building in C++ 20, so linking LLFIO programs on libstdc++ on that Linux if in C++ 20 will fail. Either use a different STL, manually rebuild libstdc++, or use C++ 17. + - Will make use of any Coroutines, Concepts, Span, Byte etc if you have them, otherwise swaps in C++ 17 compatible alternatives. - Aims to support Microsoft Windows, Linux, Android, iOS, Mac OS and FreeBSD. - Best effort to support older kernels up to their EOL (as of July 2020: >= Windows 8.1, >= Linux 2.6.32 (RHEL EOL), >= Mac OS 10.13, >= FreeBSD 11). - Original error code is always preserved, even down to the original NT kernel error code if a NT kernel API was used. diff --git a/example/wg21_path_view_benchmark.cpp b/example/wg21_path_view_benchmark.cpp index e734e3e1..6f37fa78 100644 --- a/example/wg21_path_view_benchmark.cpp +++ b/example/wg21_path_view_benchmark.cpp @@ -47,7 +47,7 @@ Traversal test for path_view (longer paths) ... #include "../include/llfio.hpp" #include "llfio/v2.0/directory_handle.hpp" -#if !defined(_WIN32) && (__cplusplus >= 201700L || _HAS_CXX17) +#if !defined(_WIN32) #include #include diff --git a/include/llfio/v2.0/config.hpp b/include/llfio/v2.0/config.hpp index 8f6c22c7..4a954773 100644 --- a/include/llfio/v2.0/config.hpp +++ b/include/llfio/v2.0/config.hpp @@ -135,32 +135,15 @@ Distributed under the Boost Software License, Version 1.0. #include "quickcpplib/cpp_feature.h" #ifndef STANDARDESE_IS_IN_THE_HOUSE -#ifndef __cpp_alias_templates -#error LLFIO needs template alias support in the compiler -#endif -#ifndef __cpp_variadic_templates -#error LLFIO needs variadic template support in the compiler -#endif -#if __cpp_constexpr < 201304L && !defined(_MSC_VER) -#error LLFIO needs relaxed constexpr (C++ 14) support in the compiler -#endif -#ifndef __cpp_init_captures -#error LLFIO needs lambda init captures support in the compiler (C++ 14) -#endif -#ifndef __cpp_attributes -#error LLFIO needs attributes support in the compiler -#endif -#ifndef __cpp_variable_templates -#error LLFIO needs variable template support in the compiler -#endif -#ifndef __cpp_generic_lambdas -#error LLFIO needs generic lambda support in the compiler +#if !(_HAS_CXX17 || __cplusplus >= 201700) +#error "LLFIO needs a minimum of C++ 17 support in the compiler" #endif #ifdef __has_include -// clang-format off -#if !__has_include() && !__has_include() -// clang-format on -#error LLFIO needs an implementation of the Filesystem TS in the standard library +#if !__has_include() +#error "LLFIO needs an implementation of C++ 17 in the standard library" +#endif +#if !__has_include() +#error "LLFIO needs an implementation of C++ 17 in the standard library" #endif #endif #endif @@ -242,60 +225,11 @@ LLFIO_V2_NAMESPACE_END #endif #include "quickcpplib/utils/thread.hpp" // Bring in filesystem -#if defined(__has_include) -// clang-format off -#if !LLFIO_FORCE_EXPERIMENTAL_FILESYSTEM && __has_include() && (__cplusplus >= 201700 || _HAS_CXX17) -#define LLFIO_USING_STD_FILESYSTEM 1 -#include -LLFIO_V2_NAMESPACE_BEGIN -namespace filesystem = std::filesystem; -LLFIO_V2_NAMESPACE_END -// C++ 14 filesystem support was dropped in VS2019 16.3 -// C++ 14 filesystem support was dropped in LLVM 11 -#elif __has_include() && (!defined(_MSC_VER) || _MSC_VER < 1923) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 11000) -#define LLFIO_USING_EXPERIMENTAL_FILESYSTEM 1 -#include -LLFIO_V2_NAMESPACE_BEGIN -namespace filesystem = std::experimental::filesystem; -LLFIO_V2_NAMESPACE_END -#elif !LLFIO_FORCE_EXPERIMENTAL_FILESYSTEM && __has_include() -#if defined(_MSC_VER) && _MSC_VER >= 1923 -#error MSVC dropped support for C++ 14 from VS2019 16.3 onwards. Please enable C++ 17 or later. -#endif -#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 11000 -#error libc++ dropped support for C++ 14 from LLVM 11 onwards. Please enable C++ 17 or later. -#endif -#define LLFIO_USING_STD_FILESYSTEM 1 -#include -LLFIO_V2_NAMESPACE_BEGIN -namespace filesystem = std::filesystem; -LLFIO_V2_NAMESPACE_END -#endif -#elif __PCPP_ALWAYS_TRUE__ #define LLFIO_USING_STD_FILESYSTEM 1 #include LLFIO_V2_NAMESPACE_BEGIN namespace filesystem = std::filesystem; -LLFIO_V2_NAMESPACE_END -// clang-format on -#elif defined(_MSC_VER) -#define LLFIO_USING_STD_FILESYSTEM 1 -#include -LLFIO_V2_NAMESPACE_BEGIN -namespace filesystem = std::experimental::filesystem; -LLFIO_V2_NAMESPACE_END -#else -#error No implementation found -#endif -#if LLFIO_USING_EXPERIMENTAL_FILESYSTEM && !LLFIO_DISABLE_USING_EXPERIMENTAL_FILESYSTEM_WARNING -#ifdef _MSC_VER -#pragma message( \ -"WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO.") -#else -#warning WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO. -#endif -#endif -LLFIO_V2_NAMESPACE_BEGIN + struct path_hasher { size_t operator()(const filesystem::path &p) const { return std::hash()(p.native()); } @@ -370,9 +304,9 @@ LLFIO_V2_NAMESPACE_BEGIN using namespace QUICKCPPLIB_NAMESPACE::span; LLFIO_V2_NAMESPACE_END // Bring in an optional implementation -#include "quickcpplib/optional.hpp" +#include LLFIO_V2_NAMESPACE_BEGIN -using namespace QUICKCPPLIB_NAMESPACE::optional; +template using optional = std::optional; LLFIO_V2_NAMESPACE_END // Bring in a byte implementation #include "quickcpplib/byte.hpp" @@ -381,9 +315,10 @@ using QUICKCPPLIB_NAMESPACE::byte::byte; using QUICKCPPLIB_NAMESPACE::byte::to_byte; LLFIO_V2_NAMESPACE_END // Bring in a string_view implementation -#include "quickcpplib/string_view.hpp" +#include LLFIO_V2_NAMESPACE_BEGIN -using namespace QUICKCPPLIB_NAMESPACE::string_view; +template > using basic_string_view = std::basic_string_view; +using std::string_view; LLFIO_V2_NAMESPACE_END // Bring in a function_ptr implementation #include "quickcpplib/function_ptr.hpp" @@ -424,9 +359,9 @@ using spinlock = QUICKCPPLIB_NAMESPACE::configurable_spinlock::spinlock LLFIO_V2_NAMESPACE_BEGIN -namespace pmr = QUICKCPPLIB_NAMESPACE::pmr; +namespace pmr = std::pmr; LLFIO_V2_NAMESPACE_END diff --git a/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp b/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp index 2a83dea5..3ab0e02a 100644 --- a/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp @@ -1040,7 +1040,7 @@ LLFIO_HEADERS_ONLY_FUNC_SPEC result to_win32_path(const fs_han { // Are any segments of the filename a reserved name? static -#if(_HAS_CXX17 || __cplusplus >= 201700) && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20170519) // libstdc++'s string_view is missing constexpr +#if(!defined(__GLIBCXX__) || __GLIBCXX__ > 20170519) // libstdc++'s string_view is missing constexpr constexpr #endif const wstring_view reserved_names[] = {L"\\CON\\", L"\\PRN\\", L"\\AUX\\", L"\\NUL\\", L"\\COM1\\", L"\\COM2\\", L"\\COM3\\", L"\\COM4\\", diff --git a/include/llfio/v2.0/path_view.hpp b/include/llfio/v2.0/path_view.hpp index de7cd519..26c45703 100644 --- a/include/llfio/v2.0/path_view.hpp +++ b/include/llfio/v2.0/path_view.hpp @@ -623,31 +623,10 @@ class LLFIO_DECL path_view_component LLFIO_PATH_VIEW_CONSTEXPR path_view_component _filename() const noexcept { auto sep_idx = _find_last_sep(); -#if LLFIO_USING_EXPERIMENTAL_FILESYSTEM -#ifdef _WIN32 - if(sep_idx == 2 && _length == 3) - { - return this->_invoke( - [this, sep_idx](const auto &v) mutable - { - if(v[1] == ':') - { - return path_view_component(v.data() + 2, 1, termination(), formatting()); - } - return *this; - }); - } -#endif - if(_npos == sep_idx || (_length == 1 && sep_idx == 0)) // Filesystem TS thinks the filename() of "/" is "/" - { - return *this; - } -#else if(_npos == sep_idx) { return *this; } -#endif return _invoke([sep_idx, this](const auto &v) { return path_view_component(v.data() + sep_idx + 1, v.size() - sep_idx - 1, termination()); }); } @@ -738,7 +717,6 @@ class LLFIO_DECL path_view_component } private: -#ifdef LLFIO_USING_STD_FILESYSTEM template static filesystem::path _path_from_char_array(basic_string_view v, filesystem::path::format f) { return {v.data(), v.data() + v.size(), f}; @@ -755,18 +733,6 @@ class LLFIO_DECL path_view_component return filesystem::u8path((const char *) v.data(), (const char *) v.data() + v.size()); #endif } -#endif -#ifdef LLFIO_USING_EXPERIMENTAL_FILESYSTEM - template static filesystem::path _path_from_char_array(basic_string_view v) { return {v.data(), v.data() + v.size()}; } - static filesystem::path _path_from_char_array(basic_string_view v) - { -#if(__cplusplus >= 202000 || _HAS_CXX20) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION > 10000 /* approx start of 2020 */) - return filesystem::path(v); -#else - return filesystem::u8path((const char *) v.data(), (const char *) v.data() + v.size()); -#endif - } -#endif template static int _do_compare(const CharT *a, const CharT *b, size_t length) noexcept { return memcmp(a, b, length * sizeof(CharT)); } static int _do_compare(const char8_t *_a, const char8_t *_b, size_t length) noexcept @@ -819,7 +785,6 @@ class LLFIO_DECL path_view_component return _invoke( [&](const auto &v) { -#ifdef LLFIO_USING_STD_FILESYSTEM return _path_from_char_array(v, [](format f) -> filesystem::path::format { @@ -833,14 +798,6 @@ class LLFIO_DECL path_view_component return filesystem::path::format::auto_format; } }(formatting())); -#endif -#ifdef LLFIO_USING_EXPERIMENTAL_FILESYSTEM - if(formatting() == generic_format || formatting() == native_format) - { - LLFIO_EXCEPTION_THROW(std::runtime_error("Path conversion with cannot handle generic_format or native_format formatting.")); - } - return _path_from_char_array(v); -#endif }); } @@ -2300,31 +2257,9 @@ class path_view : public path_view_component if(_npos == sep_idx) { // Sorry, this semantic is so broken that it's unwise to emulate! -#if 0 // LLFIO_USING_EXPERIMENTAL_FILESYSTEM && defined(_MSC_VER) - return this->_invoke([&](const auto &v) { - // MSVC's Experimental Filesystem has some really, really weird semantics :( - return *this; - }); -#else return path_view(); -#endif } - return this->_invoke( - [sep_idx, this](auto v) - { - return path_view(v.data(), -#if LLFIO_USING_EXPERIMENTAL_FILESYSTEM -#ifdef _MSC_VER - (sep_idx > 3 && (!is_uncpath() || v.data()[2] == '.' || v.data()[2] == '?')) ? sep_idx : (sep_idx + 1) -#else - (v.size() - 1 == sep_idx) ? sep_idx : (sep_idx + 1) -#endif -#else - (sep_idx + 1) -#endif - , - not_zero_terminated, formatting()); - }); + return this->_invoke([sep_idx, this](auto v) { return path_view(v.data(), (sep_idx + 1), not_zero_terminated, formatting()); }); } //! Returns a view of the root name part of this view e.g. C: LLFIO_PATH_VIEW_CONSTEXPR path_view root_name() const noexcept @@ -2472,7 +2407,6 @@ class path_view : public path_view_component return path_view(v.data(), sep_idx + 1, not_zero_terminated, formatting()); } } -#if !LLFIO_USING_EXPERIMENTAL_FILESYSTEM // If a C:\ or whatever, return exactly that. auto rp = root_path(); if(rp.native_size() == native_size()) @@ -2480,15 +2414,9 @@ class path_view : public path_view_component return *this; } return path_view(v.data(), (sep_idx == 0) ? 1 : sep_idx, not_zero_terminated, formatting()); -#else - return path_view(v.data(), (sep_idx == 0 && this->_length > 1) ? 1 : sep_idx, not_zero_terminated, formatting()); -#endif }); -#elif LLFIO_USING_EXPERIMENTAL_FILESYSTEM // Filesystem TS returns parent path "" for "/" - return this->_invoke([this, sep_idx](const auto &v) - { return path_view(v.data(), (sep_idx == 0 && this->_length > 1) ? 1 : sep_idx, not_zero_terminated, formatting()); }); #else - return this->_invoke([this, sep_idx](const auto &v) { return path_view(v.data(), (sep_idx == 0) ? 1 : sep_idx, not_zero_terminated, formatting()); }); + return this->_invoke([this, sep_idx](const auto &v) { return path_view(v.data(), (sep_idx == 0) ? 1 : sep_idx, not_zero_terminated, formatting()); }); #endif } //! Returns a view of the filename part of this view. diff --git a/test/tests/path_view.cpp b/test/tests/path_view.cpp index 69c6acf8..9898c260 100644 --- a/test/tests/path_view.cpp +++ b/test/tests/path_view.cpp @@ -56,7 +56,7 @@ static inline void CheckPathView(const LLFIO_V2_NAMESPACE::filesystem::path &pat CheckPathView(path, "filename()", [](const auto &p) { return p.filename(); }); CheckPathView(path, "stem()", [](const auto &p) { return p.stem(); }); CheckPathView(path, "extension()", [](const auto &p) { return p.extension(); }); -#if !(LLFIO_USING_EXPERIMENTAL_FILESYSTEM && defined(_MSC_VER)) +#if !(defined(_MSC_VER)) // remove_filename() is completely stupid on MSVC's Experimental Filesystem CheckPathView(path, "remove_filename()", [](auto p) { return p.remove_filename(); }); #endif @@ -118,11 +118,7 @@ static inline void TestPathView() llfio::path_view e(p); // NOLINT llfio::path_view f(e.filename()); e = e.remove_filename(); -#if LLFIO_USING_EXPERIMENTAL_FILESYSTEM && defined(_MSC_VER) - BOOST_CHECK(0 == e.compare<>("/mnt/c/Users/ned/Documents/boostish/afio/programs/build_posix/testdir")); -#else BOOST_CHECK(0 == e.compare<>("/mnt/c/Users/ned/Documents/boostish/afio/programs/build_posix/testdir/")); -#endif BOOST_CHECK(0 == f.compare<>("0")); // Trailing BOOST_CHECK(0 == llfio::path_view("/a/b/").without_trailing_separator().compare<>("/a/b")); @@ -173,11 +169,7 @@ static inline void TestPathView() llfio::path_view g(p2); llfio::path_view h(g.filename()); g = g.remove_filename(); -#if LLFIO_USING_EXPERIMENTAL_FILESYSTEM && defined(_MSC_VER) - BOOST_CHECK(0 == g.compare<>("\\mnt\\c\\Users\\ned\\Documents\\boostish\\afio\\programs\\build_posix\\testdir")); -#else BOOST_CHECK(0 == g.compare<>("\\mnt\\c\\Users\\ned\\Documents\\boostish\\afio\\programs\\build_posix\\testdir\\")); -#endif BOOST_CHECK(0 == h.compare<>("0")); // cstr llfio::path_view::zero_terminated_rendered_path<> i(g); @@ -195,9 +187,7 @@ static inline void TestPathView() CheckPathView("C:/Users/ned/Documents/boostish/afio/programs/build_posix/testdir/0.txt"); CheckPathView(L"\\\\niall\\douglas.txt"); // CheckPathView(L"\\!!\\niall\\douglas.txt"); -#ifndef _EXPERIMENTAL_FILESYSTEM_ CheckPathView(L"\\??\\niall\\douglas.txt"); -#endif CheckPathView(L"\\\\?\\niall\\douglas.txt"); CheckPathView(L"\\\\.\\niall\\douglas.txt");