u16string,uchar16_t,,basic_ostream,basic_ostringstream not working

J

jmichae3

#include <ostream>
#include <streambuf>
#include <sstream>
#include <vector>
#include <string>
#include <ios>
#include <initializer_list>
#include <uchar.h>
#include <wchar.h>
typedef std::vector<std::u16string> Vu16S;
typedef std::basic_ostringstream<char16_t, std::char_traits<char16_t>, std::allocator<char16_t> > u16ostringstream;
typedef std::basic_ostringstream<char32_t, std::char_traits<char32_t>, std::allocator<char32_t> > u32ostringstream;
//typedef std::basic_ostream<char16_t, std::char_traits<char16_t> > u16ostream;
//typedef std::basic_ostream<char32_t, std::char_traits<char32_t> > u32ostream;
std::basic_ostringstream<std::basic_stringbuf<char16_t> > u16ograph;
std::basic_ostringstream<std::basic_stringbuf<char32_t> > u32ograph;
typedef std::basic_streambuf<char16_t, std::char_traits<char16_t> > u16streambuf;
typedef std::basic_streambuf<char32_t, std::char_traits<char32_t> > u32streambuf;
u16streambuf u16sb;
u32streambuf u32sb;
std::basic_ostream<char16_t, std::char_traits<char16_t> > u16cout(&u16sb);
std::basic_ostream<char32_t, std::char_traits<char32_t> > u32cout(&u32sb);
//uostream ucout;
//u32ostream u32cout;

Vu16S vu16blockss={u"\u00a0",u"\u2591",u"\u2592",u"\u2593",u"\u2588"};
int main(void) {
uostringstream o16graph;
u16ograph<<vu16blockss[1];
u16cout<<ograph.str();
u16cout<<u"\u00a0\u2591\u2592\u2593\u2588";
return 0;
}
/*
In file included from ostream2a.cpp:2:0:
f:\x86_64-4.9.0-snapshot-20140219-rev207854-win32-sjlj-rt_v4\mingw64\x86_64-w64-mingw32\include\c++\ostream:384:7: error: 'std::basic_ostream<_CharT, _Traits>::
basic_ostream() [with _CharT = char16_t; _Traits = std::char_traits<char16_t>]' is protected
basic_ostream()
^
ostream2a.cpp:16:10: error: within this context
uostream ucout;
^
In file included from ostream2a.cpp:2:0:
f:\x86_64-4.9.0-snapshot-20140219-rev207854-win32-sjlj-rt_v4\mingw64\x86_64-w64-mingw32\include\c++\ostream:384:7: error: 'std::basic_ostream<_CharT, _Traits>::
basic_ostream() [with _CharT = char32_t; _Traits = std::char_traits<char32_t>]' is protected
basic_ostream()
^
ostream2a.cpp:17:12: error: within this context
u32ostream u32cout;
^
ostream2a.cpp:27:1: error: expected '}' at end of input
}
^
I saw this later on and this matched my implementation (but I did not know about dropping the 16):
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2035.pdf
but this doesn't work, even apparently with the microsoft compiler. something funny with the standard?

previous revision I thought this was the problem:
is this the reason? http://sourceforge.net/p/mingw-w64/mailman/message/31588691/
I have no idea how to make UNICODE work with std::eek:stringstream. eventually it needs to go to std::cout.

so: what is wrong in the first error? I don't understand why something is protected. somebody said something about
fstream containing the implementation of ostream in gcc (not sure if this is stil true). apparently, msvc++ has this problem too.
seems like something I ought to be able to do simply, but it just breaks. not sure why this is protected.
there is no wstring_convert. I grepped for it.
http://www.cplusplus.com/reference/streambuf/basic_streambuf/
http://www.cplusplus.com/reference/sstream/basic_ostringstream/
http://www.cplusplus.com/reference/ostream/basic_ostream/
http://www.cplusplus.com/reference/fstream/basic_ofstream/
*/




I was told to use a streambuf (since it's in the class as a contructor). however, when I DO use it, I get an error that it's protected.
In file included from f:\x86_64-4.9.0-snapshot-20140219-rev207854-win32-sjlj-rt_v4\mingw64\x86_64-w64-mingw32\include\c++\ios:43:0,
from f:\x86_64-4.9.0-snapshot-20140219-rev207854-win32-sjlj-rt_v4\mingw64\x86_64-w64-mingw32\include\c++\ostream:38,
from ostream2a.cpp:1:
f:\x86_64-4.9.0-snapshot-20140219-rev207854-win32-sjlj-rt_v4\mingw64\x86_64-w64-mingw32\include\c++\streambuf:463:7: error: 'std::basic_streambuf<_CharT, _Trait
s>::basic_streambuf() [with _CharT = char16_t; _Traits = std::char_traits<char16_t>]' is protected
basic_streambuf()
^

apparently same problem with VC++ too, so wondering if it's a spec problem.
would prefer to typedef something if I can. if I could make changes to the class and submit a patch, I would, but not exactly sure of the details involved for char16_t on gcc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top