Subject: [Boost-bugs] [Boost C++ Libraries] #7299: Spirit Karma static assert with unicode enabled on Win32 and Win64
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-28 10:51:51
#7299: Spirit Karma static assert with unicode enabled on Win32 and Win64
--------------------------------------------------------+-------------------
Reporter: Dave Bailey <David.Bailey@â¦> | Owner: djowel
Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
Version: Boost 1.50.0 | Severity: Problem
Keywords: spirit karma unicode |
--------------------------------------------------------+-------------------
The following code causes a static assert in
boost/spirit/home/karma/detail/output_iterator.hpp. The problem is that
buffer_sink stores charactes in a std::basic_string<wchar_t>, but when
BOOST_SPIRIT_UNICODE is defined, the output character size is 32-bit. On
Windows, wchar_t is 16-bit, which will always hit the static assert. On
Linux, wchar_t is 32-bit so we don't have the issue.
{{{
#!cpp
#ifndef BOOST_SPIRIT_UNICODE
#define BOOST_SPIRIT_UNICODE
#endif
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/home/qi.hpp>
#include <boost/spirit/home/karma.hpp>
#include <string>
namespace karma = boost::spirit::karma;
template<typename OutputIterator>
struct unicode_char_
: public karma::grammar<OutputIterator,
::boost::spirit::char_encoding::unicode::char_type()>
{
unicode_char_() : base_type(thechar)
{
using karma::unicode::char_;
thechar = char_;
}
karma::rule<OutputIterator,
::boost::spirit::char_encoding::unicode::char_type()> thechar;
};
int main()
{
typedef
std::basic_string<boost::spirit::char_encoding::unicode::char_type>
unicode_string;
typedef std::back_insert_iterator<unicode_string>
unicode_back_insert_iterator_type;
unicode_string input;
unicode_string output;
unicode_back_insert_iterator_type insert_iter(output);
unicode_char_<unicode_back_insert_iterator_type> unichar;
karma::generate(insert_iter,unichar,input);
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7299> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC