John Wilkinson | 7 Feb 21:43
Picon
Favicon

template parameter for BOOST_FUSION_ADAPT_STRUCT?

Hi, I have a grammer that I want to work with string or wstrings or perhaps a user supplied string type. I
cannot see a way to get BOOST_FUSION_ADAPT_STRUCT to work with different sting types without defining a
BOOST_FUSION_ADAPT_STRUCT for each type, e.g.:

template< class String_t >
struct Pair
{
    String_t s1, s2;
};

template < class String_t >
struct Grammer : qi::grammar< typename String_t::const_iterator, Pair< String_t >(),
ascii::space_type >
{
    Grammer() : Grammer::base_type( pair_ )
    {
        pair_ = str_ >> ':' >> str_;
        str_ = *(qi::char_ - ':');
    }

    qi::rule< iterator_type, Pair< String_t >(), ascii::space_type > pair_;
    qi::rule< iterator_type, String_t(), ascii::space_type > str_;
};

BOOST_FUSION_ADAPT_STRUCT(
    Pair< string >,
    (string, s1)
    (string, s2)
)

BOOST_FUSION_ADAPT_STRUCT(
    Pair< wstring >,
    (wstring, s1)
    (wstring, s2)
)

Is there a way to only have one BOOST_FUSION_ADAPT_STRUCT that will work with any Pair type?

Thanks
John W

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

Gmane