// { dg-do compile { target c++17 } } // { dg-options "-fconcepts" } template concept HasInit = requires(T t, Params... p) { t.init(p...); }; struct Initable { void init(int) { } }; struct Createable { void create(int) { } }; struct Foo{ template void for_each(CB&& cb) { Initable i; Createable c; cb(i); cb(c); } Foo() { struct Bar { int x; }; for_each( [&](auto& foo){ if constexpr (HasInit) { foo.init(5); } }); } }; int main() { Foo f; return 0; }