MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / main

Function main

tests/LambdaHandlerCaptureLessTest.cpp:3–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3559.pdf
2
3int main() {
4 int (*fp)(int, char) = [](auto a, auto b){ return a + b; };
5
6#if 0
7struct /* anonymous */
8 {
9template<class A, class B>
10auto operator()(A a, B b) const // N3386 Return Type Deduction
11 { return a + b; }
12 private:
13 // Note: We don't want to simply forward the call to operator()
14 // since forwarding is not entirely transparent, and could
15 // introduce visible side-effects. To produce the
16 // desired semantics we copy the parameter-clause
17 // and body exactly
18 template<class A, class B>
19static auto __invoke(A a, B b) { // N3386 Return Type Deduction return a + b;
20}
21 template<class A, class B, class R>
22 using fptr_t = R (*) (A, B);
23 public:
24 template<class A, class B, class R>
25 operator fptr_t<R, A, B>() const {
26 return &__invoke;
27} } L;
28
29int (*fp)(int, char) = L;
30#endif
31}
32

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected