enum of tuples
Van de Bugger
van.de.bugger at gmail.com
Wed Sep 26 13:12:28 PDT 2012
Hi,
I faced a little trouble and can not decide if it is a my
mistake, a bug in std library or in compiler…
Look:
$ cat enum_of_structs.d
struct T {
int v;
int opCmp( T rhs ) { return v == rhs.v ? 0 : ( v < rhs.v ? -1 :
+1 ); };
};
enum E : T {
A = T( 1 ),
B = T( 2 ),
};
$ dmd -c -w enum_of_structs.d
Output is empty — there is no warnings and/or errors.
In the next example I decide to use std.typecons module instead
of declaring struct manually:
$ cat enum_of_tuples.d
import std.typecons;
alias Tuple!( int, "v" ) T;
enum E : T {
A = T( 1 ),
B = T( 2 ),
};
$ dmd -c -w enum_of_tuples.d
enum_of_tuples.d(5): Error: template
std.typecons.Tuple!(int,"v").Tuple.opCmp does not match any
function template declaration
/usr/include/d/dmd/phobos/std/typecons.d(423): Error: template
std.typecons.Tuple!(int,"v").Tuple.opCmp(R) if (isTuple!(R))
cannot deduce template function from argument types !()(E)
enum_of_tuples.d(5): Error: template
std.typecons.Tuple!(int,"v").Tuple.opCmp does not match any
function template declaration
/usr/include/d/dmd/phobos/std/typecons.d(423): Error: template
std.typecons.Tuple!(int,"v").Tuple.opCmp(R) if (isTuple!(R))
cannot deduce template function from argument types !()(E)
Oops. What the problem?
More information about the Digitalmars-d-learn
mailing list