Replaceable
authorPhil Willoughby <philwill@fb.com>
Tue, 25 Jul 2017 07:17:24 +0000 (00:17 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 25 Jul 2017 07:24:12 +0000 (00:24 -0700)
commitfbfd3029afb38ba11ff8f403aac3704c47141119
treed4bcac95df68e3b237ed0d462309ba5fa7cfc6f0
parentebff31e4f6a2762a03cc98e9381f89534d685089
Replaceable

Summary:
An instance of `Replaceable<T>` wraps an instance of `T`.

You access the inner `T` instance with `operator*` and `operator->` (as if
it were a smart pointer).

`Replaceable<T>` adds no indirection cost and performs no allocations.

`Replaceable<T>` has the same size and alignment as `T`.

You can replace the `T` within a `Replaceable<T>` using the `emplace` method
(presuming that it is constructible and destructible without throwing
exceptions). If the destructor or constructor you're using could throw an
exception you should use `Optional<T>` instead, as it's not a logic error for
that to be empty.

Reviewed By: yfeldblum

Differential Revision: D5346528

fbshipit-source-id: c7d72e73ea04e371325327a7ff0b345315d6e5ac
folly/Makefile.am
folly/Replaceable.h [new file with mode: 0644]
folly/test/ReplaceableTest.cpp [new file with mode: 0644]