This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
"is_member_function_pointer" method with function arguments
- From: "Stefan" <stefan at schweter dot it>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 10 Dec 2013 13:28:28 +0100 (CET)
- Subject: "is_member_function_pointer" method with function arguments
- Authentication-results: sourceware.org; auth=none
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