Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / optional / optional.specalg / make_optional_explicit.pass.cpp
blobe7931e07e31d17104ce171b7051cd37fbfe48ceb
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
10 // <optional>
12 // template <class T, class... Args>
13 // constexpr optional<T> make_optional(Args&&... args);
15 #include <optional>
16 #include <string>
17 #include <memory>
18 #include <cassert>
20 #include "test_macros.h"
22 int main(int, char**)
25 constexpr auto opt = std::make_optional<int>('a');
26 static_assert(*opt == int('a'));
29 std::string s = "123";
30 auto opt = std::make_optional<std::string>(s);
31 assert(*opt == "123");
34 std::unique_ptr<int> s = std::make_unique<int>(3);
35 auto opt = std::make_optional<std::unique_ptr<int>>(std::move(s));
36 assert(**opt == 3);
37 assert(s == nullptr);
40 auto opt = std::make_optional<std::string>(4u, 'X');
41 assert(*opt == "XXXX");
44 return 0;