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 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++98, c++03, c++11, c++14 10 // <optional> 11 12 // constexpr optional(const optional<T>&& rhs); 13 // If is_trivially_move_constructible_v<T> is true, 14 // this constructor shall be a constexpr constructor. 15 16 #include <optional> 17 #include <type_traits> 18 #include <cassert> 19 20 #include "test_macros.h" 21 22 struct S { 23 constexpr S() : v_(0) {} 24 S(int v) : v_(v) {} 25 constexpr S(const S &rhs) : v_(rhs.v_) {} // not trivially moveable 26 constexpr S(const S &&rhs) : v_(rhs.v_) {} // not trivially moveable 27 int v_; 28 }; 29 30 31 int main(int, char**) 32 { 33 static_assert (!std::is_trivially_move_constructible_v<S>, "" ); 34 constexpr std::optional<S> o1; 35 constexpr std::optional<S> o2 = std::move(o1); // not constexpr 36 37 return 0; 38 } 39