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 // UNSUPPORTED: c++03 10 11 // <functional> 12 13 // class function<R(ArgTypes...)> 14 15 // Make sure we can use std::function with a type that has a hostile overload 16 // of operator&(). 17 18 #include <functional> 19 #include <cassert> 20 21 #include "operator_hijacker.h" 22 23 struct TrapAddressof : operator_hijacker { operator ()TrapAddressof24 int operator()() const { return 1; } 25 }; 26 main(int,char **)27int main(int, char**) { 28 std::function<int()> f = TrapAddressof(); 29 assert(f() == 1); 30 return 0; 31 } 32