On Friday, 14 April 2017 at 08:24:00 UTC, Johannes Pfau wrote:
I've got this code duplicated in quite some functions:

---------------------
foreach (member; __traits(derivedMembers, API))
{
    // Guards against private members
static if (__traits(compiles, __traits(getMember, API, member)))
    {
static if (isSomeFunction!(__traits(getMember, API, member)) && !hasUDA!(__traits(getMember, API, member), IgnoreUDA)
                && !isSpecialFunction!member)
        {
alias overloads = MemberFunctionsTuple!(API, member);

            foreach (MethodType; overloads)
            {
                // function dependent code here
            }
        }
    }
}
--------------------

What's the idiomatic way to refactor / reuse this code fragment?

-- Johannes

The Idiomatic way would be to wrap it inside another template.

In a year or so you won't need to worry about template overhead anymore, (if I succeed that is :) )

Reply via email to