Consider an example.
#include <string> struct S { S() { new (&s) std::string("hi"); } ~S() { // does not compile // s.~std::string(); // compiles using std::string; s.~string(); } union { std::string s; }; };
Why is the comment part not compiling?
The error message that I get from clang shows that the compiler itself parses stdas a type.
std
identifier 'std' in object destruction expression does not name type
Why can't the compiler determine what std::stringa type is? Is this ambiguous in some way?
std::string
I became aware of this from a presentation by Andrei Alexandrescu. It's at 37:10. He quickly comments that it will not “analyze” if the type name is qualified, but does not explain why.
http://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
( "parse" , , . . , - .)
, std::string . , , ~string() .
~string()
std::string <string>, , typedef ( ) std::basic_string<char>.
<string>
std::basic_string<char>
A typedef typedef some_class_name another_name ~another_name.
typedef
typedef some_class_name another_name
~another_name
Source: https://habr.com/ru/post/1569726/More articles:Behat 3 - passing parameters (from an imported file) to the FeatureContext constructor - phpcloud 9 IDE says dead - cloud9-ideIs adding a libjitsi dependency to an Android project? - androidConversion to Dalvik format failed with error 1 when compiling jitsi project - javaMaking calls over the internet in android - androidHow to save a list in a file and read it as a list type? - pythonRESTful API Design - httpGlobal Product Woocommerce (multisite) - wordpressRegex replace number after capture group? - regexCommons-Io Duplicate Entry Error Использование Robospice и Android Studio - androidAll Articles