void swap()

in fatal/container/legacy_variant.h [1346:1368]


  void swap(legacy_variant &other) {
    if (this == std::addressof(other)) {
      return;
    }

    auto const storedType = control_.storedType();
    auto const otherStoredType = other.control_.storedType();
    union_type tmp;

    if (storedType != no_tag()) {
      traits::move_over(storedType, union_, tmp);
    }

    if (otherStoredType != no_tag()) {
      traits::move_over(otherStoredType, other.union_, union_);
    }

    if (storedType != no_tag()) {
      traits::move_over(storedType, tmp, other.union_);
    }

    std::swap(control_, other.control_);
  }