[orc-rt] Prevent RTTIExtends from being used for errors. (#172250)

Custom error types (ErrorInfoBase subclasses) should use ErrorExtends as
of 8f51da369e6. Adding a static_assert allows us to enforce that at
compile-time.
This commit is contained in:
Lang Hames 2025-12-15 17:21:25 +11:00 committed by GitHub
parent 5a581acb29
commit 61908c5957
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,8 +52,12 @@
#ifndef ORC_RT_RTTI_H
#define ORC_RT_RTTI_H
#include <type_traits>
namespace orc_rt {
class ErrorInfoBase;
template <typename ThisT, typename ParentT> class RTTIExtends;
/// Base class for the extensible RTTI hierarchy.
@ -107,6 +111,10 @@ private:
///
template <typename ThisT, typename ParentT> class RTTIExtends : public ParentT {
public:
static_assert(!std::is_base_of_v<ErrorInfoBase, ParentT>,
"RTTIExtends should not be used to define orc_rt custom error "
"types, use ErrorExtends instead");
// Inherit constructors and isA methods from ParentT.
using ParentT::isA;
using ParentT::ParentT;