I'm currently reimplementing std::invoke
in C++11 (i.e. understanding and adapting libc++/libstdc++ code), and I stumbled upon an issue related to noexcept
.
This can be demonstrated with the following snippet:
#include <functional>
void nothrow_method(int, int) noexcept
{
}
int main(int argc, char const *argv[])
{
static_assert(noexcept(std::__invoke(nothrow_method, 2, 3)), "");
static_assert(std::__is_nothrow_invocable<decltype(nothrow_method), int, int>::value, "");
}
I'm on Debian Jessie, my library is libstdc++.
Compiling with -std=c++14
fails with clang 4.0.1, both static_assert
trigger.
There is no problem with GCC 7.1.0 however.
I looked at how libc++ implemented std::invoke
, and I copied their way of detecting noexcept
in my own implementation, but it still failed to compile.
Since there is only one error line because of the static_assert
, I really have no idea what is going on, could it be related to what's explained in this blog post?
I've had some issues with noexcept
and template instantiation points in the past, but I'm quite sure it's not related here.
EDIT:
I've downloaded libcxx trunk, built with apple-clang 8.1.0 on macOS 10.12.6, the static_assert
still trigger, despite their code having noexcept(noexcept())
on __invoke
.
EDIT2:
std::__*
are used for tests, I know they are private, but I didn't want to post my invoke
implementation.