copy_ctor.pass.cpp revision 0cdbe6048173c1f05628dbc85430acf191a3e173
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(const bad_optional_access&);
14
15#include <experimental/optional>
16#include <string>
17#include <cstring>
18#include <type_traits>
19#include <cassert>
20
21int main()
22{
23#if _LIBCPP_STD_VER > 11
24    using std::experimental::bad_optional_access;
25
26    static_assert(std::is_nothrow_copy_constructible<bad_optional_access>::value, "");
27    const std::string s("another message");
28    bad_optional_access e1(s);
29    bad_optional_access e2 = e1;
30    assert(std::strcmp(e1.what(), e2.what()) == 0);
31#endif  // _LIBCPP_STD_VER > 11
32}
33