[llvm-dev] RFC: Strong typedef for LLVM

David Greene via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 5 08:29:38 PDT 2019


Nevin Liber via llvm-dev <llvm-dev at lists.llvm.org> writes:

> I'm generally a fan of using the type system to encapsulate this kind of thing.  A few points:
>
> * Why no move assignment operator?

It's a sketch.  :)  The actual code will have a lot more.

> * swap has the wrong noexcept specification.

Noted, thanks.

> * In my experience, most of these types end up being equality
> comparable and hashable.  I understand that equality comparison is
> separate concern which can be provided by mixins, but the more
> boilerplate that is required to use it, the less likely people are to
> adopt it.  This could, of course, be constrained on whether or not the
> BaseType supports these operations.

Let's talk about this in the design review when I post the patch.  I'll
definitely add you as a reviewer.

> * Similar argument about using CRTP, as it requires more boilerplate
> (the using StrongTypedef::StrongTypedef; statement to bring in the
> converting constructor).

Ditto above, though without CRTP operator overloading becomes less
convenient.

> * Not a fan of the name StrongTypedef (or OpaqueTypedef) either.  If
> the C++ standard ever acquires related functionality, there will end
> up being a conceptual mismatch.

What about "ExplicitWrapper?"  Let's talk more when the patch is posted.

Thanks for your helpful feedback!

                       -David


More information about the llvm-dev mailing list