[libcxx-commits] [PATCH] D116380: [libc++] Use std::addressof in std::function::target

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 29 09:37:43 PST 2021


Quuxplusone requested changes to this revision.
Quuxplusone added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/addressof.pass.cpp:20
+struct TrapAddressof {
+    void operator&() const; // badly behaved addressof operator
+    int operator()() const { return 1; }
----------------
`template<class T> friend void operator&(T) {}` to expand its power a bit further.
Or actually, even better, go all out with the traditional ADL-proofing test:
```
struct Incomplete;
template<class T> struct Holder { T t; };
template<class T> struct Callable {
    int operator()() const { return 1; }
};

int main(int, char**) {
    std::function<int()> f = Callable<Holder<Incomplete>>();
    assert(f() == 1);
    return 0;
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116380/new/

https://reviews.llvm.org/D116380



More information about the libcxx-commits mailing list