1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// { dg-options "-std=gnu++0x" }
template<template<int, int> class Meta, int Initial, int... Values>
struct accumulate {
static const int value = Initial;
};
template<template<int, int> class Meta, int Initial, int Value, int... Rest>
struct accumulate<Meta, Initial, Value, Rest...> {
static const int value =
Meta<Value, accumulate<Meta, Initial, Rest...>::value>::value;
};
template<int X, int Y>
struct sum {
static const int value = X + Y;
};
template<int X, int Y>
struct prod {
static const int value = X * Y;
};
int a0[accumulate<sum,0,1,2,3,4,5>::value == 15? 1 : -1];
int a1[accumulate<prod,1,1,2,3,4,5>::value == 120? 1 : -1];
|