greg7mdp / parallel-hashmap

A family of header-only, very fast and memory-friendly hashmap and btree containers.
https://greg7mdp.github.io/parallel-hashmap/
Apache License 2.0
2.53k stars 239 forks source link

Unused variable warning #208

Closed bpmckinnon closed 1 year ago

bpmckinnon commented 1 year ago

Hi, I've started getting the unused variable warning again when exceptions are disabled. PR 197 reverted an earlier change to suppress the warning, but I agree that constructing the object is not the greatest.

I've tested out a change that will remove the warning, but also remove the need to have those types defined.

Let me know what you think.

#ifdef PHMAP_HAVE_EXCEPTIONS
  #define PHMAP_THROW_IMPL_MSG(e, message) throw e(message)
  #define PHMAP_THROW_IMPL(e) throw e
#else
  #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_MSG(std::logic_error, what_arg);
}
static inline void ThrowStdBadFunctionCall() {
  PHMAP_THROW_IMPL(std::bad_function_call());
}
greg7mdp commented 1 year ago

Sounds good, thanks for the great suggestion @bpmckinnon . I'll do #define PHMAP_THROW_IMPL(e) throw e() though to delay the construction.

bpmckinnon commented 1 year ago

Thanks!