Is it possible to concat two string literals using a constexpr? Or put differently, can one eliminate macros in code like:
#define nl(str) str \
A little bit of constexpr, sprinkled with some TMP and a topping of indices gives me this:
#include
template struct seq{};
template
struct gen_seq : gen_seq{};
template
struct gen_seq<0, Is...> : seq{};
template
constexpr std::array concat(char const (&a1)[N1], char const (&a2)[N2], seq, seq){
return {{ a1[I1]..., a2[I2]... }};
}
template
constexpr std::array concat(char const (&a1)[N1], char const (&a2)[N2]){
return concat(a1, a2, gen_seq{}, gen_seq{});
}
Live example.
I'd flesh this out some more, but I have to get going and wanted to drop it off before that. You should be able to work from that.