MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / narrow_cast

Function narrow_cast

extensions/include/cuMat/src/Errors.h:186–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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}
199CUMAT_NAMESPACE_END

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected