MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / isCastingSafe

Function isCastingSafe

include/behaviortree_cpp/utils/safe_any.hpp:276–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274
275template <typename T>
276inline bool isCastingSafe(const std::type_index& type, const T& val)
277{
278 if(type == typeid(T))
279 {
280 return true;
281 }
282
283 if(std::type_index(typeid(uint8_t)) == type)
284 {
285 return ValidCast<T, uint8_t>(val);
286 }
287 if(std::type_index(typeid(uint16_t)) == type)
288 {
289 return ValidCast<T, uint16_t>(val);
290 }
291 if(std::type_index(typeid(uint32_t)) == type)
292 {
293 return ValidCast<T, uint32_t>(val);
294 }
295 if(std::type_index(typeid(uint64_t)) == type)
296 {
297 return ValidCast<T, uint64_t>(val);
298 }
299 //------------
300 if(std::type_index(typeid(int8_t)) == type)
301 {
302 return ValidCast<T, int8_t>(val);
303 }
304 if(std::type_index(typeid(int16_t)) == type)
305 {
306 return ValidCast<T, int16_t>(val);
307 }
308 if(std::type_index(typeid(int32_t)) == type)
309 {
310 return ValidCast<T, int32_t>(val);
311 }
312 if(std::type_index(typeid(int64_t)) == type)
313 {
314 return ValidCast<T, int64_t>(val);
315 }
316 //------------
317 if(std::type_index(typeid(float)) == type)
318 {
319 return ValidCast<T, float>(val);
320 }
321 if(std::type_index(typeid(double)) == type)
322 {
323 return ValidCast<T, double>(val);
324 }
325 return false;
326}
327
328inline Any& Any::operator=(const Any& other)
329{

Callers 1

setMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected