Commit f6b640be by Jonathan Wakely Committed by Jonathan Wakely

Make std::mem_fn work with varargs functions.

	* include/std/functional (_Mem_fn_traits): Add partial specializations
	for varargs functions.
	(_Mem_fn_base): Do not check arguments are convertible for varargs.
	(_Bind_check_arity): Add partial specializations for varargs functions.
	* include/std/type_traits (__bool_constant): Add alias template.
	* testsuite/20_util/bind/ref_neg.cc: Adjust dg-error.
	* testsuite/20_util/bind/refqual.cc: New, test ref-qualifiers.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
	* testsuite/20_util/function_objects/mem_fn/refqual.cc: Test varargs.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
	dg-error.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust
	dg-error.

From-SVN: r217393
parent 3d00119c
2014-11-11 Jonathan Wakely <jwakely@redhat.com>
* include/std/functional (_Mem_fn_traits): Add partial specializations
for varargs functions.
(_Mem_fn_base): Do not check arguments are convertible for varargs.
(_Bind_check_arity): Add partial specializations for varargs functions.
* include/std/type_traits (__bool_constant): Add alias template.
* testsuite/20_util/bind/ref_neg.cc: Adjust dg-error.
* testsuite/20_util/bind/refqual.cc: New, test ref-qualifiers.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
* testsuite/20_util/function_objects/mem_fn/refqual.cc: Test varargs.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
dg-error.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust
dg-error.
2014-11-11 Siva Chandra Reddy <sivachandra@google.com>
* testsuite/libstdc++-xmethods/associative-containers.cc: Add new
......
......@@ -89,6 +89,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// The type used as a compile-time boolean with false value.
typedef integral_constant<bool, false> false_type;
template<bool __v>
using __bool_constant = integral_constant<bool, __v>;
// Meta programming helper types.
template<bool, typename, typename>
......
......@@ -30,10 +30,10 @@ void test01()
{
const int dummy = 0;
std::bind(&inc, _1)(0); // { dg-error "no match" }
// { dg-error "rvalue|const" "" { target *-*-* } 1207 }
// { dg-error "rvalue|const" "" { target *-*-* } 1221 }
// { dg-error "rvalue|const" "" { target *-*-* } 1235 }
// { dg-error "rvalue|const" "" { target *-*-* } 1249 }
// { dg-error "rvalue|const" "" { target *-*-* } 1126 }
// { dg-error "rvalue|const" "" { target *-*-* } 1140 }
// { dg-error "rvalue|const" "" { target *-*-* } 1154 }
// { dg-error "rvalue|const" "" { target *-*-* } 1168 }
std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" }
}
......
// Copyright (C) 2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++11" }
#include <functional>
#include <testsuite_hooks.h>
struct X
{
int f() const& { return 0; }
int g(int i, ...)& { return i; }
};
void
test01()
{
X x;
auto b = std::bind(&X::f, &x);
VERIFY( b() == 0 );
auto bb = std::bind(&X::g, &x, 1, 2);
VERIFY( bb() == 1 );
}
int
main()
{
test01();
}
......@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 2201 }
// { dg-error "static assertion failed" "" { target *-*-* } 2204 }
#include <utility>
......
......@@ -24,6 +24,7 @@ struct Foo
{
void r()&& { }
int l() const& { return 0; }
void lv(int, ...)& { }
};
void test01()
......@@ -31,4 +32,5 @@ void test01()
Foo f;
int i = std::mem_fn(&Foo::l)( f );
std::mem_fn(&Foo::r)( std::move(f) );
std::mem_fn(&Foo::lv)( f, 1, 2, 3 );
}
......@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1866 }
// { dg-error "declaration of" "" { target *-*-* } 1830 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1869 }
// { dg-error "declaration of" "" { target *-*-* } 1833 }
......@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1754 }
// { dg-error "declaration of" "" { target *-*-* } 1718 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1757 }
// { dg-error "declaration of" "" { target *-*-* } 1721 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment