Add getValueOr to llvm::Optional<T>.
authorJordan Rose <jordan_rose@apple.com>
Mon, 29 Sep 2014 18:56:08 +0000 (18:56 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 29 Sep 2014 18:56:08 +0000 (18:56 +0000)
commit88c0ed30da6937146ffdcbc880053ba6ceacebbb
tree7af704c03e20df8e51c6e4973aae508d504a5874
parentede14e3e21b528ca4a69c07d9e220db3057e2392
Add getValueOr to llvm::Optional<T>.

This takes a single argument convertible to T, and
- if the Optional has a value, returns the existing value,
- otherwise, constructs a T from the argument and returns that.

Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218618 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/Optional.h
unittests/ADT/OptionalTest.cpp