Reputation: 2117
I want to concatenate a number of string literals at compile time:
#include <iostream>
#define VAR0 "var0 text"
#define VAR1 "var1 text"
#define VAR2 "var2 text"
static const char* concat = "var0:" VAR0 " var1:" VAR1 " var2:" VAR2 ;
int main(int argc, char *argv[])
{
std::cout << concat << std::endl;
return(0);
}
This is all very well, but I'd rather use constant expressions instead of macros. Is there any simple way of doing this in C++ 03?
Upvotes: 0
Views: 1520