The following initialization,
auto p = std::make_pair(std::stringstream{}, "Hello World!");
compiles and works fine with clang++
using libc++
.
Compiling it using libstdc++
, however, gives error with both clang++
or g++
,
error: use of deleted function 'std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)'
from g++
, and
error: call to implicitly-deleted copy constructor of 'std::basic_stringstream<char>'
from clang++
using libstdc++
.
My understanding of the standard is that this type of declaration plus initialization should not involve copy constructor. Am I wrong? Should libc++
allow this kind of initialization? Or is libstdc++
not correct?
EDIT: after you kind replies, I know it is a bug in gcc, which won't be fixed until v5. Whether using copy initialization or direct initialization, calling make_pair
always requires a move or copy constructor, which gives error under current buggy gcc. So my question is how to rewrite my code easily to circumvent the bug. I have a class hierarchy which has a member of type stringstream
. Removing it would cause too much headache. Is using a unique_ptr
the only way to go?