On Tue, Aug 7, 2012 at 12:42 PM, Zhenya <[email protected]> wrote:
>> Template alias parameters do not accept built-in types.
The trick is:
- A template type parameter (like (T)) recognizes types
- A template alias parameter(like (alias a)) recognizes names, symbols.
A built-in type is 'purely' a type. It's a keyword, and hence it's not
a symbol ('int' cannot be a D identifier)
A user-defined type is *both* a type and a symbol (because it has a name)
So, given:
class C {}
template isType(T) { ... }
template isName(alias name) { ... }
then
isType!int => accepted
isType!C => accepted
isName!int => not accepted
isName!C => accepted
which also means you can design a template that accepts
- only built-in types
- only user-defined types
- both
- neither (with other template parameters...)