instanceOf
now uses RTTI and checks its answer.
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled
Next I'll just remove it, but this commit lets me have something in history such that I can fall back to check for bugs that might get introduced.
This commit is contained in:
@ -99,7 +99,7 @@ void IdentifiableObject::registerName (const char *className, const std::type_in
|
||||
* \brief Returns, whether this class is an instance of the class, given by
|
||||
* \em otherClassId, or of a sub class of this class.
|
||||
*/
|
||||
bool IdentifiableObject::instanceOf (std::intptr_t otherClassId)
|
||||
bool IdentifiableObject::instanceOf_impl (std::intptr_t otherClassId)
|
||||
{
|
||||
if (otherClassId == -1)
|
||||
// Other class has not been registered yet, while it should have been,
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <typeindex>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@ -143,7 +145,19 @@ public:
|
||||
*/
|
||||
const char *getClassName() { return classesById.at( classId )->className; }
|
||||
|
||||
bool instanceOf (std::intptr_t otherClassId);
|
||||
template< typename T >
|
||||
[[deprecated]]
|
||||
inline bool
|
||||
instanceOf()
|
||||
{
|
||||
const bool expected= dynamic_cast< T * >( this );
|
||||
const bool witness= instanceOf_impl( T::CLASS_ID );
|
||||
if( witness != expected ) throw std::logic_error{ "RTTI based `instanceOf` disagrees with Dillo's lout:: impl." };
|
||||
return expected;
|
||||
}
|
||||
|
||||
private:
|
||||
bool instanceOf_impl (std::intptr_t otherClassId);
|
||||
};
|
||||
|
||||
} // namespace identity
|
||||
|
Reference in New Issue
Block a user