Or maybe... This seems like a much better solution:

module program;

import std.stdio;
import std.traits;
import std.typetuple;

template SelectTrue (bool condition, T) {
  static if (condition)
    alias T SelectTrue;
}

struct Event (T...) {

  alias TypeTuple!(T,
    SelectTrue!(T.length < 1, int),
    SelectTrue!(T.length < 2, float),
  ) T2;

  void F (T2 args) {
    writeln(typeid(typeof(args)));
  }

}

void main () {

  Event!() e1;

  e1.F(5, 6);

}



On Tuesday, 2 October 2012 at 13:44:10 UTC, luka8088 wrote:

module program;

import std.stdio;
import std.traits;
import std.typetuple;

struct Event (T...) {

  alias EraseAll!(void, TypeTuple!(T,
    Select!(T.length < 1, int, void),
    Select!(T.length < 2, float, void),
  )) T2;

  void F (T2 args) {
    writeln(typeid(typeof(args)));
  }

}

void main () {

  Event!() e1;

  e1.F(5, 6);

}


On Tuesday, 2 October 2012 at 13:15:08 UTC, Manu wrote:
Is it possible?

Eg:
 struct Event(T... = (int, float))
 {
   void F(T...); // <- should default to F(int, float)
 }

Does anyone have any clever tricks that will work in this scenario? Some
magic tuple syntax?


Reply via email to