CategoryName

Provides string representations of the category of a symbol, where such is not a fundamental primitive variable but a module, a function, a delegate, a class or a struct.

Accurate module detection only works on compilers 2.087 and later, due to missing support for __traits(isModule).

template CategoryName (
alias sym
) {}

Members

Imports

fullyQualifiedName (from std.traits)
public import std.traits : isDelegate, isFunction, fullyQualifiedName;
Undocumented in source.
isDelegate (from std.traits)
public import std.traits : isDelegate, isFunction, fullyQualifiedName;
Undocumented in source.
isFunction (from std.traits)
public import std.traits : isDelegate, isFunction, fullyQualifiedName;
Undocumented in source.

Manifest constants

fqn
enum fqn;

The fully qualified name for the symbol sym is an alias of.

name
enum name;

A short name for the symbol sym is an alias of.

type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.
type
enum type;
Undocumented in source.

Parameters

sym

Symbol to provide the strings for.

Examples

module foo;

void bar() {}

alias categoryName = CategoryName!bar;

assert(categoryName.type == "function");
assert(categoryName.name == "bar");
assert(categoryName.fqn == "foo.bar");
bool localSymbol;

void fn() {}

auto dg = () => localSymbol;

class C {}
C c;

struct S {}
S s;

interface I {}

union U
{
    int i;
    bool b;
}

U u;

alias Ffn = CategoryName!fn;
static assert(Ffn.type == "function");
static assert(Ffn.name == "fn");
// Can't test fqn from inside a unittest

alias Fdg = CategoryName!dg;
static assert(Fdg.type == "delegate");
static assert(Fdg.name == "dg");
// Ditto

alias Fc = CategoryName!c;
static assert(Fc.type == "class");
static assert(Fc.name == "c");
// Ditto

alias Fs = CategoryName!s;
static assert(Fs.type == "struct");
static assert(Fs.name == "s");

alias Fm = CategoryName!(lu.traits);
static assert(Fm.type == "module");
static assert(Fm.name == "traits");
static assert(Fm.fqn == "lu.traits");

alias Fi = CategoryName!I;
static assert(Fi.type == "interface");
static assert(Fi.name == "I");

alias Fu = CategoryName!u;
static assert(Fu.type == "union");
static assert(Fu.name == "u");

Meta