copy_assign.pass.cpp revision 01afa5c6e407e985d9643707d7b7ab1384bd9317
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// <optional> 11 12// class bad_optional_access; 13// bad_optional_access& operator=(const bad_optional_access&); 14 15#include <optional> 16#include <string> 17#include <cstring> 18#include <type_traits> 19#include <cassert> 20 21#if _LIBCPP_STD_VER > 11 22 23#endif // _LIBCPP_STD_VER > 11 24 25int main() 26{ 27#if _LIBCPP_STD_VER > 11 28 static_assert(std::is_nothrow_copy_assignable<std::bad_optional_access>::value, ""); 29 const std::string s1("one message"); 30 const std::string s2("another message"); 31 std::bad_optional_access e1(s1); 32 std::bad_optional_access e2(s2); 33 assert(std::strcmp(e1.what(), e2.what()) != 0); 34 e1 = e2; 35 assert(std::strcmp(e1.what(), e2.what()) == 0); 36#endif // _LIBCPP_STD_VER > 11 37} 38