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