1 | #include <string>
|
---|
2 | #include <iterator>
|
---|
3 |
|
---|
4 | #include <boost/variant.hpp>
|
---|
5 |
|
---|
6 |
|
---|
7 | struct Leaf { };
|
---|
8 | struct Node;
|
---|
9 |
|
---|
10 | using TreeBase = boost::variant<Leaf, boost::recursive_wrapper<Node>>;
|
---|
11 |
|
---|
12 | struct Tree : TreeBase {
|
---|
13 | using TreeBase::TreeBase;
|
---|
14 |
|
---|
15 | template <typename Iter>
|
---|
16 | static Tree Create(Iter first, Iter last) { return Leaf{}; }
|
---|
17 | };
|
---|
18 |
|
---|
19 |
|
---|
20 | struct Node {
|
---|
21 | Tree left, right;
|
---|
22 | };
|
---|
23 |
|
---|
24 |
|
---|
25 | int main() {
|
---|
26 | std::string input{"abracadabra"};
|
---|
27 |
|
---|
28 | const auto root = Tree::Create(begin(input), end(input));
|
---|
29 | }
|
---|