This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

"is_member_function_pointer" method with function arguments


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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]