[Fusion] wide-char output
Hi,
the documentation of the Boost.Fusion library (1.63.0) at
http://www.boost.org/doc/libs/1_63_0/libs/fusion/doc/html/fusion/sequence/op...
affirms that operator<< is defined in the boost::fusion namespace with
the following synopsis:
template
Leo Cacciari
Accordingly, I thought that the following would work:
using boost::fusion::operator<<; fusion::vector
v = fusion::make_vector(42, 3.1415, "foobar"); std::wcout << "v = " << v << std::endl;
Forgive me if I'm missing something obvious: Could the problem be that your passing char-based strings to an output stream expecting wchar_t-based text? Couldn't you fix this by writing to std:cout instead of std::wcout? |+| M a r k |+| Mark Stallard Business Application Services Global Business Services Information Technology Raytheon Company
AMDG On 04/05/2017 10:43 AM, Mark Stallard via Boost-users wrote:
Leo Cacciari
wrote: Accordingly, I thought that the following would work:
using boost::fusion::operator<<; fusion::vector
v = fusion::make_vector(42, 3.1415, "foobar"); std::wcout << "v = " << v << std::endl; Forgive me if I'm missing something obvious: Could the problem be that your passing char-based strings to an output stream expecting wchar_t-based text?
Couldn't you fix this by writing to std:cout instead of std::wcout?
basic_ostream has an overload for const char * in addition to const CharT*. In Christ, Steven Watanabe
On Wed, Apr 5, 2017 at 6:43 PM, Mark Stallard
Forgive me if I'm missing something obvious: Could the problem be that your passing char-based strings to an output stream expecting wchar_t-based text?
No, it's a 'char *', not a std::string, and this is definitely valid: std::cout << "foobar" << std::endl;
Couldn't you fix this by writing to std:cout instead of std::wcout?
No, because the actual structure I will use contains members that are std::wstring (and those can not be sent to std::cout directly). Nor can those std::wstring be made std::string. Leaving out the hassle of converting the encoding without a C+11 compiler (I'm stuck with MSVC9), there is the problem that these data are windows system data (device properties, in fact) that must be read and writen back in wide char. So I'll have to convert between 8- and 16-bits encoding all the time... Ugly! :) -- Leo Cacciari Aliae nationes servitutem pati possunt. Populi Romani est propria libertas.
AMDG On 04/05/2017 09:10 AM, Leo Cacciari via Boost-users wrote:
the documentation of the Boost.Fusion library (1.63.0) at http://www.boost.org/doc/libs/1_63_0/libs/fusion/doc/html/fusion/sequence/op... affirms that operator<< is defined in the boost::fusion namespace with the following synopsis:
template
OStream& operator<<(OStream& os, Sequence& seq); where the template parameter OStream is defined as "An output stream".
<snip>
Looking into the source (file boost/fusion/sequence/io/out.hpp) it seems that the operator<< is only defined for left-hand argument of type std::ostream.
Thus the questions:
1. Is this a bug and should I post a ticket about it? (I looked in the bugs database but I couldn't find it)
It's definitely a bug. Whether the bug is in
the documentation or in the source, I can't say.
Personally, I think both are wrong, and the
correct signature is
template
2. If it's a bug, are there any plan to patch it soon? 3. If not, does exist any reason why it shouldn't be patched nevertheless?
In Christ, Steven Watanabe
participants (3)
-
Leo Cacciari
-
Mark Stallard
-
Steven Watanabe