summaryrefslogtreecommitdiffstats
path: root/libcxx/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
blob: 448ffba2c2bdf5f54a52304ddf60d3161830bd59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//===----------------------------------------------------------------------===//
//
//                     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.
//
//===----------------------------------------------------------------------===//

// test bad_cast

#include <typeinfo>
#include <type_traits>
#include <cassert>

int main()
{
    static_assert((std::is_base_of<std::exception, std::bad_cast>::value),
                 "std::is_base_of<std::exception, std::bad_cast>::value");
    static_assert(std::is_polymorphic<std::bad_cast>::value,
                 "std::is_polymorphic<std::bad_cast>::value");
    std::bad_cast b;
    std::bad_cast b2 = b;
    b2 = b;
    const char* w = b2.what();
    assert(w);
}
OpenPOWER on IntegriCloud