What about an identifier that is an mixin
ag0aep6g via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jan 16 03:08:03 PST 2017
On 01/16/2017 08:52 AM, Bauss wrote:
> On Friday, 13 January 2017 at 21:32:49 UTC, Daniel Kozák wrote:
[...]
>> there is no difference between template and mixin template
>
> That's not true.
>
> Templates do not carry context with them, they only have their own scope
> available.
>
> Where as mixin templates can access every member that is in their scope.
>
> Consider:
>
> template SetXCTFE_Template(int value) {
> void SetXCTFE_Template() {
> x = value;
> }
> }
>
> mixin template SetXCTFE_Mixin_Template(int value) {
> void handle() {
> x = value;
> }
> }
>
> void main() {
> int x;
>
> x = SetXCTFE_Template!10; // Not ok ...
>
> mixin SetXCTFE_Mixin_Template!10; // ok ...
> handle(); // ok ...
> }
The point is that you can mix in non-mixin templates just fine:
mixin SetXCTFE_Template!10; // ok
In that regard, templates and mixin templates behave the same. The
difference between them is that you can't instantiate a mixin template
without `mixin`.
More information about the Digitalmars-d
mailing list