#include<iostream>
using namespace std;
template<typename T,T val,typename L,typename R>
struct Tree {
};
template<typename T>
struct Print {
};
template<typename T, T val,typename L, typename R>
struct Print<Tree<T,val,L,R> >{
static void print() {
cout << val<<' ';
if constexpr (is_void<L>::value == false) {
Print<L>::print();
}
if constexpr (is_void<R>::value == false) {
Print<R>::print();
}
}
};
int main() {
Print<Tree<int, 3, Tree<int, 4, void, void>, Tree<int, 5, void, void>>>::print();
}
c++元编程打印二叉树
猜你喜欢
转载自blog.csdn.net/weixin_39057744/article/details/120801834
今日推荐
周排行