[Spirit Devel] [ADAPT_ADT and Karma] ADAPT_ADT causes grammars with variants to not compile in karma
Robert Nelson <[email protected]> Sat, 20 Nov 2010 06:24:16 -0700
| Newsgroups | gmane.comp.parsers.spirit.devel |
|---|---|
| Message-ID | <[email protected]> |
I am trying to output a variant in using the ADAPT_ADT macro and Karma. It
seems to be a problem with the adt_proxy class that causes the variant
conversion to fail. I can easily get similar code working with
ADAPT_STRUCT.
The following fails to compile.
typedef const boost::variant<std::string,unsigned int> const_variant_type;
struct y
{
const_variant_type& get() const;
void set(const_variant_type&);
};
BOOST_FUSION_ADAPT_ADT(y,(const_variant_type,const_variant_type,obj.get(),obj.set(val)))
int main()
{
using namespace boost::spirit::karma;
using namespace boost::phoenix;
boost::spirit::karma::rule<std::string::iterator,std::string()> a;
boost::spirit::karma::rule<std::string::iterator,unsigned int()> b;
boost::spirit::karma::rule<std::string::iterator,y()> Y;
Y = (a | b)[_1 = at_c<0>(_val)];
}
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
main.cpp
(text/x-c++src, 985 B)
#include <boost/spirit/include/karma.hpp>
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/home/support/adapt_adt_attributes.hpp>
#include <boost/variant/variant.hpp>
#include <string>
typedef const boost::variant<std::string,unsigned int> const_variant_type;
struct y
{
const_variant_type& get() const;
void set(const_variant_type&);
};
BOOST_FUSION_ADAPT_ADT(y,(const_variant_type,const_variant_type,obj.get(),obj.set(val)))
int main()
{
using namespace boost::spirit::karma;
using namespace boost::phoenix;
boost::spirit::karma::rule<std::string::iterator,std::string()> a;
boost::spirit::karma::rule<std::string::iterator,unsigned int()> b;
boost::spirit::karma::rule<std::string::iterator,y()> Y;
Y = (a | b)[_1 = at_c<0>(_val)];
}