Raven Engine v0.1
Loading...
Searching...
No Matches
Casting.h File Reference

Provides casting utilities for safe type conversions and CRTP-based self-casting. More...

#include <cassert>
#include <concepts>
#include <cstdlib>
#include "Raven/Memory/Ref.h"
#include "Raven/Logging/Logger.h"

Classes

class  Raven::Castable< Derived >
 CRTP base class enabling self-casting in derived types. More...

Namespaces

namespace  Raven

Functions

template<typename To, typename From>
To Raven::CastHelper (From *ptr)
 Safe casting function between types.

Detailed Description

Provides casting utilities for safe type conversions and CRTP-based self-casting.

Author
PhilikusHD

This file contains utilities for safe type casting, including a CRTP base class that provides integrated casting via As<T>() method. It also includes a free function CastHelper for safe casting between types.

Typical usage:

  1. Derive from Castable<T> to enable self-casting in your hierarchy.
  2. Use As<T>() to safely cast to the desired type.
Note
  • The CastHelper function is designed to be used in debug mode for safety checks.