On Saturday, 22 December 2018 at 10:11:23 UTC, bauss wrote:
On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote:
Awesome hack!
Being a hack, it would be even nicer if it worked ouf of the
box:
mixin template foo(bool b)
{
int _impl() { writeln(b); return int.init; }
On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote:
Awesome hack!
Being a hack, it would be even nicer if it worked ouf of the
box:
mixin template foo(bool b)
{
int _impl() { writeln(b); return int.init; }
int _ipml2 = _impl();
}
vs
mixin template f
On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote:
On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh
wrote:
On Wed, 19 Dec 2018 15:12:14 +, bauss wrote:
Or while instantiating it:
mixin template foo()
{
int _ignoreme()
{
if (readln.strip == "abort") throw new
On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote:
On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh
wrote:
On Wed, 19 Dec 2018 15:12:14 +, bauss wrote:
Or while instantiating it:
mixin template foo()
{
int _ignoreme()
{
if (readln.strip == "abort") throw new
On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh
wrote:
On Wed, 19 Dec 2018 15:12:14 +, bauss wrote:
Or while instantiating it:
mixin template foo()
{
int _ignoreme()
{
if (readln.strip == "abort") throw new AbortException;
return 1;
}
int _alsoIgnoreMe = _ignor
On Thursday, 20 December 2018 at 16:23:39 UTC, H. S. Teoh wrote:
On Thu, Dec 20, 2018 at 11:04:19AM +, bauss via
Digitalmars-d-learn wrote:
On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh
wrote:
[...]
> mixin template foo()
> {
> int _ignoreme()
> {
> if (readln.stri
On Thursday, 20 December 2018 at 16:23:39 UTC, H. S. Teoh wrote:
On Thu, Dec 20, 2018 at 11:04:19AM +, bauss via
Digitalmars-d-learn wrote:
[...]
[...]
[...]
Me too! This is awesome! This basically lets you insert
arbitrary code via mixin templates with essentially no
restrictions!
On Thu, Dec 20, 2018 at 11:04:19AM +, bauss via Digitalmars-d-learn wrote:
> On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh wrote:
[...]
> > mixin template foo()
> > {
> > int _ignoreme()
> > {
> > if (readln.strip == "abort") throw new AbortException;
> > return 1;
On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh
wrote:
On Wed, 19 Dec 2018 15:12:14 +, bauss wrote:
That's assuming that it's compile-time data though.
If not then you can't do what you want to do.
What you can do is wrap it in a function in the mixin template
which you jus
On Wed, 19 Dec 2018 15:12:14 +, bauss wrote:
> That's assuming that it's compile-time data though.
>
> If not then you can't do what you want to do.
>
> What you can do is wrap it in a function in the mixin template which you
> just call after instantiating it.
Or while instantiating it:
mi
to compile it, I get:
Error: declaration expected, not if
Is it possible to mixin operator 'if' directly inside my
template mixin?
What you want to use is "static if".
The correct way to do the above would be this:
mixin template create(alias input, uint index, alia
it possible to mixin operator 'if' directly inside my
template mixin?
What you want to use is "static if".
The correct way to do the above would be this:
mixin template create(alias input, uint index, alias data)
{
static if(input.length >= in
Mixin templates don't work on statements only declarations like structs.
Hi,
Here is a template mixin:
mixin template create(alias input, uint index, alias data)
{
if(input.length < index) return;
// ... some code
}
When I try to compile it, I get:
Error: declaration expected, not if
Is it possible to mixin operator 'if' directly insid
14 matches
Mail list logo