Skip to content

Commit

Permalink
Move to C++17 dropping C++11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tessil committed Sep 14, 2024
1 parent b28a4c2 commit 7f32a77
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ target_link_libraries(your_target PRIVATE tsl::hopscotch_map)

If the project has been installed through `make install`, you can also use `find_package(tsl-hopscotch-map REQUIRED)` instead of `add_subdirectory`.

The code should work with any C++11 standard-compliant compiler and has been tested with GCC 4.8.4, Clang 3.5.0 and Visual Studio 2015.
The code should work with any C++17 standard-compliant compiler.

To run the tests you will need the Boost Test library and CMake.

Expand Down
22 changes: 0 additions & 22 deletions include/tsl/hopscotch_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@

#include "hopscotch_growth_policy.h"

#if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
#define TSL_HH_NO_RANGE_ERASE_WITH_CONST_ITERATOR
#endif

namespace tsl {
namespace detail_hopscotch_hash {
Expand Down Expand Up @@ -309,22 +306,14 @@ class hopscotch_bucket : public hopscotch_bucket_hash<StoreHash> {

value_type& value() noexcept {
tsl_hh_assert(!empty());
#if defined(__cplusplus) && __cplusplus >= 201703L
return *std::launder(
reinterpret_cast<value_type*>(std::addressof(m_value)));
#else
return *reinterpret_cast<value_type*>(std::addressof(m_value));
#endif
}

const value_type& value() const noexcept {
tsl_hh_assert(!empty());
#if defined(__cplusplus) && __cplusplus >= 201703L
return *std::launder(
reinterpret_cast<const value_type*>(std::addressof(m_value)));
#else
return *reinterpret_cast<const value_type*>(std::addressof(m_value));
#endif
}

template <typename... Args>
Expand Down Expand Up @@ -1380,25 +1369,14 @@ class hopscotch_hash : private Hash, private KeyEqual, private GrowthPolicy {
new_map.swap(*this);
}

#ifdef TSL_HH_NO_RANGE_ERASE_WITH_CONST_ITERATOR
iterator_overflow mutable_overflow_iterator(const_iterator_overflow it) {
return std::next(m_overflow_elements.begin(),
std::distance(m_overflow_elements.cbegin(), it));
}
#else
iterator_overflow mutable_overflow_iterator(const_iterator_overflow it) {
return m_overflow_elements.erase(it, it);
}
#endif

// iterator is in overflow list
iterator_overflow erase_from_overflow(const_iterator_overflow pos,
std::size_t ibucket_for_hash) {
#ifdef TSL_HH_NO_RANGE_ERASE_WITH_CONST_ITERATOR
auto it_next = m_overflow_elements.erase(mutable_overflow_iterator(pos));
#else
auto it_next = m_overflow_elements.erase(pos);
#endif
m_nb_elements--;

// Check if we can remove the overflow flag
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_executable(tsl_hopscotch_map_tests "main.cpp"
"hopscotch_set_tests.cpp"
"policy_tests.cpp")

target_compile_features(tsl_hopscotch_map_tests PRIVATE cxx_std_11)
target_compile_features(tsl_hopscotch_map_tests PRIVATE cxx_std_17)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(tsl_hopscotch_map_tests PRIVATE -Werror -Wall -Wextra -Wold-style-cast -DTSL_DEBUG -UNDEBUG)
Expand All @@ -18,7 +18,7 @@ endif()

# Boost::unit_test_framework
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.54.0 REQUIRED COMPONENTS unit_test_framework)
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
target_link_libraries(tsl_hopscotch_map_tests PRIVATE Boost::unit_test_framework)

# tsl::hopscotch_map
Expand Down

0 comments on commit 7f32a77

Please sign in to comment.