The following code fails in GCC, Clang and Visual Studio:
#include <string>
#include <sstream>
int main() {
std::string s = "hello"; // ok, copy-initialization
std::stringstream ss1(s); // ok, direct-initialization
std::stringstream ss2 = s; // error
}
I thought the only case where direct-initialization works while copy-initialization doesn't is when the constructor is explicit, which it is not in this case. What's going on?