C++ Logo

SG7

Advanced search

Subject: Re: Metaprogramming
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-10-26 13:51:33


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.


SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups