From b86f941c676968b9901598538789cd6ed8fcac7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Sch=C3=BCmann?= Date: Sat, 29 Sep 2018 13:51:12 +0200 Subject: [PATCH] Fixed some warnings and a CMakeLists issue on Windows. --- examples/CMakeLists.txt | 4 ++++ filesystem.h | 40 +++++++++++++++++++++------------------- test/CMakeLists.txt | 1 + 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e82671c..a49142c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(fs_dir dir.cpp ../filesystem.h) +target_compile_definitions(fs_dir PRIVATE _CRT_SECURE_NO_WARNINGS) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)) add_executable(std_fs_dir dir.cpp) @@ -14,4 +15,7 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 19.15 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.15)) add_executable(std_fs_dir dir.cpp) set_property(TARGET std_fs_dir PROPERTY CXX_STANDARD 17) + set_property(TARGET std_fs_dir PROPERTY CXX_STANDARD_REQUIRED ON) + target_compile_options(std_fs_dir PRIVATE "/Zc:__cplusplus") + target_compile_definitions(std_fs_dir PRIVATE _CRT_SECURE_NO_WARNINGS) endif() diff --git a/filesystem.h b/filesystem.h index 12f6991..fc6e814 100644 --- a/filesystem.h +++ b/filesystem.h @@ -345,9 +345,15 @@ private: path _p1, _p2; }; -class path::iterator : public std::iterator +class path::iterator { public: + using value_type = const path; + using difference_type = std::ptrdiff_t; + using pointer = const path*; + using reference = const path&; + using iterator_category = std::bidirectional_iterator_tag; + iterator(); iterator(const string_type::const_iterator& first, const string_type::const_iterator& last, const string_type::const_iterator& pos); iterator& operator++(); @@ -356,8 +362,8 @@ public: iterator operator--(int); bool operator==(const iterator& other) const; bool operator!=(const iterator& other) const; - const path& operator*() const; - const path* operator->() const; + const reference operator*() const; + const pointer operator->() const; private: string_type::const_iterator increment(const std::string::const_iterator& pos) const; @@ -900,8 +906,9 @@ typedef basic_ofstream ofstream; typedef basic_ofstream wofstream; typedef basic_fstream fstream; typedef basic_fstream wfstream; - -class u8arguments { + +class u8arguments +{ public: u8arguments(int& argc, char**& argv); ~u8arguments() @@ -909,6 +916,7 @@ public: _refargc = _argc; _refargv = _argv; } + private: int _argc; char** _argv; @@ -920,7 +928,6 @@ private: #endif }; - //------------------------------------------------------------------------------------------------- // Implementation //------------------------------------------------------------------------------------------------- @@ -1073,13 +1080,8 @@ inline void appendUTF8(std::string& str, uint32_t unicode) // Generating debugging and shrinking my own DFA from scratch was a day of fun! enum utf8_states_t { S_STRT = 0, S_RJCT = 8 }; static const uint32_t utf8_state_info[] = { - 0x11111111u, 0x11111111u, 0x77777777u, 0x77777777u, - 0x88888888u, 0x88888888u, 0x88888888u, 0x88888888u, - 0x22222299u, 0x22222222u, 0x22222222u, 0x22222222u, - 0x3333333au, 0x33433333u, 0x9995666bu, 0x99999999u, - 0x88888880u, 0x22818108u, 0x88888881u, 0x88888882u, - 0x88888884u, 0x88888887u, 0x88888886u, 0x82218108u, - 0x82281108u, 0x88888888u, 0x88888883u, 0x88888885u, + 0x11111111u, 0x11111111u, 0x77777777u, 0x77777777u, 0x88888888u, 0x88888888u, 0x88888888u, 0x88888888u, 0x22222299u, 0x22222222u, 0x22222222u, 0x22222222u, 0x3333333au, 0x33433333u, + 0x9995666bu, 0x99999999u, 0x88888880u, 0x22818108u, 0x88888881u, 0x88888882u, 0x88888884u, 0x88888887u, 0x88888886u, 0x82218108u, 0x82281108u, 0x88888888u, 0x88888883u, 0x88888885u, }; static inline unsigned consumeUtf8Fragment(const unsigned state, const uint8_t fragment, uint32_t& codepoint) { @@ -1202,10 +1204,10 @@ inline void postprocess_path_with_format(path::string_type& p, path::format fmt) } // namespace detail inline u8arguments::u8arguments(int& argc, char**& argv) -: _argc(argc) -, _argv(argv) -, _refargc(argc) -, _refargv(argv) + : _argc(argc) + , _argv(argv) + , _refargc(argc) + , _refargv(argv) { #ifdef GHC_OS_WINDOWS LPWSTR* p; @@ -2418,12 +2420,12 @@ inline bool path::iterator::operator!=(const path::iterator& other) const return _iter != other._iter; } -inline const path& path::iterator::operator*() const +inline const path::iterator::reference path::iterator::operator*() const { return _current; } -inline const path* path::iterator::operator->() const +inline const path::iterator::pointer path::iterator::operator->() const { return &_current; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9352c39..ae1b4a0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,5 +23,6 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 19.15 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.15)) add_executable(std_filesystem_test filesystem_test.cpp ../filesystem.h catch.hpp) set_property(TARGET std_filesystem_test PROPERTY CXX_STANDARD 17) + target_compile_options(std_filesystem_test PRIVATE "/Zc:__cplusplus") target_compile_definitions(std_filesystem_test PRIVATE USE_STD_FS) endif()