1 // { dg-options "-std=gnu++20" }
2 // { dg-do compile { target c++20 } }
3 
4 #include <optional>
5 #include <testsuite_hooks.h>
6 
7 constexpr bool
test_cons()8 test_cons()
9 {
10   std::optional<int> oi(1);
11   std::optional<long> ol(oi);
12   VERIFY( *ol == 1L );
13   VERIFY( *oi == 1 );
14 
15   std::optional<unsigned> ou(std::move(oi));
16   VERIFY( *ou == 1u );
17   VERIFY( oi.has_value() && *oi == 1 );
18 
19   return true;
20 }
21 
22 static_assert( test_cons() );
23