copy_ctor_mixin() = default;
inline copy_ctor_mixin(copy_ctor_mixin const& other) noexcept(
std::is_nothrow_constructible<T, T const&>::value) {
- ::new (reinterpret_cast<Replaceable<T>*>(this)->storage_) T(*other);
+ ::new (reinterpret_cast<Replaceable<T>*>(this)->storage_)
+ T(*reinterpret_cast<Replaceable<T> const&>(other));
}
copy_ctor_mixin(copy_ctor_mixin&&) = default;
copy_ctor_mixin& operator=(copy_ctor_mixin&&) = default;
using namespace ::folly;
namespace {
+struct Basic {};
struct alignas(128) BigAlign {};
struct HasConst final {
bool const b1;
float,
double,
char[11],
+ Basic,
BigAlign,
HasConst,
HasRef,
EXPECT_TRUE(rHasConstB->b1);
}
+TEST(ReplaceableTest, Constructors) {
+ Basic b{};
+ // From existing `T`
+ auto rBasicCopy1 = Replaceable<Basic>(b);
+ auto rBasicMove1 = Replaceable<Basic>(std::move(b));
+ // From existing `Replaceable<T>`
+ auto rBasicCopy2 = Replaceable<Basic>(rBasicCopy1);
+ auto rBasicMove2 = Replaceable<Basic>(std::move(rBasicMove1));
+ (void)rBasicCopy2;
+ (void)rBasicMove2;
+}
+
TEST(ReplaceableTest, DestructsWhenExpected) {
int i{0};
{