[PATCH] Add a forwarding variadic constructor to llvm::Optional<T>.

David Blaikie dblaikie at gmail.com
Mon Sep 29 15:15:49 PDT 2014


Any idea if this has been discussed in the C++ standards committee proposal? (be good to know if it was considered & rejected, and if so why)

one thing that might be confusing would be:

  Optional<T> func() {
    return {};
  }

Does your implementation have trouble with copying a volatile Optional<T>, perhaps? (you've accounted for const/non-const, but not necessarily volatile/non-volatile) I suspect, if we're going for this, the right thing to do is to SFINAE the whole varargs ctor to ensure it's only available when the T is constructible (and, to be precise, /implicitly/ constructible) from the args. This way it won't accidentally steal away Optional(Optional) constructions, etc.

But as with another patch - I'd be concerned that this is just an in-tree trap, since the implementation isn't portable to MSVC, so no in-tree code could realistically use this.

http://reviews.llvm.org/D5511






More information about the llvm-commits mailing list