[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / utilities / function.objects / func.memfn / member_function_volatile.pass.cpp
blob7f27c2f1d99edc04aec73cd1827c010c1c9e9f04
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <functional>
11 // template<Returnable R, class T, CopyConstructible... Args>
12 // unspecified mem_fn(R (T::* pm)(Args...) volatile);
14 #include <functional>
15 #include <cassert>
17 #include "test_macros.h"
19 struct A
21 char test0() volatile {return 'a';}
22 char test1(int) volatile {return 'b';}
23 char test2(int, double) volatile {return 'c';}
26 template <class F>
27 void
28 test0(F f)
31 A a;
32 assert(f(a) == 'a');
33 A* ap = &a;
34 assert(f(ap) == 'a');
35 volatile A* cap = &a;
36 assert(f(cap) == 'a');
37 const F& cf = f;
38 assert(cf(ap) == 'a');
42 template <class F>
43 void
44 test1(F f)
47 A a;
48 assert(f(a, 1) == 'b');
49 A* ap = &a;
50 assert(f(ap, 2) == 'b');
51 volatile A* cap = &a;
52 assert(f(cap, 2) == 'b');
53 const F& cf = f;
54 assert(cf(ap, 2) == 'b');
58 template <class F>
59 void
60 test2(F f)
63 A a;
64 assert(f(a, 1, 2) == 'c');
65 A* ap = &a;
66 assert(f(ap, 2, 3.5) == 'c');
67 volatile A* cap = &a;
68 assert(f(cap, 2, 3.5) == 'c');
69 const F& cf = f;
70 assert(cf(ap, 2, 3.5) == 'c');
74 int main(int, char**)
76 test0(std::mem_fn(&A::test0));
77 test1(std::mem_fn(&A::test1));
78 test2(std::mem_fn(&A::test2));
80 return 0;