diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e271f9..624bfa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,11 +92,12 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") endif() +include_directories(${PROJECT_SOURCE_DIR}) + if (PHMAP_BUILD_TESTS) if (NOT PHMAP_GTEST_LIBS) include(cmake/DownloadGTest.cmake) - include_directories(${PROJECT_SOURCE_DIR}) check_target(gtest) check_target(gtest_main) @@ -166,7 +167,10 @@ endif() if (PHMAP_BUILD_EXAMPLES) if(NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wno-unused -Wno-unknown-warning-option -Wno-gnu-zero-variadic-macro-arguments") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wno-unused") + if (NOT CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wno-gnu-zero-variadic-macro-arguments") + endif() else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /Zc:__cplusplus") endif() diff --git a/examples/hash.cc b/examples/hash.cc index c33afec..8e981b4 100644 --- a/examples/hash.cc +++ b/examples/hash.cc @@ -4,7 +4,9 @@ #include #include #include -#include +#if PHMAP_HAVE_STD_STRING_VIEW + #include +#endif #include using std::string; @@ -17,7 +19,7 @@ namespace std { template<> struct hash { -#if 0 +#if PHMAP_HAVE_STD_STRING_VIEW std::size_t operator()(groupid_t const &g) const { const std::string_view bv{reinterpret_cast(g.data()), sizeof(g)}; diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 8550d59..5a766e4 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -2271,14 +2271,14 @@ private: } // Reset all ctrl bytes back to kEmpty, except the sentinel. - void reset_ctrl(size_t capacity) { - std::memset(ctrl_, kEmpty, capacity + Group::kWidth); - ctrl_[capacity] = kSentinel; - SanitizerPoisonMemoryRegion(slots_, sizeof(slot_type) * capacity); + void reset_ctrl(size_t new_capacity) { + std::memset(ctrl_, kEmpty, new_capacity + Group::kWidth); + ctrl_[new_capacity] = kSentinel; + SanitizerPoisonMemoryRegion(slots_, sizeof(slot_type) * new_capacity); } - void reset_growth_left(size_t capacity) { - growth_left() = CapacityToGrowth(capacity) - size_; + void reset_growth_left(size_t new_capacity) { + growth_left() = CapacityToGrowth(new_capacity) - size_; } size_t& growth_left() { return std::get<0>(settings_); }