Passing variadic template parameters AND default call site __FILE__, __LINE__ template parameters.
realhet
real_het at hotmail.com
Tue May 27 21:07:51 UTC 2025
On Tuesday, 27 May 2025 at 15:01:38 UTC, monkyyy wrote:
> On Tuesday, 27 May 2025 at 10:20:40 UTC, realhet wrote:
Hi and thanks for trying!
t2!(x) //The problem with this is the __LINE__ will point to the
alias declaration, not the pragma.
Interesting trick: template nested inside a template.
T3!(x) //This works perfectly, but the 8 alias has a really low
limit on the contents of the IES string: 3 $() blocks and it's
out of parameters. Maybe if I generate this template with a
string mixin, but I'm affraid the compiler would go crazy. I'm
planning to use it with 1000 lines of shader code and lots of
constanst injected into that with $().
Interesting tricks: alias reassignment and
templateParameterValueSpecialization (wow! It avoids the
redeclaration error I normally get.).
T4!(pack!(x)) //Unlike T3, it has no limitations but it needs an
extra work at the call site. The simplest extra work is manually
writing __FILE__,__LINE__ btw.
Interesting trick: How to pack a whole AliasSeq into a single
slot. I got to rememper this, it's so cool. template
pack(A...) { alias unpack=A; }
Final thoughts: I think the only conflict is on the language
level, as the data form __FILE__ and __LINE__ are always
accessible inside the compiler. But maybe in the future there
will be a __traits for this. And also for __COLUMN__. But I
also understand that these simple looking things are super
complicated inside the compiler.
Thx for the template tricks!
More information about the Digitalmars-d-learn
mailing list