any.cpp

mail@pastecode.io avatar
unknown
c_cpp
a year ago
390 B
4
Indexable
Never
#include "any.h"

#include <utility>

Any::Any() {
}

Any::Any(const Any &rhs) : ptr_(rhs.ptr_->Clone()) {
}

Any &Any::operator=(Any rhs) {
    this->Swap(rhs);
    return *this;
}

Any::~Any() {
    Clear();
}

bool Any::Empty() const {
    return ptr_ == nullptr;
}

void Any::Clear() {
    delete ptr_;
    ptr_ = nullptr;
}

void Any::Swap(Any &rhs) {
    std::swap(ptr_, rhs.ptr_);
}