C++ Logo

sg7

Advanced search

Re: [SG7] Metaprogramming

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 26 Oct 2020 20:51:33 +0200
On Mon, 26 Oct 2020 at 20:37, David Rector <davrec_at_[hidden]> wrote:
> One alternative way to make meta content stand out: always express it via strings literals.
>
> I’m not trying to be cute: we could still do fragments semantically, while using string injection syntax, and thereby perhaps get the best of both worlds. E.g.:
>
> ```
> consteval void create_var_42(const char *name) {
> inject("int " + name + " = 42;");
> }

I don't see how that stands out. It seems to do quite the opposite,
blend in in plain sight.
Except for the need of all those +, which certainly stand out as noise.

Received on 2020-10-26 13:51:47