control_block copy_impl()

in fatal/container/legacy_variant.h [1621:1640]


  control_block copy_impl(legacy_variant const &other) {
    auto const otherStoredType = other.control_.storedType();
    auto otherAllocator = other.control_.get_allocator();

    if (otherStoredType == no_tag()) {
      return other.control_;
    }

    traits::allocate(otherAllocator, otherStoredType, union_);
    try {
      traits::copy_construct(
        otherAllocator, otherStoredType, other.union_, union_
      );
    } catch(...) {
      traits::deallocate(otherAllocator, otherStoredType, union_);
      throw;
    }

    return other.control_;
  }