language: C++ 4.7.2 (gcc-4.7.2)
date: 500 days 5 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
template<unsigned Cur, unsigned Goal>
struct adder{
  static unsigned const sub_goal = (Cur + Goal) / 2;
  static unsigned const tmp = adder<Cur, sub_goal>::value;
  static unsigned const value = tmp + adder<sub_goal+1, Goal>::value;
};
 
template<unsigned Goal>
struct adder<Goal, Goal>{
  static unsigned const value = Goal;
};
 
template<unsigned Start>
struct sum_from{
  template<unsigned Goal>
  struct to{
    template<unsigned N>
    struct equals;
 
    typedef equals<adder<Start, Goal>::value> result;
  };
};
 
int main(){
  sum_from<1>::to<1000>::result();
}
prog.cpp: In function ‘int main()’:
prog.cpp:25: error: invalid use of incomplete type ‘struct sum_from<1u>::to<1000u>::equals<500500u>’
prog.cpp:18: error: declaration of ‘struct sum_from<1u>::to<1000u>::equals<500500u>’