Skip to content

Commit

Permalink
Review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Quuxplusone committed Apr 13, 2019
1 parent 4004927 commit ca7824c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions SG14/inplace_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,23 @@ class inplace_function<R(Args...), Capacity, Alignment>
}

template<size_t Cap, size_t Align>
inplace_function(const inplace_function<R(Args...), Cap, Align>& rhs)
: inplace_function(rhs.vtable_ptr_, rhs.vtable_ptr_->copy_ptr, std::addressof(rhs.storage_))
inplace_function(const inplace_function<R(Args...), Cap, Align>& other)
: inplace_function(other.vtable_ptr_, other.vtable_ptr_->copy_ptr, std::addressof(other.storage_))
{
static_assert(inplace_function_detail::is_valid_inplace_dst<
Capacity, Alignment, Cap, Align
>::value, "conversion not allowed");
}

template<size_t Cap, size_t Align>
inplace_function(inplace_function<R(Args...), Cap, Align>&& rhs)
: inplace_function(rhs.vtable_ptr_, rhs.vtable_ptr_->relocate_ptr, std::addressof(rhs.storage_))
inplace_function(inplace_function<R(Args...), Cap, Align>&& other) noexcept
: inplace_function(other.vtable_ptr_, other.vtable_ptr_->relocate_ptr, std::addressof(other.storage_))
{
static_assert(inplace_function_detail::is_valid_inplace_dst<
Capacity, Alignment, Cap, Align
>::value, "conversion not allowed");

rhs.vtable_ptr_ = std::addressof(inplace_function_detail::empty_vtable<R, Args...>);
other.vtable_ptr_ = std::addressof(inplace_function_detail::empty_vtable<R, Args...>);
}

inplace_function(std::nullptr_t) noexcept :
Expand Down
11 changes: 11 additions & 0 deletions SG14_test/inplace_function_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ void test_move_construction_is_noexcept()
EXPECT_EQ(1, moved);
}

void test_move_construction_from_smaller_buffer_is_noexcept()
{
using IPF32 = stdext::inplace_function<void(int), 32>;
using IPF40 = stdext::inplace_function<void(int), 40>;
static_assert(std::is_nothrow_constructible<IPF32, IPF32&&>::value, "");
static_assert(std::is_nothrow_assignable<IPF32, IPF32&&>::value, "");
static_assert(std::is_nothrow_constructible<IPF40, IPF32&&>::value, "");
static_assert(std::is_nothrow_assignable<IPF40, IPF32&&>::value, "");
}

// https://bugs.llvm.org/show_bug.cgi?id=32072
struct test_bug_32072_C;
struct test_bug_32072 {
Expand Down Expand Up @@ -565,6 +575,7 @@ void sg14_test::inplace_function_test()
test_move_construction_is_noexcept();
test_is_convertible();
test_return_by_move();
test_move_construction_from_smaller_buffer_is_noexcept();
}

#ifdef TEST_MAIN
Expand Down

0 comments on commit ca7824c

Please sign in to comment.