I have a problem with preservation of noexcept
specifier in std::bind
, using C++17.
In GCC and Clang is not preserved, but in MSVC it is. It seems that using bind
with a function with noexcept
specifier, the resulting object doesn't preserve it, considering always that it isn't noexcept
.
Having a function like:
void f(int) noexcept;
And now creating a callable with std::bind
on it:
auto g = std::bind(f,5);
It can be seen that noexcept
behaviour is different between f
and g
when executing in GCC and Clang (using C++17 mode)
std::cout << noexcept(f(5)); //prints 1, ok, as expected
std::cout << noexcept(g()); //prints 0, WRONG!!
As mentioned at the beginning, MSVC is the only with (in my opinion) consistent behaviour. Reading the standard specification doesn't mention anything about that, so maybe this behaviour is not specified So, is this a normal behaviour because the lack of specification in the standard or is a bug?
Is any way to force the "noexcept
" specifier when using bind
?