Skip to content

Implicit conversion for template-less usage #14

@schveiguy

Description

@schveiguy

Well, not exactly template-less usage, but for usage with a non-template function.

e.g.:

struct IHead { // name TBD
    string[] interpolated; // optional, maybe we don't even need this?
}

struct InterpolationHeader(_parts...) {
    alias parts = _parts;
    string toString() { return null; }
    IHead __noTemplate()() {
        static immutable parts = [_parts];
        return IHead(parts);
    }
    alias __noTemplate this;
}

Now, one can write a function that takes an interpolation header without using templates:

void foo(IHead header, ...) {
    ...
}

You still get the information from the header, you still get the strings as passed, but don't have to define it using a template parameter. It also might clean up some templated usage:

void foo(T...)(IHead header, T params) {
    ...
}

This is for code which might not have a need to use the header at compile-time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions