Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary creation of std *_error objects #197

Merged
merged 1 commit into from
Jun 11, 2023
Merged

remove unnecessary creation of std *_error objects #197

merged 1 commit into from
Jun 11, 2023

Conversation

ilobilo
Copy link
Contributor

@ilobilo ilobilo commented Jun 11, 2023

remove creation and then casting to (void) of std::*_error objects if exceptions are disabled
this also removes the need for those classes to be available to use this library

remove creation and then casting to (void) of std::*_error objects if exceptions are disabled
Copy link
Owner

@greg7mdp greg7mdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thank you for the change @ilobilo !

@greg7mdp greg7mdp merged commit 79cbd2d into greg7mdp:master Jun 11, 2023
@bpmckinnon
Copy link
Contributor

bpmckinnon commented Sep 28, 2023

Hi, just noticed this one when updating. I've started getting the unused variable warning again.

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());
}

@ilobilo
Copy link
Contributor Author

ilobilo commented Sep 29, 2023

Oh I didn't notice that what_arg wasn't being used anymore with std::abort(), my bad.
But yes, your solution should fix the warning and it's cleaner than using [[maybe_unused]] everywhere.

@greg7mdp
Copy link
Owner

@bpmckinnon 's solution was checked-in earlier this morning, so we should be all set. Thanks to both of you for your contribs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants