Why does std::string(whatever)
declare a variable named whatever
? Why isn't that expression treated as a constructor call and error out?
#include <string>
int main() {
std::string(something);
another += "something";
static_assert(std::is_same<decltype(something), std::string>::value, "");
assert(another == "something");
return 0;
}
I am compiling with C++14 with the following compiler version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode_8.3.3_fb.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Aucun commentaire:
Enregistrer un commentaire