buffet: add C++ variant type (Any).

Any is the class that adds support for native variant types.

Any can store any C++ type which is copyable. Moveable-only
types (such as std::unique_ptr) cannot be stored directly,
however you can store pointers (or references) to such types.

Any stores small data embedded into the class itself without
having to allocate a separate storage for it. Larger data
(roughly, larger than 8 bytes) or non trivially-copyable types
are stored in a separate memory block and the pointer to that
block is stored in the Any class itself.

Any supports move semantics. You can move the stored value
from one Any into another without copying it.

At this point, there is no support for comparing the Any class
(equal or less than), so you cannot use it as a key in a map,
however you still can store it as a value.

The code that extracts the data from Any must know the exact
type stored. Calling Any::Get<T>() for incompatible type is
not supported. However you can use Any::TryGet<T>() instead
and provide a default value, which will be returned if Any
does not contain the expected data.

You can also inspect the type of the contained data by
using Any::GetType() and Any::IsTypeCompatible<T>() methods.

BUG=chromium:366709
TEST=All existing and new unit tests pass.

Change-Id: Ic47529935ddd39c792dff1db8667c76db91b16d4
Reviewed-on: https://chromium-review.googlesource.com/198590
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
6 files changed