cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

strongly typed wrappers

Open lefticus opened this issue 3 years ago • 6 comments
trafficstars

lefticus avatar Jun 23 '22 00:06 lefticus

Would want to make the tool as automagic as possible, with concepts automatically enabling requested features.

lefticus avatar Aug 01 '22 19:08 lefticus

There are a few of those wrappers available on GitHub. The first I saw was NamedType, from Jonathan Boccara (Fluent C++). I remember thinking it's neat, but also that I would have a hard time convincing coworkers of using heavy machinery involving CRTP to replace a simple built-in.

If I may self-promote: I wrote a guest post about how just wrapping a built-in in a struct, with nothing else, is already an improvement, and it's easier to convince people of using that method in my work experience. Maybe you could suggest that as a first step towards using strong types.

Edit: another thing I've come across is using an enum class with specified underlying type. This is what has been done for std::byte. Works only for integral types though.

VincentZalzal avatar Jan 13 '23 13:01 VincentZalzal