[Issue 9324] New: Can't assign type to Tuple with a Tuple subtype
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 15 18:37:32 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9324
Summary: Can't assign type to Tuple with a Tuple subtype
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-15 18:37:31 PST ---
import std.string;
import std.typecons;
struct MyTuple(T...)
{
this(T args)
{
tup = Tuple!T(args);
}
void opAssign(Tuple!T args)
{
this.tup = args;
}
Tuple!T tup;
alias tup this;
}
void main()
{
MyTuple!(string, int) x;
x = tuple("foo", 1); // ok
Tuple!(string, int) y;
y = x; // fail
}
test.d(28): Error: template std.typecons.Tuple!(string, int).Tuple.opAssign
does not match any function template declaration.
isTuple check fails on MyTuple even though it has a Tuple subtype. But why?
isTuple implementation:
template isTuple(T)
{
static if (is(Unqual!T Unused : Tuple!Specs, Specs...))
{
enum isTuple = true;
}
else
{
enum isTuple = false;
}
}
It seems to me like we need some way of determining if type 'A' has subtype
'B'. I don't think we have a trait or Phobos function to do it, perhaps we
should introduce something like this?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list