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]

Re: "is_member_function_pointer" method with function arguments


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.


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