template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
constexpr const void* __get_fallback_typeid() {
- return &__unique_typeinfo<decay_t<_Tp>>::__id;
+ return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
}
template <class _Tp>
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = ^(int x) { return x + 1; };
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(*f1.target<int(*)(int)>() == g);
- assert(*f2.target<int(^)(int)>() != 0);
+ RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+ RTTI_ASSERT(*f2.target<int(^)(int)>() != 0);
swap(f1, f2);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(*f1.target<int(^)(int)>() != 0);
- assert(*f2.target<int(*)(int)>() == g);
+ RTTI_ASSERT(*f1.target<int(^)(int)>() != 0);
+ RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
}
// operator bool
std::function<int(int)> f2 = ^(int x) { return x + 1; };
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f1.target<A>()->id() == 999);
- assert((*f2.target<int(^)(int)>())(13) == 14);
+ RTTI_ASSERT(f1.target<A>()->id() == 999);
+ RTTI_ASSERT((*f2.target<int(^)(int)>())(13) == 14);
f1.swap(f2);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert((*f1.target<int(^)(int)>())(13) == 14);
- assert(f2.target<A>()->id() == 999);
+ RTTI_ASSERT((*f1.target<int(^)(int)>())(13) == 14);
+ RTTI_ASSERT(f2.target<A>()->id() == 999);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A::count == 0);
{
int (^block)(int) = Block_copy(^(int x) { return x + 1; });
std::function<int(int)> f = block;
- assert(*f.target<int(^)(int)>() == block);
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(*f.target<int(^)(int)>() == block);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
Block_release(block);
}
// target_type
{
std::function<int(int)> f = ^(int x) { return x + 1; };
- assert(f.target_type() == typeid(int(^)(int)));
+ RTTI_ASSERT(f.target_type() == typeid(int(^)(int)));
}
return 0;
int main(int, char**)
{
A::global = A();
- assert(A::global.target<A>());
+ RTTI_ASSERT(A::global.target<A>());
// Check that we don't recurse in A::~A().
A::cancel = true;
A::global = std::function<void()>(nullptr);
- assert(!A::global.target<A>());
+ RTTI_ASSERT(!A::global.target<A>());
return 0;
}
int main(int, char**)
{
A::global = A();
- assert(A::global.target<A>());
+ RTTI_ASSERT(A::global.target<A>());
// Check that we don't recurse in A::~A().
A::cancel = true;
A::global = nullptr;
- assert(!A::global.target<A>());
+ RTTI_ASSERT(!A::global.target<A>());
return 0;
}
// test type_info
+// UNSUPPORTED: -fno-rtti
+
#include <typeinfo>
#include <string>
#include <cstring>
// test type_info
+// UNSUPPORTED: -fno-rtti
+
#include <typeinfo>
#include <cstring>
#include <cassert>
void test_cast_array() {
int arr[3];
std::any a(arr);
- assert(a.type() == typeid(int*)); // contained value is decayed
-// We can't get an array out
+ RTTI_ASSERT(a.type() == typeid(int*)); // contained value is decayed
+ // We can't get an array out
int (*p)[3] = std::any_cast<int[3]>(&a);
assert(p == nullptr);
}
#endif
assert(A::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f1.target<A>()->id() == 1);
- assert(f2.target<A>()->id() == 2);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(f2.target<A>()->id() == 2);
swap(f1, f2);
assert(A::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f1.target<A>()->id() == 2);
- assert(f2.target<A>()->id() == 1);
+ RTTI_ASSERT(f1.target<A>()->id() == 2);
+ RTTI_ASSERT(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
#endif
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f1.target<A>()->id() == 1);
- assert(*f2.target<int(*)(int)>() == g);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
swap(f1, f2);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(*f1.target<int(*)(int)>() == g);
- assert(f2.target<A>()->id() == 1);
+ RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+ RTTI_ASSERT(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
#endif
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(*f1.target<int(*)(int)>() == g);
- assert(f2.target<A>()->id() == 1);
+ RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+ RTTI_ASSERT(f2.target<A>()->id() == 1);
swap(f1, f2);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f1.target<A>()->id() == 1);
- assert(*f2.target<int(*)(int)>() == g);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
#endif
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(*f1.target<int(*)(int)>() == g);
- assert(*f2.target<int(*)(int)>() == h);
+ RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+ RTTI_ASSERT(*f2.target<int(*)(int)>() == h);
swap(f1, f2);
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(*f1.target<int(*)(int)>() == h);
- assert(*f2.target<int(*)(int)>() == g);
+ RTTI_ASSERT(*f1.target<int(*)(int)>() == h);
+ RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>());
+ RTTI_ASSERT(f.target<A>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = (int (*)(int))0;
assert(!f);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f = &A::foo;
assert(f);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (A::*)(int) const>() != 0);
+ RTTI_ASSERT(f.target<int (A::*)(int) const>() != 0);
}
{
std::function<void(int)> f(&g);
assert(f);
- assert(f.target<int(*)(int)>() != 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() != 0);
f(1);
}
{
f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
std::function<int(int)> f;
f = g;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>());
+ RTTI_ASSERT(f.target<A>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
f = (int (*)(int))0;
assert(!f);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f;
f = &A::foo;
assert(f);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (A::*)(int) const>() != 0);
+ RTTI_ASSERT(f.target<int (A::*)(int) const>() != 0);
}
{
std::function<void(int)> f;
f = &g;
assert(f);
- assert(f.target<int(*)(int)>() != 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() != 0);
f(1);
}
#if TEST_STD_VER >= 11
{ // Check that the null value is detected
TestFn tf = nullptr;
std::function<Fn> f = tf;
- assert(f.template target<TestFn>() == nullptr);
+ RTTI_ASSERT(f.template target<TestFn>() == nullptr);
}
{ // Check that the non-null value is detected.
TestFn tf = Creator<TestFn>::create();
assert(tf != nullptr);
std::function<Fn> f = tf;
- assert(f.template target<TestFn>() != nullptr);
- assert(*f.template target<TestFn>() == tf);
+ RTTI_ASSERT(f.template target<TestFn>() != nullptr);
+ RTTI_ASSERT(*f.template target<TestFn>() == tf);
}
}
std::function<FuncType> f = FunctionObject();
assert(FunctionObject::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.template target<FunctionObject>());
- assert(f.template target<FuncType>() == 0);
- assert(f.template target<FuncType*>() == 0);
+ RTTI_ASSERT(f.template target<FunctionObject>());
+ RTTI_ASSERT(f.template target<FuncType>() == 0);
+ RTTI_ASSERT(f.template target<FuncType*>() == 0);
// Copy function with allocator
std::function<FuncType> f2(std::allocator_arg, alloc, f);
assert(FunctionObject::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f2.template target<FunctionObject>());
- assert(f2.template target<FuncType>() == 0);
- assert(f2.template target<FuncType*>() == 0);
+ RTTI_ASSERT(f2.template target<FunctionObject>());
+ RTTI_ASSERT(f2.template target<FuncType>() == 0);
+ RTTI_ASSERT(f2.template target<FuncType*>() == 0);
}
assert(FunctionObject::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
FuncType* target = &FreeFunction;
std::function<FuncType> f = target;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.template target<FuncType*>());
- assert(*f.template target<FuncType*>() == target);
- assert(f.template target<FuncType>() == 0);
+ RTTI_ASSERT(f.template target<FuncType*>());
+ RTTI_ASSERT(*f.template target<FuncType*>() == target);
+ RTTI_ASSERT(f.template target<FuncType>() == 0);
// Copy function with allocator
std::function<FuncType> f2(std::allocator_arg, alloc, f);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.template target<FuncType*>());
- assert(*f2.template target<FuncType*>() == target);
- assert(f2.template target<FuncType>() == 0);
+ RTTI_ASSERT(f2.template target<FuncType*>());
+ RTTI_ASSERT(*f2.template target<FuncType*>() == target);
+ RTTI_ASSERT(f2.template target<FuncType>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
}
TargetType target = &MemFunClass::foo;
std::function<FuncType> f = target;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.template target<TargetType>());
- assert(*f.template target<TargetType>() == target);
- assert(f.template target<FuncType*>() == 0);
+ RTTI_ASSERT(f.template target<TargetType>());
+ RTTI_ASSERT(*f.template target<TargetType>() == target);
+ RTTI_ASSERT(f.template target<FuncType*>() == 0);
// Copy function with allocator
std::function<FuncType> f2(std::allocator_arg, alloc, f);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.template target<TargetType>());
- assert(*f2.template target<TargetType>() == target);
- assert(f2.template target<FuncType*>() == 0);
+ RTTI_ASSERT(f2.template target<TargetType>());
+ RTTI_ASSERT(*f2.template target<TargetType>() == target);
+ RTTI_ASSERT(f2.template target<FuncType*>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
}
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int (*)(int)>() == 0);
std::function<int(int)> f2(std::allocator_arg, bare_allocator<A>(),
std::move(f));
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.target<A>());
- assert(f2.target<int (*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(f.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>());
+ RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int (*)(int)>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
Ref aref(a);
std::function<int(int)> f(aref);
assert(A::count == 1);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ref>());
+ RTTI_ASSERT(f.target<A>() == nullptr);
+ RTTI_ASSERT(f.target<Ref>());
std::function<int(int)> f2(std::allocator_arg, std::allocator<int>{},
std::move(f));
assert(A::count == 1);
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ref>());
- assert(f.target<Ref>()); // f is unchanged because the target is small
+ RTTI_ASSERT(f2.target<A>() == nullptr);
+ RTTI_ASSERT(f2.target<Ref>());
+ RTTI_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
}
{
// Test that moving a function constructed from a function pointer
using Ptr = int(*)(int);
Ptr p = g;
std::function<int(int)> f(p);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ptr>());
+ RTTI_ASSERT(f.target<A>() == nullptr);
+ RTTI_ASSERT(f.target<Ptr>());
std::function<int(int)> f2(std::allocator_arg, std::allocator<int>(),
std::move(f));
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ptr>());
- assert(f.target<Ptr>()); // f is unchanged because the target is small
+ RTTI_ASSERT(f2.target<A>() == nullptr);
+ RTTI_ASSERT(f2.target<Ptr>());
+ RTTI_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
}
return 0;
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int (*)(int)>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(A::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f2.target<A>());
- assert(f2.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>());
+ RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (*)(int)>());
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int (*)(int)>());
+ RTTI_ASSERT(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int (*)(int)>());
- assert(f2.target<A>() == 0);
+ RTTI_ASSERT(f2.target<int (*)(int)>());
+ RTTI_ASSERT(f2.target<A>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (*)(int)>() == 0);
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int (*)(int)>() == 0);
- assert(f2.target<A>() == 0);
+ RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>() == 0);
}
{
typedef std::function<int()> Func;
Func f = g0;
Func& fr = (f = (Func &)f);
assert(&fr == &f);
- assert(*f.target<int(*)()>() == g0);
+ RTTI_ASSERT(*f.target<int(*)()>() == g0);
}
{
typedef std::function<int(int)> Func;
Func f = g;
Func& fr = (f = (Func &)f);
assert(&fr == &f);
- assert(*f.target<int(*)(int)>() == g);
+ RTTI_ASSERT(*f.target<int(*)(int)>() == g);
}
{
typedef std::function<int(int, int)> Func;
Func f = g2;
Func& fr = (f = (Func &)f);
assert(&fr == &f);
- assert(*f.target<int(*)(int, int)>() == g2);
+ RTTI_ASSERT(*f.target<int(*)(int, int)>() == g2);
}
{
typedef std::function<int(int, int, int)> Func;
Func f = g3;
Func& fr = (f = (Func &)f);
assert(&fr == &f);
- assert(*f.target<int(*)(int, int, int)>() == g3);
+ RTTI_ASSERT(*f.target<int(*)(int, int, int)>() == g3);
}
#if TEST_STD_VER >= 11
assert(globalMemCounter.checkOutstandingNewEq(0));
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int (*)(int)>() == 0);
std::function<int(int)> f2;
f2 = std::move(f);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.target<A>());
- assert(f2.target<int (*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(f.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>());
+ RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int (*)(int)>() == 0);
}
#endif
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = f;
assert(A::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f2.target<A>());
- assert(f2.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>());
+ RTTI_ASSERT(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>());
+ RTTI_ASSERT(f.target<A>() == 0);
std::function<int(int)> f2 = f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int(*)(int)>());
- assert(f2.target<A>() == 0);
+ RTTI_ASSERT(f2.target<int(*)(int)>());
+ RTTI_ASSERT(f2.target<A>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
std::function<int(int)> f2 = f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int(*)(int)>() == 0);
- assert(f2.target<A>() == 0);
+ RTTI_ASSERT(f2.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>() == 0);
}
{
std::function<int(int)> f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
assert(!f);
std::function<long(int)> g = f;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(g.target<long(*)(int)>() == 0);
- assert(g.target<A>() == 0);
+ RTTI_ASSERT(g.target<long(*)(int)>() == 0);
+ RTTI_ASSERT(g.target<A>() == 0);
assert(!g);
}
#if TEST_STD_VER >= 11
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>());
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
#if TEST_STD_VER > 17
ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
std::function<int(int)> f2 = std::move(f);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.target<A>());
- assert(f2.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f2.target<A>());
+ RTTI_ASSERT(f2.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
Ref aref(a);
std::function<int(int)> f(aref);
assert(A::count == 1);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ref>());
+ RTTI_ASSERT(f.target<A>() == nullptr);
+ RTTI_ASSERT(f.target<Ref>());
LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
#if TEST_STD_VER > 17
ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
#endif
std::function<int(int)> f2(std::move(f));
assert(A::count == 1);
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ref>());
- LIBCPP_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
+ RTTI_ASSERT(f2.target<A>() == nullptr);
+ RTTI_ASSERT(f2.target<Ref>());
+#if defined(_LIBCPP_VERSION)
+ RTTI_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
+#endif
}
{
// Test that moving a function constructed from a function pointer
using Ptr = int(*)(int);
Ptr p = g;
std::function<int(int)> f(p);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ptr>());
+ RTTI_ASSERT(f.target<A>() == nullptr);
+ RTTI_ASSERT(f.target<Ptr>());
LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
#if TEST_STD_VER > 17
ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
#endif
std::function<int(int)> f2(std::move(f));
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ptr>());
- LIBCPP_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
+ RTTI_ASSERT(f2.target<A>() == nullptr);
+ RTTI_ASSERT(f2.target<Ptr>());
+#if defined(_LIBCPP_VERSION)
+ RTTI_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
+#endif
}
#endif // TEST_STD_VER >= 11
std::function<int(int)> f = A();
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
+ RTTI_ASSERT(f.target<A>());
f = nullptr;
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<A>() == 0);
}
{
std::function<int(int)> f = g;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>());
+ RTTI_ASSERT(f.target<A>() == 0);
f = nullptr;
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
+ RTTI_ASSERT(f.target<int(*)(int)>() == 0);
}
return 0;
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f1.target<A>()->id() == 1);
- assert(f2.target<A>()->id() == 2);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(f2.target<A>()->id() == 2);
f1.swap(f2);
assert(A::count == 2);
assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f1.target<A>()->id() == 2);
- assert(f2.target<A>()->id() == 1);
+ RTTI_ASSERT(f1.target<A>()->id() == 2);
+ RTTI_ASSERT(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
std::function<int(int)> f2 = g;
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f1.target<A>()->id() == 1);
- assert(*f2.target<int (*)(int)>() == g);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(*f2.target<int (*)(int)>() == g);
f1.swap(f2);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(*f1.target<int (*)(int)>() == g);
- assert(f2.target<A>()->id() == 1);
+ RTTI_ASSERT(*f1.target<int (*)(int)>() == g);
+ RTTI_ASSERT(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(*f1.target<int (*)(int)>() == g);
- assert(f2.target<A>()->id() == 1);
+ RTTI_ASSERT(*f1.target<int (*)(int)>() == g);
+ RTTI_ASSERT(f2.target<A>()->id() == 1);
f1.swap(f2);
assert(A::count == 1);
assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f1.target<A>()->id() == 1);
- assert(*f2.target<int (*)(int)>() == g);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(*f2.target<int (*)(int)>() == g);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
std::function<int(int)> f2 = h;
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(*f1.target<int (*)(int)>() == g);
- assert(*f2.target<int (*)(int)>() == h);
+ RTTI_ASSERT(*f1.target<int (*)(int)>() == g);
+ RTTI_ASSERT(*f2.target<int (*)(int)>() == h);
f1.swap(f2);
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(*f1.target<int (*)(int)>() == h);
- assert(*f2.target<int (*)(int)>() == g);
+ RTTI_ASSERT(*f1.target<int (*)(int)>() == h);
+ RTTI_ASSERT(*f2.target<int (*)(int)>() == g);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
f1.swap(f1);
}
assert(A::count == 1);
- assert(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(globalMemCounter.checkOutstandingNewEq(0));
DisableAllocationGuard guard;
((void)guard);
f1.swap(f1);
- assert(*f1.target<int (*)()>() == g0);
+ RTTI_ASSERT(*f1.target<int (*)()>() == g0);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
DisableAllocationGuard guard;
((void)guard);
f1.swap(f1);
- assert(*f1.target<int (*)(int, int)>() == g2);
+ RTTI_ASSERT(*f1.target<int (*)(int, int)>() == g2);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
DisableAllocationGuard guard;
((void)guard);
f1.swap(f1);
- assert(*f1.target<int (*)(int, int, int)>() == g3);
+ RTTI_ASSERT(*f1.target<int (*)(int, int, int)>() == g3);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
{
((void)guard);
f1.swap(f1);
assert(A::count == 1);
- assert(f1.target<A>()->id() == 1);
+ RTTI_ASSERT(f1.target<A>()->id() == 1);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A::count == 0);
((void)guard);
f1.swap(f1);
assert(A::count == 1);
- assert(f1.target<A>()->id() == 2);
+ RTTI_ASSERT(f1.target<A>()->id() == 2);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A::count == 0);
((void)guard);
f1.swap(f1);
assert(A::count == 1);
- assert(f1.target<A>()->id() == 3);
+ RTTI_ASSERT(f1.target<A>()->id() == 3);
}
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A::count == 0);
// This test runs in C++03, but we have deprecated using std::function in C++03.
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+// UNSUPPORTED: -fno-rtti
+
#include <functional>
#include <new>
#include <cstdlib>
// This test runs in C++03, but we have deprecated using std::function in C++03.
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+// UNSUPPORTED: -fno-rtti
+
#include <functional>
#include <typeinfo>
#include <cassert>
// template<class D, class T> D* get_deleter(const shared_ptr<T>& p);
+// UNSUPPORTED: -fno-rtti
+
#include <memory>
#include <cassert>
#include "test_macros.h"
// template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r);
+// UNSUPPORTED: -fno-rtti
+
#include <memory>
#include <type_traits>
#include <cassert>
assert(A::count == 0);
assert(p.use_count() == 1);
assert(p.get() == 0);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(A::count == 0);
assert(p.use_count() == 1);
assert(p.get() == 0);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
assert(test_allocator<A>::count == 1);
assert(test_allocator<A>::alloc_count == 1);
}
assert(A::count == 0);
assert(p.use_count() == 1);
assert(p.get() == 0);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count ==1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 1);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(A::count == 0);
assert(p.use_count() == 1);
assert(p.get() == 0);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count ==1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 1);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(A::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(A::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
assert(test_allocator<A>::count == 1);
assert(test_allocator<A>::alloc_count == 1);
}
assert(A::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(A::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(B::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(B::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 1);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
}
assert(A::count == 0);
assert(test_deleter<A>::count == 0);
assert(B::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+ std::get_deleter<test_deleter<A> >(p)
assert(d);
assert(d->state() == 3);
+#endif
assert(test_allocator<A>::count == 1);
assert(test_allocator<A>::alloc_count == 1);
}
assert(B::count == 1);
assert(p.use_count() == 1);
assert(p.get() == ptr);
- test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(test_deleter<A>::count == 1);
assert(test_deleter<A>::dealloc_count == 1);
+#ifndef TEST_HAS_NO_RTTI
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
assert(d);
assert(d->state() == 3);
+#endif
assert(test_allocator<A>::count == 1);
assert(test_allocator<A>::alloc_count == 1);
}
const std::shared_ptr<int> p;
assert(!p);
}
+#if !defined(TEST_HAS_NO_RTTI)
{
std::shared_ptr<A> basePtr = std::make_shared<B>();
std::shared_ptr<B> sp = std::dynamic_pointer_cast<B>(basePtr);
assert(sp);
}
+#endif
return 0;
}
// size_t operator()(type_index index) const;
// };
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <type_traits>
#include <cassert>
// type_index(const type_info& rhs);
+// UNSUPPORTED: -fno-rtti
+
#include <typeinfo>
#include <typeindex>
#include <cassert>
// bool operator==(const type_index& rhs) const;
// bool operator!=(const type_index& rhs) const;
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <cassert>
// size_t hash_code() const;
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <cassert>
// bool operator> (const type_index& rhs) const;
// bool operator>=(const type_index& rhs) const;
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <cassert>
// const char* name() const;
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <string>
#include <cassert>
// type_index& operator=(const type_index& ti);
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <cassert>
// type_index(const type_index& ti);
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <cassert>
// size_t operator()(type_index index) const;
// };
+// UNSUPPORTED: -fno-rtti
+
#include <typeindex>
#include <type_traits>
#include <memory>
#include "test_macros.h"
-#include "type_id.h"
template <class Tp, class Up>
constexpr bool check_tag(Up) {
+++ /dev/null
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef SUPPORT_DEMANGLE_H
-#define SUPPORT_DEMANGLE_H
-
-#include "test_macros.h"
-#include <string>
-#include <cstdlib>
-
-#if !defined(TEST_HAS_NO_DEMANGLE)
-# if defined(__GNUC__) || defined(__clang__)
-# if __has_include("cxxabi.h") && !defined(_LIBCPP_ABI_MICROSOFT)
-# include "cxxabi.h"
-# else
-# define TEST_HAS_NO_DEMANGLE
-# endif
-# else
-# define TEST_HAS_NO_DEMANGLE
-# endif
-#endif
-
-#if defined(TEST_HAS_NO_DEMANGLE)
-inline std::string demangle(const char* mangled_name) {
- return mangled_name;
-}
-#else
-template <size_t N> struct Printer;
-inline std::string demangle(const char* mangled_name) {
- int status = 0;
- char* out = __cxxabiv1::__cxa_demangle(mangled_name, nullptr, nullptr, &status);
- if (out != nullptr) {
- std::string res(out);
- std::free(out);
- return res;
- }
- return mangled_name;
-}
-#endif
-
-#endif // SUPPORT_DEMANGLE_H
#include "test_macros.h"
-#if !defined(TEST_HAS_NO_RTTI)
-#define RTTI_ASSERT(X) assert(X)
-#else
-#define RTTI_ASSERT(X)
-#endif
-
template <class T>
struct IsSmallObject
: public std::integral_constant<bool
+++ /dev/null
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#include "test_macros.h"
-#include "demangle.h"
-#include <typeinfo>
-#include <cassert>
-
-struct MyType {};
-
-template <class T, class U> struct ArgumentListID {};
-
-int main(int, char**) {
- struct {
- const char* raw;
- const char* expect;
- } TestCases[] = {
- {typeid(int).name(), "int"},
- {typeid(MyType).name(), "MyType"},
- {typeid(ArgumentListID<int, MyType>).name(), "ArgumentListID<int, MyType>"}
- };
- const size_t size = sizeof(TestCases) / sizeof(TestCases[0]);
- for (size_t i=0; i < size; ++i) {
- const char* raw = TestCases[i].raw;
- const char* expect = TestCases[i].expect;
-#ifdef TEST_HAS_NO_DEMANGLE
- assert(demangle(raw) == raw);
- ((void)expect);
-#else
- assert(demangle(raw) == expect);
-#endif
- }
-
- return 0;
-}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: no-exceptions
-
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_EXCEPTIONS macro is NOT defined when exceptions
+// are enabled.
-// #define TEST_HAS_NO_EXCEPTIONS
+// UNSUPPORTED: no-exceptions
#include "test_macros.h"
-#if defined(TEST_HAS_NO_EXCEPTIONS)
-#error macro defined unexpectedly
+#ifdef TEST_HAS_NO_EXCEPTIONS
+# error "TEST_HAS_NO_EXCEPTIONS should NOT be defined"
#endif
int main(int, char**) {
- try { ((void)0); } catch (...) {}
-
- return 0;
+ try { (void)0; } catch (...) { }
+ return 0;
}
//
//===----------------------------------------------------------------------===//
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_EXCEPTIONS macro is defined when exceptions are
+// disabled.
-// #define TEST_HAS_NO_EXCEPTIONS
+// REQUIRES: no-exceptions
#include "test_macros.h"
-int main(int, char**) {
-#if defined(TEST_HAS_NO_EXCEPTIONS)
- try { ((void)0); } catch (...) {} // expected-error {{exceptions disabled}}
-#else
- try { ((void)0); } catch (...) {}
-#error exceptions enabled
-// expected-error@-1 {{exceptions enabled}}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+# error "TEST_HAS_NO_EXCEPTIONS should be defined"
#endif
- return 0;
+int main(int, char**) {
+ try { (void)0; } catch (...) { } // expected-error {{exceptions disabled}}
+ return 0;
}
//
//===----------------------------------------------------------------------===//
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_RTTI macro is defined when the -fno-rtti feature
+// is defined.
-// #define TEST_HAS_NO_RTTI
+// REQUIRES: -fno-rtti
#include "test_macros.h"
-struct A { virtual ~A() {} };
-struct B : A {};
+#ifndef TEST_HAS_NO_RTTI
+# error "TEST_HAS_NO_RTTI should be defined"
+#endif
+
+struct A { virtual ~A() { } };
+struct B : A { };
int main(int, char**) {
-#if defined(TEST_HAS_NO_RTTI)
- A* ptr = new B;
- (void)dynamic_cast<B*>(ptr); // expected-error{{cannot use dynamic_cast}}
-#else
A* ptr = new B;
- (void)dynamic_cast<B*>(ptr);
-#error RTTI enabled
-// expected-error@-1{{RTTI enabled}}
-#endif
-
- return 0;
+ (void)dynamic_cast<B*>(ptr); // expected-error{{use of dynamic_cast requires -frtti}}
+ return 0;
}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: -fno-rtti
-
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_RTTI macro is NOT defined when the -fno-rtti
+// feature isn't defined.
-// #define TEST_HAS_NO_RTTI
+// UNSUPPORTED: -fno-rtti
#include "test_macros.h"
-#if defined(TEST_HAS_NO_RTTI)
-#error Macro defined unexpectedly
+#ifdef TEST_HAS_NO_RTTI
+# error "TEST_HAS_NO_RTTI should NOT be defined"
#endif
-struct A { virtual ~A() {} };
-struct B : A {};
+struct A { virtual ~A() { } };
+struct B : A { };
int main(int, char**) {
A* ptr = new B;
(void)dynamic_cast<B*>(ptr);
delete ptr;
-
- return 0;
+ return 0;
}
#define TEST_HAS_NO_RTTI
#endif
+#if !defined(TEST_HAS_NO_RTTI)
+# define RTTI_ASSERT(X) assert(X)
+#else
+# define RTTI_ASSERT(X)
+#endif
+
#if !TEST_HAS_FEATURE(cxx_exceptions) && !defined(__cpp_exceptions) \
&& !defined(__EXCEPTIONS)
#define TEST_HAS_NO_EXCEPTIONS
#define SUPPORT_TYPE_ID_H
#include <functional>
-#include <typeinfo>
#include <string>
#include <cstdio>
#include <cassert>
#include "test_macros.h"
-#include "demangle.h"
#if TEST_STD_VER < 11
#error This header requires C++11 or greater
{return LHS.m_id != RHS.m_id; }
std::string name() const {
- return demangle(m_id);
- }
-
- void dump() const {
- std::string s = name();
- std::printf("TypeID: %s\n", s.c_str());
+ return m_id;
}
private:
#endif // _MSC_VER
template <class T>
inline TypeID const& makeTypeIDImp() {
- static const TypeID id(typeid(T).name());
+ static const TypeID id(__PRETTY_FUNCTION__);
return id;
}
#ifdef _MSC_VER