| 184 | */ |
| 185 | template<class Target, class Source> |
| 186 | CUMAT_STRONG_INLINE Target narrow_cast(Source v) |
| 187 | { |
| 188 | #if CUMAT_ENABLE_HOST_ASSERTIONS==1 |
| 189 | auto r = static_cast<Target>(v); // convert the value to the target type |
| 190 | if (static_cast<Source>(r) != v) |
| 191 | throw std::runtime_error("narrow_cast<>() failed"); |
| 192 | return r; |
| 193 | #else |
| 194 | return static_cast<Target>(v); |
| 195 | #endif |
| 196 | } |
| 197 | |
| 198 | } |
| 199 | CUMAT_NAMESPACE_END |
nothing calls this directly
no outgoing calls
no test coverage detected