Get tests compiling with -Wunused-local-typedef

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346914 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-11-15 00:11:02 +00:00
parent c6da5c57fe
commit c2c6c1de6b
51 changed files with 22 additions and 94 deletions

View File

@@ -24,15 +24,25 @@ int identity(int v) { return v; }
int sum(int a, int b) { return a + b; }
struct Foo {
int zero() const { return 0; }
int identity(int v) const { return v; }
int sum(int a, int b) const { return a + b; }
int zero() { return 0; }
int zero_const() const { return 1; }
int identity(int v) const { return v; }
int sum(int a, int b) const { return a + b; }
};
int main()
{
typedef std::pointer_to_unary_function<int, int> PUF;
typedef std::pointer_to_binary_function<int, int, int> PBF;
static_assert(
(std::is_same<PUF, decltype(std::ptr_fun<int, int>(identity))>::value),
"");
static_assert(
(std::is_same<PBF, decltype(std::ptr_fun<int, int, int>(sum))>::value),
"");
assert((std::ptr_fun<int, int>(identity)(4) == 4));
assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
@@ -43,6 +53,12 @@ int main()
typedef std::mem_fun_ref_t<int, Foo> MFR;
typedef std::const_mem_fun_ref_t<int, Foo> CMFR;
static_assert(
(std::is_same<MFR, decltype(std::mem_fun_ref(&Foo::zero))>::value), "");
static_assert((std::is_same<CMFR, decltype(std::mem_fun_ref(
&Foo::zero_const))>::value),
"");
assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
}