Opened 11 years ago

#6066 new Bugs

Getting back std::string from a utree string node throws std::bad_cast

Reported by: Rémy Chibois <rchibois@…> Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.47.0 Severity: Problem
Keywords: spirit utree string bad_cast Cc:

Description

When using:

std::string s1("test"); boost::spirit::utree u = s1;

Either of:

std::string s2 = u.get<std::string>();

or

std::string s2 = u.get<boost::spirit::utf8_string_type>();

fail with a "std::bad_cast" thrown.

Proceeding with:

boost::spirit::utf8_string_range_type rt = u.get<spirit::utf8_string_range_type>(); std::string s2(rt.begin(), rt.end());

works fine...

Please see attached file for a complete example.

Attachments (1)

boost-spirit-utree_get-string.cpp (876 bytes ) - added by Rémy Chibois <rchibois@…> 11 years ago.

Download all attachments as: .zip

Change History (1)

by Rémy Chibois <rchibois@…>, 11 years ago

Note: See TracTickets for help on using tickets.