diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 90a303f..17bb3d6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,3 +10,8 @@ add_executable(fs_du du.cpp) target_link_libraries(fs_du ghc_filesystem) AddExecutableWithStdFS(std_fs_du du.cpp) +if(EXISTS "${PROJECT_SOURCE_DIR}/examples/benchmark.cpp") + add_executable(fs_benchmark benchmark.cpp) + set_property(TARGET fs_benchmark PROPERTY CXX_STANDARD 17) + target_link_libraries(fs_benchmark ghc_filesystem) +endif() \ No newline at end of file diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index aec56a1..f2af8e1 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -2850,7 +2850,7 @@ GHC_INLINE path path::parent_path() const { auto rootPathLen = _prefixLength + root_name_length() + (has_root_directory() ? 1 : 0); if (rootPathLen < _path.length()) { - if (empty() || begin() == --end()) { + if (empty()) { return path(); } else { @@ -3068,7 +3068,9 @@ GHC_INLINE path::iterator::iterator(const path& p, const impl_string_type::const , _root(p.has_root_directory() ? _first + static_cast(p._prefixLength + p.root_name_length()) : _last) , _iter(pos) { - updateCurrent(); + if(pos != _last) { + updateCurrent(); + } } GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(const path::impl_string_type::const_iterator& pos) const