This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: "is_member_function_pointer" method with function arguments
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Stefan <stefan at schweter dot it>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 10 Dec 2013 23:44:04 +0000
- Subject: Re: "is_member_function_pointer" method with function arguments
- Authentication-results: sourceware.org; auth=none
- References: <20131210122828 dot B50816E4356C at dd32626 dot kasserver dot com>
On 10 December 2013 12:28, Stefan wrote:
>
> 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()");
I don't really understand what you're trying to do here.
(T::resize)(std::string::size_type) is not a valid type.
I think your problem is not that resize() has arguments, it is that it
is an overloaded function, so &T::resize is ambiguous..
Maybe you are trying to say this:
static_assert( std::is_member_function_pointer<static_cast<void
(T::*)(typename T::size_type)>(&T::resize)>::value, "Member function
void T::resize(T::size_type) exists" );
However, this doesn't seem very useful, because if a member with that
signature does not exist then you will not get a static assertion
failure, you will get an error because the static_cast expression is
ill-formed.