invoke.fail.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <functional>
11
12// class function<R(ArgTypes...)>
13
14// R operator()(ArgTypes... args) const
15
16#include <functional>
17#include <cassert>
18
19// member data pointer:  cv qualifiers should transfer from argument to return type
20
21struct A_int_1
22{
23    A_int_1() : data_(5) {}
24
25    int data_;
26};
27
28void
29test_int_1()
30{
31    // member data pointer
32    {
33    int A_int_1::*fp = &A_int_1::data_;
34    A_int_1 a;
35    std::function<int& (const A_int_1*)> r2(fp);
36    const A_int_1* ap = &a;
37    assert(r2(ap) == 6);
38    r2(ap) = 7;
39    assert(r2(ap) == 7);
40    }
41}
42
43
44int main()
45{
46    test_int_1();
47}
48