ReflectName

Attribute to rename methods, types and functions

  1. template ReflectName(string target)
    template ReflectName (
    string target
    ) {}
  2. template reflectName(string target = null, Args...)

Members

Structs

ReflectName
struct ReflectName(Args...)

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