| Thread overview | |||||
|---|---|---|---|---|---|
|
August 01, 2015 Import template in phobos | ||||
|---|---|---|---|---|
| ||||
Exist in phobos something like Import template?
public import std.traits;
template Import(alias Module){
mixin("import " ~ moduleName!Module ~ ";");
}
class C;
struct Test{
Import!(std.typecons).Rebindable!C test; //symbols
}
| ||||
August 01, 2015 Re: Import template in phobos | ||||
|---|---|---|---|---|
| ||||
Posted in reply to vit | On Saturday, 1 August 2015 at 14:42:47 UTC, vit wrote:
> Exist in phobos something like Import template?
What would you use that for? You can just use the import keyword...
| |||
August 01, 2015 Re: Import template in phobos | ||||
|---|---|---|---|---|
| ||||
Posted in reply to vit | On Saturday, 1 August 2015 at 14:42:47 UTC, vit wrote: > Exist in phobos something like Import template? > > public import std.traits; > > template Import(alias Module){ > mixin("import " ~ moduleName!Module ~ ";"); > } > > class C; > > struct Test{ > Import!(std.typecons).Rebindable!C test; //symbols > } Not very clear. from your '//symbols' comment I deduce that you want to turn a template into a local symbol. To do so use an 'alias expression': --- import std.typecons: Rebindable; alias symbolIdentifier = Rebindable!C; --- see http://dlang.org/declaration.html#alias for full spec. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply