On Wednesday, 7 December 2016 at 17:32:14 UTC, Alex wrote:
enum hasRun(T) = __traits(hasMember, T, "run");
This is strange... I expect this to work... but it does not...
hasRun there ONLY takes types, whereas T... can take types,
values, aliases, etc.
Try making it hasRun(T...) and
On Wednesday, 7 December 2016 at 17:05:11 UTC, H. S. Teoh wrote:
Try this:
import std.meta : allSatisfy;
enum hasRun(T) = __traits(hasMember, T, "run");
mixin template S(T...)
if (allSatisfy!(hasRun, T))
{
void run()
{
On Wednesday, 7 December 2016 at 17:08:09 UTC, Gary Willoughby
wrote:
Will some like this work?
import std.range.primitives;
mixin template S(T...) if(__traits(hasMember,
ElementType!(T), "run"))
{
...
}
https://dlang.org/phobos/std_range_primitives.html#ElementType
On Wed, Dec 07, 2016 at 04:35:52PM +, Alex via Digitalmars-d-learn wrote:
> Hi people,
> have searched the history, but didn't find something similar:
>
> say I have a template like
>
> mixin template S(T...)
> {
> void run()
> {
> foreach(s; T)
> {
> stati
On Wednesday, 7 December 2016 at 16:35:52 UTC, Alex wrote:
mixin template S(T...)
{
void run()
{
foreach(s; T)
{
static assert(__traits(hasMember, s, "run"));
}
}
}
How to formulate the check inside the foreach as a template
constraint with
mixin
On Wednesday, 7 December 2016 at 16:48:08 UTC, Adam D. Ruppe
wrote:
On Wednesday, 7 December 2016 at 16:35:52 UTC, Alex wrote:
void run()
{
foreach(s; T)
{
static assert(__traits(hasMember, s, "run"));
}
}
Just put that in a function:
bool test(
On Wednesday, 7 December 2016 at 16:35:52 UTC, Alex wrote:
void run()
{
foreach(s; T)
{
static assert(__traits(hasMember, s, "run"));
}
}
Just put that in a function:
bool test(T...)() {
foreach(s; T)
if(!__traits(hasMember, s, "run"))
Hi people,
have searched the history, but didn't find something similar:
say I have a template like
mixin template S(T...)
{
void run()
{
foreach(s; T)
{
static assert(__traits(hasMember, s, "run"));
}
}
}
How to formulate the check inside the for