1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03, c++11, c++14 11 12 // <optional> 13 14 // optional(optional<T>&& rhs); 15 16 #include <optional> 17 #include <string> 18 #include <type_traits> 19 #include <utility> 20 21 using std::optional; 22 23 struct X {}; 24 25 struct Y 26 { 27 Y() = default; YY28 Y(Y&&) {} 29 }; 30 31 struct Z 32 { 33 Z() = default; 34 Z(Z&&) = delete; 35 Z(const Z&) = delete; 36 Z& operator=(Z&&) = delete; 37 Z& operator=(const Z&) = delete; 38 }; 39 main()40int main() 41 { 42 { 43 using T = int; 44 static_assert((std::is_trivially_copy_constructible<optional<T>>::value), ""); 45 constexpr optional<T> opt; 46 constexpr optional<T> opt2 = std::move(opt); 47 (void)opt2; 48 } 49 { 50 using T = X; 51 static_assert((std::is_trivially_copy_constructible<optional<T>>::value), ""); 52 constexpr optional<T> opt; 53 constexpr optional<T> opt2 = std::move(opt); 54 (void)opt2; 55 } 56 static_assert(!(std::is_trivially_move_constructible<optional<Y>>::value), ""); 57 static_assert(!(std::is_trivially_move_constructible<optional<std::string>>::value), ""); 58 59 static_assert(!(std::is_move_constructible<optional<Z>>::value), ""); 60 } 61