boostorg / spirit

Boost.org spirit module
http://boost.org/libs/spirit
392 stars 161 forks source link

x3::variant operator << prints empty #552

Closed allopislozano closed 4 years ago

allopislozano commented 4 years ago

Hi there, the operator << of x3::variant always prints an empty string. Is this a bug?

https://wandbox.org/permlink/qS2XErm6hbi2ZLt9

#include<vector>
#include<string>
#include <utility>
#include <iostream>
#define BOOST_SPIRIT_X3_DEBUG
#include <boost/spirit/home/x3.hpp>
#include <boost/spirit/home/x3/support/ast/variant.hpp>

using std::vector;
using std::string;
namespace x3 = boost::spirit::x3;
int main()
{
   using V = boost::variant<string,int>;

   V v = V(string("hello"));

   std::cout << "V:" << v << std::endl;

   using V2 = x3::variant<string,int>;
   V2 v2 = V2(string("hello"));

   std::cout << "V2:" << v2 << std::endl;

}
Kojoley commented 4 years ago

This compiles by accident, x3::variant does not have streaming operators.