google / google/filament

FR: constexpr std::string_view to_string methods for all public enums, for debug-printing

Open
#9,979 0 comments 0 reactions 1 assignee Claimed by @pixelflinger View on GitHub
Dominant language
C++
Stars
20.5k
Forks
2.3k
Avg merge
2d 14h
Merged PRs (30d)
83

Description

Filament has many public enums. It's natural to want to print these out for debuggers, printf statements, and heck, even for AI agents.

Today, some enums have to_string methods. And some don't. The ones that don't, end up getting duplicate to_string methods in libraries that call Filament. These duplicates get out of sync with the enum definitions over time. That's bad. We'd be better off to put the to_string function inside filament itself, next to the enum.

There are some code size increase costs, but I hope that compilers should be able to find and strip dead code and constants.

On https://github.com/google/filament/pull/9975#issuecomment-4422286831, which proposes one such to_string method, @romainguy says

> It would make more sense to do this consistently for all public enums

I agree, let's file this ticket to track.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.