Add Optional::value_or
authorTudor Bosman <tudorb@fb.com>
Sat, 16 Aug 2014 22:09:20 +0000 (15:09 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Sep 2014 21:22:22 +0000 (14:22 -0700)
commit65902504332d7f856a1fa407b0930ab5cc55fb2a
treed33d3073b4e324464b4e019c9c5d8b0aa9890dbe
parent32a19232b18c348096f980a64805d1641deec630
Add Optional::value_or

Summary:
Common pattern: a function returns Optional<X>, indicating whether some X was
present or not; you want a default value if the X was not present. Requires
that X is copiable.

Test Plan: optional_test (test added)

Reviewed By: tjackson@fb.com

Subscribers: aalexandre, fjargsto, jhj, ntv, lesha, kma

FB internal diff: D1502397
folly/Optional.h
folly/test/OptionalTest.cpp