I am having trouble with std::is_member_function_pointer
. As far as I can tell, it's not working when given a noexcept
member function. I cannot find anything in the standard declaring that it does not work for noexcept
qualified member functions. Example of the problem:
#include <type_traits>
class A {
public:
void member() noexcept { }
};
int main()
{
// fails at compile time if A::member is a data member and not a function
static_assert(std::is_member_function_pointer<decltype(&A::member)>::value,
"A::member is not a member function.");
}
It gives me the following error:
member.cpp:11:5: error: static_assert failed due to requirement 'std::is_member_function_pointer::value' "A::member is not a member function." static_assert(std::is_member_function_pointer::value, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.
If I remove the noexcept
qualification it compiles as it should.
This has been tested on Debian Stretch, using clang 6.0 and libstdc++ 6.3.0 Am I missing something here? From what I can read, this should work.
Your code compiles on GodBolt - with and without noexcept
on the member - with all of MSVC 2017, GCC 5.5, 6.x, 8.x , clang 5, 6, 7.
On my Debian Stretch (well, the corresponding Devuan really) - I can reproduce the issue. Interestingly, compilation fails even if I switch to libc++.
So:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With