Skip to content

[BUG] Add support for defining template specializations. #467

@leejy12

Description

@leejy12

AFAIK, there's no way to define template specializations in cppfront. I found this out when trying to define a custom std::formatter.

Here's my expected syntax.

Foo: @struct type = {
    x: i32 = 0;
}

std::formatter<Foo>: <> @struct type = {
    parse: (this, inout ctx: std::format_parse_context) -> _ = {
        return ctx.end();
    }

    format: <FormatContext> (this, foo: Foo, inout ctx: FormatContext) -> _ = {
        return std::format_to(ctx.out(), "Foo({})", foo.x);
    }
}

As of now, cppfront doesn't attempt to compile the std::formatter<Foo> part.

https://godbolt.org/z/eKd8Y9aWz

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions