Macro for static std::string object from literal
问题 Suppose I need to call a function foo that takes a const std::string reference from a great number of places in my code: int foo(const std::string&); .. foo("bar"); .. foo("baz"); Calling a function with a string literal like this will create temporary std::string objects, copying the literal each time. Unless I'm mistaken, compilers won't optimize this by creating a static std::string object per literal that can be reused for subsequent calls. I know that g++ has advanced string pool