| 274 | |
| 275 | template <typename T> |
| 276 | inline 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 | |
| 328 | inline Any& Any::operator=(const Any& other) |
| 329 | { |