13 const Any Any::Null{};
17 Any::Any(
const Any& other) :
18 mData(other.mData ? other.mType->copy(other.mData) : nullptr),
23 Any::Any(Any&& other) noexcept :
24 mData(std::exchange(other.mData,
nullptr)),
25 mType(std::exchange(other.mType,
nullptr))
32 mType->destroy(mData);
35 Any& Any::operator=(
const Any& rhs)
37 return *
this = Any(rhs);
40 Any& Any::operator=(Any&& rhs)
noexcept
45 Any incoming(std::move(rhs));
46 std::swap(mData, incoming.mData);
47 std::swap(mType, incoming.mType);
52 bool Any::empty()
const
57 const std::type_info& Any::getType()
const
59 return mType ? mType->type :
typeid(void);
62 bool Any::compare(
const Any& other)
const
64 if (empty() || other.empty())
65 return empty() == other.empty();
66 return mType->compare(mData, other.mData, other.mType->type);