reflectName

Attribute to rename methods, types and functions

template reflectName(string target = null, Args...)
reflectName
(
string name
)

Members

Functions

reflectName
auto reflectName(string name)

Examples

enum E { A, B, C }

struct S
{
    @reflectName("A")
    int a;

    @reflectName!"c++"("B")
    int b;

    @reflectName!("C",  double)("cd")
    @reflectName!("C",  float)("cf")
    F c(F)()
    {
        return b;
    }
}

import std.traits: hasUDA;

alias UniName = ReflectName!null;
alias CppName = ReflectName!"c++";
alias CName = ReflectName!"C";

static assert(hasUDA!(S.a, UniName!()("A")));
static assert(hasUDA!(S.b, CppName!()("B")));

// static assert(hasUDA!(S.c, ReflectName)); // doesn't work for now
static assert(hasUDA!(S.c, CName));
static assert(hasUDA!(S.c, CName!double));
static assert(hasUDA!(S.c, CName!float));
static assert(hasUDA!(S.c, CName!double("cd")));
static assert(hasUDA!(S.c, CName!float("cf")));

Meta