Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/concepts/pr91073-1.C @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | 1830386684a0 |
children |
line wrap: on
line source
// { dg-do compile { target c++17 } } // { dg-options "-fconcepts" } template<typename T, typename... Params> concept HasInit = requires(T t, Params... p) { t.init(p...); }; struct Initable { void init(int) { } }; struct Createable { void create(int) { } }; struct Foo{ template<typename CB> 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<decltype(foo), int>) { foo.init(5); } }); } }; int main() { Foo f; return 0; }