Skip to content

Commit

Permalink
Unused variable warning (issue #208) and remove c++17 dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Sep 29, 2023
1 parent 81ca453 commit a7909d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
8 changes: 4 additions & 4 deletions parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1271,8 +1271,8 @@ class raw_hash_set
if (empty())
return;
if (capacity_) {
if constexpr (!std::is_trivially_destructible<typename PolicyTraits::value_type>::value ||
std::is_same<typename Policy::is_flat, std::false_type>::value) {
PHMAP_IF_CONSTEXPR((!std::is_trivially_destructible<typename PolicyTraits::value_type>::value ||
std::is_same<typename Policy::is_flat, std::false_type>::value)) {
// node map or not trivially destructible... we need to iterate and destroy values one by one
for (size_t i = 0; i != capacity_; ++i) {
if (IsFull(ctrl_[i])) {
Expand Down Expand Up @@ -2009,8 +2009,8 @@ class raw_hash_set
if (!capacity_)
return;

if constexpr (!std::is_trivially_destructible<typename PolicyTraits::value_type>::value ||
std::is_same<typename Policy::is_flat, std::false_type>::value) {
PHMAP_IF_CONSTEXPR((!std::is_trivially_destructible<typename PolicyTraits::value_type>::value ||
std::is_same<typename Policy::is_flat, std::false_type>::value)) {
// node map, or not trivially destructible... we need to iterate and destroy values one by one
// std::cout << "either this is a node map or " << type_name<typename PolicyTraits::value_type>() << " is not trivially_destructible\n";
for (size_t i = 0; i != capacity_; ++i) {
Expand Down
46 changes: 24 additions & 22 deletions parallel_hashmap/phmap_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,82 +654,84 @@ namespace base_internal {
namespace {

#ifdef PHMAP_HAVE_EXCEPTIONS
#define PHMAP_THROW_IMPL(e) throw e
#define PHMAP_THROW_IMPL_MSG(e, message) throw e(message)
#define PHMAP_THROW_IMPL(e) throw e()
#else
#define PHMAP_THROW_IMPL(...) std::abort()
#define PHMAP_THROW_IMPL_MSG(e, message) do { (void)(message); std::abort(); } while(0)
#define PHMAP_THROW_IMPL(e) std::abort()
#endif
} // namespace

static inline void ThrowStdLogicError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::logic_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::logic_error, what_arg);
}
static inline void ThrowStdLogicError(const char* what_arg) {
PHMAP_THROW_IMPL(std::logic_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::logic_error, what_arg);
}
static inline void ThrowStdInvalidArgument(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::invalid_argument(what_arg));
PHMAP_THROW_IMPL_MSG(std::invalid_argument, what_arg);
}
static inline void ThrowStdInvalidArgument(const char* what_arg) {
PHMAP_THROW_IMPL(std::invalid_argument(what_arg));
PHMAP_THROW_IMPL_MSG(std::invalid_argument, what_arg);
}

static inline void ThrowStdDomainError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::domain_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::domain_error, what_arg);
}
static inline void ThrowStdDomainError(const char* what_arg) {
PHMAP_THROW_IMPL(std::domain_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::domain_error, what_arg);
}

static inline void ThrowStdLengthError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::length_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::length_error, what_arg);
}
static inline void ThrowStdLengthError(const char* what_arg) {
PHMAP_THROW_IMPL(std::length_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::length_error, what_arg);
}

static inline void ThrowStdOutOfRange(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::out_of_range(what_arg));
PHMAP_THROW_IMPL_MSG(std::out_of_range, what_arg);
}
static inline void ThrowStdOutOfRange(const char* what_arg) {
PHMAP_THROW_IMPL(std::out_of_range(what_arg));
PHMAP_THROW_IMPL_MSG(std::out_of_range, what_arg);
}

static inline void ThrowStdRuntimeError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::runtime_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::runtime_error, what_arg);
}
static inline void ThrowStdRuntimeError(const char* what_arg) {
PHMAP_THROW_IMPL(std::runtime_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::runtime_error, what_arg);
}

static inline void ThrowStdRangeError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::range_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::range_error, what_arg);
}
static inline void ThrowStdRangeError(const char* what_arg) {
PHMAP_THROW_IMPL(std::range_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::range_error, what_arg);
}

static inline void ThrowStdOverflowError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::overflow_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::overflow_error, what_arg);
}

static inline void ThrowStdOverflowError(const char* what_arg) {
PHMAP_THROW_IMPL(std::overflow_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::overflow_error, what_arg);
}

static inline void ThrowStdUnderflowError(const std::string& what_arg) {
PHMAP_THROW_IMPL(std::underflow_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::underflow_error, what_arg);
}

static inline void ThrowStdUnderflowError(const char* what_arg) {
PHMAP_THROW_IMPL(std::underflow_error(what_arg));
PHMAP_THROW_IMPL_MSG(std::underflow_error, what_arg);
}

static inline void ThrowStdBadFunctionCall() {
PHMAP_THROW_IMPL(std::bad_function_call());
PHMAP_THROW_IMPL(std::bad_function_call);
}

static inline void ThrowStdBadAlloc() {
PHMAP_THROW_IMPL(std::bad_alloc());
PHMAP_THROW_IMPL(std::bad_alloc);
}

} // namespace base_internal
Expand Down

0 comments on commit a7909d5

Please sign in to comment.