diff options
| author | Casey Carter <Casey@Carter.net> | 2017-06-06 18:47:26 +0000 |
|---|---|---|
| committer | Casey Carter <Casey@Carter.net> | 2017-06-06 18:47:26 +0000 |
| commit | dd7c68bc7867adabc34bfe07c1a85c4cb955e088 (patch) | |
| tree | 7598557a081a20f7ce35907d582210ae160c7343 /libcxx/test/std | |
| parent | 1e2b87893bf22194a4b5e55f0eb28b89cd86339f (diff) | |
| download | bcm5719-llvm-dd7c68bc7867adabc34bfe07c1a85c4cb955e088.tar.gz bcm5719-llvm-dd7c68bc7867adabc34bfe07c1a85c4cb955e088.zip | |
add missing constexpr to optional::value_or
[Credit to cpplearner]
Differential Revision: https://reviews.llvm.org/D27850
llvm-svn: 304813
Diffstat (limited to 'libcxx/test/std')
| -rw-r--r-- | libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp index c219e970471..f94dcabde51 100644 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // <optional> -// template <class U> T optional<T>::value_or(U&& v) &&; +// template <class U> constexpr T optional<T>::value_or(U&& v) &&; #include <optional> #include <type_traits> @@ -26,22 +26,22 @@ struct Y { int i_; - Y(int i) : i_(i) {} + constexpr Y(int i) : i_(i) {} }; struct X { int i_; - X(int i) : i_(i) {} - X(X&& x) : i_(x.i_) {x.i_ = 0;} - X(const Y& y) : i_(y.i_) {} - X(Y&& y) : i_(y.i_+1) {} + constexpr X(int i) : i_(i) {} + constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;} + constexpr X(const Y& y) : i_(y.i_) {} + constexpr X(Y&& y) : i_(y.i_+1) {} friend constexpr bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} }; -int main() +constexpr int test() { { optional<X> opt(in_place, 2); @@ -65,4 +65,10 @@ int main() assert(std::move(opt).value_or(Y(3)) == 4); assert(!opt); } + return 0; +} + +int main() +{ + static_assert(test() == 0); } |

