dimanche 7 août 2022

noexcept, third party and STL calls

I'm trying to understand when I should use noexcept and when I should not.

In my library, I have many methods. Some are using methods from third party, some are using the STL. Some use throw, some don't.

I can put noexcept statements on all my methods, the compiler just do not complain at all. But I do.

I can check my own throws to know if I should put a noexcept on a method, but am I supposed to check every signature of the STL methods and third party methods to know if I should put a noexcept ?

I could do that but that seems inefficient, am I missing something here ?

example code where I should NOT use noexcept if my understanding is correct:

foo::foo() noexcept
{
  this->BarPtr = std::make_unique<Bar>();
}

Aucun commentaire:

Enregistrer un commentaire