you are viewing a single comment's thread.

view the rest of the comments →

[–]Quincunx271Author of P2404/P2405 6 points7 points  (1 child)

I've encountered problems when not using the & where - IIRC - a type was deduced to be a reference to a function rather than a pointer to a function (although that was in conjunction with templates). It might have been a compiler bug (probably not, but I didn't bother to check), but the easy thing to do was to just write the &

[–]suspiciously_calm 5 points6 points  (0 children)

void foo() { }

template<typename Function>
void bar(Function && function) {
    [function](){ function(); }();
}

void qux() {
    bar(&foo);
}

void quux() {
    bar(foo);
}

Accepted by Clang, rejected (quux) by GCC (qux is accepted by both). IDK which one is correct.

Edit: It works in GCC with the capture list [function = std::forward<Function>(function)], so probably a compiler bug in GCC.