z-logo
Premium
Fast dynamic casting
Author(s) -
Gibbs Michael,
Stroustrup Bjarne
Publication year - 2006
Publication title -
software: practice and experience
Language(s) - English
Resource type - Journals
SCImago Journal Rank - 0.437
H-Index - 70
eISSN - 1097-024X
pISSN - 0038-0644
DOI - 10.1002/spe.686
Subject(s) - pointer (user interface) , c dynamic memory allocation , computer science , modulo , integer (computer science) , class (philosophy) , arithmetic , predictability , base (topology) , theoretical computer science , function (biology) , algorithm , programming language , discrete mathematics , mathematics , artificial intelligence , memory management , mathematical analysis , statistics , overlay , evolutionary biology , biology
We describe a scheme for implementing dynamic casts suitable for systems where the performance and predictability of performance is essential. A dynamic cast from a base class to a derived class in an object‐oriented language can be performed quickly by having the linker assign an integer type ID to each class. A simple integer arithmetic operation verifies whether the cast is legal at run time. The type ID scheme presented uses the modulo function to check that one class derives from another. A 64‐bit type ID is sufficient to handle class hierarchies of large size at least nine levels of derivation deep. We also discuss the pointer adjustments required for a C++ dynamic_cast. All examples will be drawn from the C++ language. Copyright © 2005 John Wiley & Sons, Ltd.

This content is not available in your region!

Continue researching here.

Having issues? You can contact us here
Accelerating Research

Address

John Eccles House
Robert Robinson Avenue,
Oxford Science Park, Oxford
OX4 4GP, United Kingdom