member_data.pass.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// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
13
14#include <functional>
15#include <cassert>
16
17struct A
18{
19    double data_;
20};
21
22template <class F>
23void
24test(F f)
25{
26    {
27    A a;
28    f(a) = 5;
29    assert(a.data_ == 5);
30    A* ap = &a;
31    f(ap) = 6;
32    assert(a.data_ == 6);
33    const A* cap = ap;
34    assert(f(cap) == f(ap));
35    }
36}
37
38int main()
39{
40    test(std::mem_fn(&A::data_));
41}
42