Bruice
Bruice

Reputation: 663

Should I write noexcept only to constructors and move operators?

There is a quite (very) popular question about the usage of noexcept, but it's from 8 years ago, and other popular answers are just as old. Seeing some code from other people in different projects, it seems to me that noexcept didn't become a very common thing for many developers to write.

Besides move constructor and move assignment operator, the benefit of using noexcept doesn't seems clear enough to think about for every function ("should I add noexcept here or not?").

Has somebody found a good usage of this specifier, and can share their experience?

Upvotes: 6

Views: 477

Answers (1)

Woodford
Woodford

Reputation: 4449

Besides the answers in the question that you linked (which continue to be relevant today), there are quite a few specific cases called out in the C++ Core Guidelines that you might want to check out:

It's not a topic to easily summarize as noted by the continued lack of content (as of 03-2021) in the Discussion: Usage of noexcept section.

Upvotes: 5

Related Questions