Le 05/08/2012 14:38, Christophe Travert a écrit :
Jonathan M Davis , dans le message (digitalmars.D:174267), a écrit :
On Saturday, August 04, 2012 15:22:34 Jonathan M Davis wrote:
On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote:
T fun(T)(T arg) if(isSomeString!arg){

      return arg~arg[0];

}

IMO, the behavior should be this: when trying to call the template with
a argument that is an enum type based on string, the compiler should try
to instanciate the template for this enum type, and isSomeString should
fail. Then, the the compiler will try to instanciate the template for
strings, which works. Thus, the template is called with a string
argument, which is the enum converted to a string.


With multiple template parameter, it becomes a nightmare for the compiler.

The example above is easily solved using auto for return type inference instead of specifying it.

Reply via email to