[PATCH] D69230: RFC: specialized Optional<T> for T that can represent its own invalid state

Lawrence D'Anna via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 17:29:56 PDT 2019


lawrence_danna added a comment.

In D69230#1717364 <https://reviews.llvm.org/D69230#1717364>, @labath wrote:

>




> The thing I would like to see here is to have this behaviour be configurable via a traits argument of the Optional class, similarly to how DenseMap allows the type to specify default traits by specialising DenseMapInfo (I recommend taking a look at that for inspiration/consistency),

So that would mean actually adding the Info class as a template parameter to Optional, right?   It looks like that would be quite disruptive, as there's other headers that predeclare Optional as taking only a single template parameter.

I'm not sure I understand what the advantage of having that extra level of customization would be.    Are there situations where `OptionalInfo<Foo>`  is specialized  in `Foo.h`, but some other code is going to want to use its own Info struct to customize `Foo` optionals?    I can see how you'd want that for maps, because different code has different requirements for their maps, even with the same key types.   But it seems like for Optionals there's probably one right way to make an `Optional<T>` for each `T`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69230/new/

https://reviews.llvm.org/D69230





More information about the llvm-commits mailing list