Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/concepts/pr91073-1.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
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; }