Skip to content

C++ checked_cast implementation for a faster safe dynamic_cast

Notifications You must be signed in to change notification settings

Schorny/checked_cast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

checked_cast

C++ checked_cast implementation for a faster safe dynamic_cast

Synopsis

dynamic_cast in C++ requires RTTI lookups and is therefore very slow. It ensures that the cast is correct and this takes time. Time that not necessarily needs to be spend. If you know that the cast is OK, there is no need to do all the RTTI lookups and a static_cast will work just fine. But during debug it might be usefull to use dynamic_cast to ensure that the code is correct. Hence: checked_cast.

Use

checked_cast is basically just a dynamic_cast which turns to a static_cast in non-debug situations.

Sample

Derived* p=checked_cast<Derived*>(pBase);

About

C++ checked_cast implementation for a faster safe dynamic_cast

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages