Bug 11158 – __MODULE__ as default template parameter doesn't use the instantiating module
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-02T11:09:00Z
Last change time
2013-10-02T19:07:11Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2013-10-02T11:09:36Z
cat > buga.d << CODE
struct Uniq(string name, string mod=__MODULE__)
{
pragma(msg, name, mod);
string toString() { return mod~"."~name; }
}
CODE
cat > bug.d << CODE
import buga;
alias UniqFoo = Uniq!("foo");
CODE
dmd -c bug;
----
As with __FILE__ or __LINE__ they should be used from the instantiating module.
This allows to generically implement somewhat unique types and is useful for printing additional information.
Comment #1 by andrej.mitrovich — 2013-10-02T19:07:11Z