1 | // Demonstration of apply_visitor failing to compile with move-only return type
|
---|
2 | //clang++ -I/opt/local/include --std=c++11 main.cpp -o main
|
---|
3 |
|
---|
4 | #include <boost/variant.hpp>
|
---|
5 | #include <memory>
|
---|
6 |
|
---|
7 | struct test : boost::static_visitor<std::unique_ptr<bool> > {
|
---|
8 | std::unique_ptr<bool> operator()(int) const {
|
---|
9 | return std::unique_ptr<bool>(new bool(true));
|
---|
10 | }
|
---|
11 | std::unique_ptr<bool> operator()(double) const {
|
---|
12 | return std::unique_ptr<bool>(new bool(false));
|
---|
13 | }
|
---|
14 | };
|
---|
15 |
|
---|
16 | int main(){
|
---|
17 | boost::variant<int,double> vdata{2.0};
|
---|
18 | std::unique_ptr<bool> result = boost::apply_visitor(test(), vdata);
|
---|
19 | return 0;
|
---|
20 | }
|
---|