Ticket #9655: main.cpp
| File main.cpp, 366 bytes (added by , 9 years ago) |
|---|
| Line | |
|---|---|
| 1 | #include<boost/variant> |
| 2 | #include<memory> |
| 3 | |
| 4 | struct Visitor : public boost::static_visitor<std::unique_ptr<int>> { |
| 5 | template<class T> |
| 6 | std::unique_ptr<int> operator()(T& operand) { |
| 7 | return std::unique_ptr<int>(new int(5)); |
| 8 | } |
| 9 | }; |
| 10 | |
| 11 | |
| 12 | int main() { |
| 13 | boost::variant<int,double> a = int(5); |
| 14 | boost::apply_visitor(Visitor(),a); // this doesn't compile |
| 15 | } |
