You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't compile std::basic_stringstream<std::byte, ByteCharTraits> with only constructor. GCC accepts this code.
It gives error in basic_stringbuf::allocator on sputc function.
clang++ -stdlib=libc++ byte_stream.cpp -std=c++17
In file included from byte_stream.cpp:1:
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/sstream:562:28: error: cannot initialize a parameter of type 'std::__1::basic_streambuf<std::byte,
ByteCharTraits>::char_type' (aka 'std::byte') with an lvalue of type 'std::__1::basic_stringbuf<std::byte, ByteCharTraits,
std::__1::allocatorstd::byte >::int_type' (aka 'int')
return this->sputc(__c);
^~~
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/sstream:866:28: note: in instantiation of member function 'std::__1::basic_stringbuf<std::byte,
ByteCharTraits, std::__1::allocatorstd::byte >::overflow' requested here
class _LIBCPP_TEMPLATE_VIS basic_stringstream
^
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/streambuf:221:30: note: passing argument to parameter '__c' here
int_type sputc(char_type __c) {
^
1 error generated.
The text was updated successfully, but these errors were encountered:
Tanks for the report. I have reproduced this locally; it appears that someone made an assumption that traits::char_type and traits::int_type are implicitly convertible. (which (a) has been true in the past, and (b) is not true for your example).
Fixing this particular bit is straightforward; replace line 562 of with
return this->sputc(traits_type::to_char_type(__c));
However, I'm wondering what other places this assumption is lurking in the iostreams code. I'll be looking into that soon.
In the classes of [input.output], a template parameter with name charT represents a member of the set of types containing char, wchar_t, and any other implementation-defined character types that satisfy the requirements for a character on which any of the iostream components can be instantiated.
Extended Description
I can't compile std::basic_stringstream<std::byte, ByteCharTraits> with only constructor. GCC accepts this code.
It gives error in basic_stringbuf::allocator on sputc function.
clang++ -stdlib=libc++ byte_stream.cpp -std=c++17
In file included from byte_stream.cpp:1:
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/sstream:562:28: error: cannot initialize a parameter of type 'std::__1::basic_streambuf<std::byte,
ByteCharTraits>::char_type' (aka 'std::byte') with an lvalue of type 'std::__1::basic_stringbuf<std::byte, ByteCharTraits,
std::__1::allocatorstd::byte >::int_type' (aka 'int')
return this->sputc(__c);
^~~
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/sstream:866:28: note: in instantiation of member function 'std::__1::basic_stringbuf<std::byte,
ByteCharTraits, std::__1::allocatorstd::byte >::overflow' requested here
class _LIBCPP_TEMPLATE_VIS basic_stringstream
^
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/streambuf:221:30: note: passing argument to parameter '__c' here
int_type sputc(char_type __c) {
^
1 error generated.
The text was updated successfully, but these errors were encountered: