//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template optional& operator=(U&& v); #include #include #include #include #if _LIBCPP_STD_VER > 11 using std::experimental::optional; struct X { }; #endif // _LIBCPP_STD_VER > 11 int main() { #if _LIBCPP_STD_VER > 11 static_assert(std::is_assignable, int>::value, ""); static_assert(std::is_assignable, int&>::value, ""); static_assert(std::is_assignable&, int>::value, ""); static_assert(std::is_assignable&, int&>::value, ""); static_assert(std::is_assignable&, const int&>::value, ""); static_assert(!std::is_assignable&, const int&>::value, ""); static_assert(!std::is_assignable, X>::value, ""); { optional opt; opt = 1; assert(static_cast(opt) == true); assert(*opt == 1); } { optional opt; const int i = 2; opt = i; assert(static_cast(opt) == true); assert(*opt == i); } { optional opt(3); const int i = 2; opt = i; assert(static_cast(opt) == true); assert(*opt == i); } { optional> opt; opt = std::unique_ptr(new int(3)); assert(static_cast(opt) == true); assert(**opt == 3); } { optional> opt(std::unique_ptr(new int(2))); opt = std::unique_ptr(new int(3)); assert(static_cast(opt) == true); assert(**opt == 3); } #endif // _LIBCPP_STD_VER > 11 }