Created
December 28, 2016 11:28
-
-
Save benpigchu/f1fd92bbc80667b723689de7e09d1a30 to your computer and use it in GitHub Desktop.
Naively bomb the compiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<int _height> | |
struct node{ | |
const int height=_height; | |
node<_height-1> left; | |
node<_height-1> right; | |
inline print(int num=0){ | |
for(int i=0;i<num;i++){ | |
std::cout<<'-'; | |
} | |
std::cout<<height<<std::endl; | |
left.print(num+1); | |
right.print(num+1); | |
} | |
}; | |
template<> | |
struct node<1>{ | |
const int height=1; | |
inline print(int num=0){ | |
for(int i=0;i<num;i++){ | |
std::cout<<'-'; | |
} | |
std::cout<<height<<std::endl; | |
} | |
}; | |
int main(){ | |
node<18> n;//try a larger number | |
n.print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment