"is_member_function_pointer" method with function arguments
Stefan
stefan@schweter.it
Tue Dec 10 12:28:00 GMT 2013
Hi,
I played around with the "is_member_function_pointer" method I´ve got a question - the following code is working:
#include <type_traits>
#include <iostream>
#include <utility>
#include <string>
template<class T>
struct has_data {
static_assert(std::is_member_function_pointer< decltype(&T::data) >::value, "T has no member method data()");
static const constexpr bool value = true;
};
int main() {
std::cout << std::boolalpha << has_data< std::string >::value << std::endl;
return 0;
}
But: The code is not "working" (won´t compile) if the function has one or more arguments like the resize() function (for basic_strings):
static_assert(std::is_member_function_pointer<(T::resize)(std::basic_string<char, std::char_traits<char>,
std::allocator<char>>::size_type)>::value, "T has no member method append()");
Can anybody explain me, how this "is_member_function_pointer" methods works with one or more function arguments?
Thanks in advance,
Stefan
More information about the Libstdc++
mailing list