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 //===----------------------------------------------------------------------===// 8 9 // GCC 5 does not evaluate static assertions dependent on a template parameter. 10 // UNSUPPORTED: gcc-5 11 12 // <functional> 13 14 // template<Returnable R, class T> unspecified mem_fn(R T::* pm); 15 16 #include <functional> 17 #include <cassert> 18 19 struct A 20 { 21 double data_; 22 }; 23 24 template <class F> 25 void 26 test(F f) 27 { 28 { 29 A a; 30 f(a) = 5; 31 assert(a.data_ == 5); 32 A* ap = &a; 33 f(ap) = 6; 34 assert(a.data_ == 6); 35 const A* cap = ap; 36 assert(f(cap) == f(ap)); 37 f(cap) = 7; 38 } 39 } 40 41 int main(int, char**) 42 { 43 test(std::mem_fn(&A::data_)); 44 45 return 0; 46 } 47