3 ms·
I actually like c++, but I can't deny the syntax is incredibly ugly. for example, here's a declaration of a vector of pairs of strings suitable for a header fil
by leetcrew 6y ago
I actually like c++, but I can't deny the syntax is incredibly ugly. for example, here's a declaration of a vector of pairs of strings suitable for a header file:
std::vector<std::pair<std::string, std::string>> vec;
anything involving nested namespaces and template parameters gets out of control really fast. the textual inclusion paradigm means I must declare the vector this way unless I want to inject everything from std:: into any source file that includes the header.
I'm not sure what GP means about debugging. in my experience it's just like any other language if you have symbols and minimal optimizations. it can be kinda weird with optimizations, but that's to be expected. if the compiler can optimize away entire blocks of code, I don't think a debugger can abstract over that.
- bloodorange 6y agoYou can alias that type into a simpler name and keep using that instead of bringing components into the current namespace (or the global one). I haven't done C++ in some years but this was definitely a part of C++11.
- leetcrew 6y agoin practice I would probably do something more like this: typedef std::pair<std::string, std::string> TStringPair; std::vector<TStringPair> vec; or maybe: typedef std::vector<std::pair<std::string, std::string>> TStringPairVec; TStringPairVec vec; this improves readability a bit, but is even more verbose at the declaration site if I'm not reusing the typedefs elsewhere. in an ideal world, I'd like something analogous to #undef for `using namespace` (or better yet, have this be the default at the end of a header file). this is only scratching the surface of the gotchas that come from textual inclusion.