evan 2026.1.4
Evan
Loading...
Searching...
No Matches
CheckedCast.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** CheckedCast
6*/
7
8#pragma once
9
10#include <stdexcept>
11#include <string>
12
13namespace evan
14{
29 template<typename Target, typename Source>
30 Target &checkedCast(Source &source)
31 {
32 Target *result = dynamic_cast<Target *>(&source);
33 if (result == nullptr) {
34 throw std::logic_error("Failed to cast to requested backend type");
35 }
36 return *result;
37 }
38} // namespace evan