Рассмотрим следующий код
template<bool b, typename T> void foo(const T& t = []() {}) {
// implementation here
}
void bar() {
foo<true>([&](){ /* implementation here */ }); // this compiles
foo<true>(); // this doesn't compile
}
В случае, если он не компилируется, я получаю следующие ошибки:
error C2672: 'foo': no matching overloaded function found
error C2783: 'void foo(const T&)': could not deduce template argument for 'T'
Думаю, понятно, чего я хочу добиться: пусть foo
вызывается с лямбдой, предоставляемой клиентом, и без нее. Компилятор представляет собой набор инструментов MSVC++2017 версии 15.4.4 v141.