C++: Can a macro expand "abc" into 'a', 'b', 'c'?
Posted
by
Peter Alexander
on Stack Overflow
See other posts from Stack Overflow
or by Peter Alexander
Published on 2011-01-03T08:29:32Z
Indexed on
2011/01/03
18:53 UTC
Read the original article
Hit count: 225
I've written a variadic template that accepts a variable number of char
parameters, i.e.
template <char... Chars>
struct Foo;
I was just wondering if there were any macro tricks that would allow me to instantiate this with syntax similar to the following:
Foo<"abc">
or
Foo<SOME_MACRO("abc")>
or
Foo<SOME_MACRO(abc)>
etc.
Basically, anything that stops you from having to write the characters individually, like so
Foo<'a', 'b', 'c'>
This isn't a big issue for me as it's just for a toy program, but I thought I'd ask anyway.
© Stack Overflow or respective owner