brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d54d518 Raw
54 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <functional>10 11// reference_wrapper12 13// template <class... ArgTypes>14//   requires Callable<T, ArgTypes&&...>15//   Callable<T, ArgTypes&&...>::result_type16//   operator()(ArgTypes&&... args) const;17 18#include <functional>19#include <cassert>20 21// member data pointer:  cv qualifiers should transfer from argument to return type22 23struct A_int_124{25    A_int_1() : data_(5) {}26 27    int data_;28};29 30void31test_int_1()32{33    // member data pointer34    {35    int A_int_1::*fp = &A_int_1::data_;36    std::reference_wrapper<int A_int_1::*> r1(fp);37    A_int_1 a;38    assert(r1(a) == 5);39    r1(a) = 6;40    assert(r1(a) == 6);41    const A_int_1* ap = &a;42    assert(r1(ap) == 6);43    r1(ap) = 7;44    assert(r1(ap) == 7);45    }46}47 48int main(int, char**)49{50    test_int_1();51 52  return 0;53}54