bearophile <[email protected]> wrote:

I have seen this bug report:
http://d.puremagic.com/issues/show_bug.cgi?id=4224

Do you know any way to make the following code work? It can be useful,
especially once the int type can be replaced with a good variant type:


struct A {
  int[string] table;

  auto opDispatch( string name, T... )( T args ) {
    static if ( T.length == 0 ) {
      return table[s];
    } else if ( T.length == 1 ) {
      table[ name ] = args[0];
    } else {
      static assert( false, "Wrong parameter count to opDispatch" );
    }
  }
}

You could factor out the static ifs to template constraints, if you
wish.

--
Simen

Reply via email to