16#if !defined(__linux__)
18#define SHARED_PTR_NAME "std::__1::shared_ptr"
21#define SHARED_PTR_NAME "std::shared_ptr"
27 template<
class T,
class U,
bool Unsafe = false>
29 checked_dynamic_pointer_cast(
const std::shared_ptr<U>& right)
32 return std::static_pointer_cast<T>(right);
34 std::shared_ptr<T> destination = std::dynamic_pointer_cast<T>(right);
36 if (__builtin_expect(!destination,
false)) {
37 const auto td =
typeid(right).name();
39 const auto td2 =
typeid(T).name();
40 std::unique_ptr<char, void(*)(
void*)> not_type {abi::__cxa_demangle(td2,
nullptr,
nullptr, &sts), std::free};
41 std::unique_ptr<char, void(*)(
void*)> is_type {abi::__cxa_demangle(td,
nullptr,
nullptr, &sts), std::free};
44 sparta_assert2(destination !=
nullptr,
45 " dynamic_pointer_cast failed, this shared_ptr is of type " <<
46 is_type.get() <<
", not of type " SHARED_PTR_NAME
"<" <<
47 not_type.get() <<
">");
57 template<
class T,
class U,
bool Unsafe = false>
58 T checked_dynamic_cast(
const U right)
61 return static_cast<T
>(right);
63 T destination =
dynamic_cast<T
>(right);
65 if (__builtin_expect(!destination,
false)) {
66 const auto td =
typeid(right).name();
68 const auto td2 =
typeid(T).name();
69 std::unique_ptr<char, void(*)(
void*)> not_type {abi::__cxa_demangle(td2,
nullptr,
nullptr, &sts), std::free};
70 std::unique_ptr<char, void(*)(
void*)> is_type {abi::__cxa_demangle(td,
nullptr,
nullptr, &sts), std::free};
71 sparta_assert2(destination !=
nullptr,
72 " dynamic_cast failed, this pointer is of type " <<
73 is_type.get() <<
", not of type " << not_type.get());
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Macros for handling exponential backoff.