Skip to content

Instantly share code, notes, and snippets.

@benpigchu
Created December 28, 2016 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benpigchu/f1fd92bbc80667b723689de7e09d1a30 to your computer and use it in GitHub Desktop.
Save benpigchu/f1fd92bbc80667b723689de7e09d1a30 to your computer and use it in GitHub Desktop.
Naively bomb the compiler
#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