2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -fdump-tree-optimized" }
4 // { dg-final { scan-tree-dump "return 0" "optimized" } }
11 constexpr bool same(char const *x, char const *y) {
12 return !*x && !*y ? true
13 : /* default */ (*x == *y && same(x+1, y+1));
16 constexpr int keyToValue(char const *label, entry const *entries) {
17 return !entries->label ? entries->value
18 : same(entries->label, label) ? entries->value
19 : /*default*/ keyToValue(label, entries+1);
22 constexpr entry foo[] = {{"Foo", 0}, {"Bar", 1}, {"FooBar", 2}, {0, -1}};
27 int result = keyToValue("Foo", foo);