1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 #include <type_traits>
20 static_assert((std::is_base_of<std::exception, std::runtime_error>::value),
21 "std::is_base_of<std::exception, std::runtime_error>::value");
22 static_assert(std::is_polymorphic<std::runtime_error>::value,
23 "std::is_polymorphic<std::runtime_error>::value");
25 const char* msg = "runtime_error message";
26 std::runtime_error e(msg);
27 assert(std::strcmp(e.what(), msg) == 0);
28 std::runtime_error e2(e);
29 assert(std::strcmp(e2.what(), msg) == 0);
31 assert(std::strcmp(e2.what(), msg) == 0);
34 std::string msg("another runtime_error message");
35 std::runtime_error e(msg);
36 assert(e.what() == msg);
37 std::runtime_error e2(e);
38 assert(e2.what() == msg);
40 assert(e2.what() == msg);