brintos

brintos / llvm-project-archived public Read only

0
0
Text · 813 B · 717e655 Raw
32 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++0310 11// <functional>12 13// class function<R(ArgTypes...)>14 15// Make sure we can use std::function with a type that has a hostile overload16// of operator&().17 18#include <functional>19#include <cassert>20 21#include "operator_hijacker.h"22 23struct TrapAddressof : operator_hijacker {24    int operator()() const { return 1; }25};26 27int main(int, char**) {28    std::function<int()> f = TrapAddressof();29    assert(f() == 1);30    return 0;31}32