| 354 | } |
| 355 | |
| 356 | inline void Any::copyInto(Any& dst) const |
| 357 | { |
| 358 | if(dst.empty()) |
| 359 | { |
| 360 | dst = *this; |
| 361 | return; |
| 362 | } |
| 363 | |
| 364 | const auto& dst_type = dst.castedType(); |
| 365 | |
| 366 | if((castedType() == dst_type) || (isString() && dst.isString())) |
| 367 | { |
| 368 | dst._any = _any; |
| 369 | } |
| 370 | else if(isNumber() && dst.isNumber()) |
| 371 | { |
| 372 | if(dst_type == typeid(int64_t)) |
| 373 | { |
| 374 | dst._any = cast<int64_t>(); |
| 375 | } |
| 376 | else if(dst_type == typeid(uint64_t)) |
| 377 | { |
| 378 | dst._any = cast<uint64_t>(); |
| 379 | } |
| 380 | else if(dst_type == typeid(double)) |
| 381 | { |
| 382 | dst._any = cast<double>(); |
| 383 | } |
| 384 | else |
| 385 | { |
| 386 | throw std::runtime_error("Any::copyInto fails"); |
| 387 | } |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | throw std::runtime_error("Any::copyInto fails"); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | template <typename DST> |
| 396 | inline nonstd::expected<DST, std::string> Any::convert(EnableString<DST>) const |