[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / utilities / function.objects / func.memfn / member_data.pass.cpp
blobd6cd06cd8cd0966d0eb5eb548feabb7ed17e316c
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> unspecified mem_fn(R T::* pm);
13 #include <functional>
14 #include <cassert>
16 #include "test_macros.h"
18 struct A
20 double data_;
23 template <class F>
24 TEST_CONSTEXPR_CXX20 bool
25 test(F f)
28 A a = {0.0};
29 f(a) = 5;
30 assert(a.data_ == 5);
31 A* ap = &a;
32 f(ap) = 6;
33 assert(a.data_ == 6);
34 const A* cap = ap;
35 assert(f(cap) == f(ap));
36 const F& cf = f;
37 assert(cf(ap) == f(ap));
39 return true;
42 int main(int, char**)
44 test(std::mem_fn(&A::data_));
46 #if TEST_STD_VER >= 20
47 static_assert(test(std::mem_fn(&A::data_)));
48 #endif
50 return 0;