Suppose I need to call a function foo that takes a const std::string reference from a great number of places in my code:
foo
std::string
int foo(const
This will work for simple strings - w/o whitespace:
#define DECL_STR(s) const std::string str_##s (#s)
Usage in header (parse once!):
DECL_STR(Foo); DECL_STR(Bar);
In code:
func(str_Foo); func(str_Bar);