samedi 4 mai 2019

C++11 - How to fix noexcept operator that fails to detect function declaration with noexcept specifier

I'm setting up a new library for personal research purpose, and i'm trying to fully understand c++ standard library tools and core functionalities. Now i have a problem understanding the noexcept operator.

I wrote some test examples involving the noexcept operator and i'm puzzled with the result of the following assertion:

...
void no_throw() noexcept;

static_assert(noexcept(no_throw), "This should be true");
static_assert(noexcept((std::declval<decltype(no_throw)>())())), "this also should be true");
...

I expected this code to compile, but the second assertion pass only if using c++17 compile flag; i did run the test with gcc8.1 and clang5.0 . I've not tested with other compilers.

It fails with c++11 or c++14 flag. Could someone explain me why?

Thank you

Aucun commentaire:

Enregistrer un commentaire