Aliasing a mixin (or alternative ways to profile a scope)
Simon
simon.vanbernem at yahoo.de
Thu Mar 7 21:21:54 UTC 2019
On Thursday, 7 March 2019 at 20:34:48 UTC, Johannes Loher wrote:
> auto profile_scope(string name)
> {
> import std.format : format;
> return q{import std.stdio : writeln; writeln("%1$s");
> scope(exit)
> writeln("%1$s");}.format(name);
> }
>
> void main()
> {
> mixin(profile_scope("func1"));
> }
Is there a way to achieve this while compiling with -betterC? I
use a custom string struct right now, and your version needs
TypeInfo, concatening using ~ needs the garbage collector. I have
the feeling D is really not agreeing with the way I want to do
things. If this is not possible, I will just roll with the Adam's
struct solution.
More information about the Digitalmars-d-learn
mailing list