[Issue 12424] New: Cannot do qualifier-overload with mixin template.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 20 04:48:47 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12424
Summary: Cannot do qualifier-overload with mixin template.
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2014-03-20 04:48:45 PDT ---
I'm trying to use a mixin template to insert const/non-const functions into my
struct. They have the same signature, save for the const qualifier.
The mixins work correctly, inserting the functions. However, the compiler
complains of conflicts, instead of recognizing a qualified-overload. The
mutable one should take precedence over the non-mutable one: That's the
standard lookup rules.
//----
mixin template fooMixin(T)
{
void foo() //L.3
{};
}
struct S
{
//insert "void foo()"
mixin fooMixin!int;
//insert "void foo() const"
const mixin fooMixin!int;
}
void main()
{
const(S) sc;
S s;
sc.foo(); //OK
s.foo(); //FAILS L.22
}
//----
main.d(22): Error: main.S.fooMixin!int.foo at main.d(3) conflicts with
main.S.fooMixin!int.foo at main.d(3)
//----
I need to use this approach, because inout doesn't actually work for me here,
as the return type depends on how "this" is qualified. See:
https://d.puremagic.com/issues/show_bug.cgi?id=12408
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list