Skip to content

Commit 0f67d13

Browse files
committed
test_custom_rtti: fix out of range index
1 parent 45db3ae commit 0f67d13

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

test/test_custom_rtti.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ struct custom_rtti : policies::deferred_static_rtti {
448448
if constexpr (is_polymorphic<T>) {
449449
return type_id(T::static_type);
450450
} else {
451-
return nullptr;
451+
return type_id(0);
452452
}
453453
}
454454

@@ -457,14 +457,14 @@ struct custom_rtti : policies::deferred_static_rtti {
457457
if constexpr (is_polymorphic<T>) {
458458
return type_id(obj.type);
459459
} else {
460-
return nullptr;
460+
return type_id(0);
461461
}
462462
}
463463

464464
template<class Stream>
465465
static void type_name(type_id type, Stream& stream) {
466-
static const char* name[] = {"Animal", "Dog", "Cat"};
467-
stream << (type == nullptr ? "?" : name[std::size_t(type)]);
466+
static const char* name[] = {"?", "Animal", "Dog", "Cat"};
467+
stream << name[std::size_t(type)];
468468
}
469469

470470
static auto type_index(type_id type) {

0 commit comments

Comments
 (0)