File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111#include < stdexcept>
1212#include < type_traits>
1313
14+ template <int N>
15+ struct fib
16+ {
17+ static const int value =
18+ fib<N - 1 >::value + fib<N - 2 >::value;
19+ };
20+
21+ template <>
22+ struct fib <0 >
23+ {
24+ static const int value = 1 ;
25+ };
26+
27+ template <>
28+ struct fib <1 >
29+ {
30+ static const int value = 1 ;
31+ };
32+
1433// [[deprecated("deadline:2020-12-31")]] // c+14 or later
1534[[gnu::deprecated]] // c+11 or later
1635int old_func ()
@@ -67,6 +86,7 @@ void case3()
6786
6887void case4 ()
6988{
89+ static_assert (sizeof (int ) == 4 , " int must be 32bit" );
7090 static_assert (sizeof (long ) >= 8 , " must run on x64" );
7191}
7292
@@ -86,6 +106,12 @@ void check_type(T v)
86106
87107int main ()
88108{
109+ using namespace std ;
110+
111+ cout << fib<2 >::value << endl;
112+ cout << fib<3 >::value << endl;
113+ cout << fib<5 >::value << endl;
114+
89115 old_func ();
90116 get_num ();
91117
You can’t perform that action at this time.
0 commit comments