From ca7824c820347f479c0fdf691d88e4fb86cb50ab Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 13 Apr 2019 14:58:39 -0400 Subject: [PATCH] Review comments. --- SG14/inplace_function.h | 10 +++++----- SG14_test/inplace_function_test.cpp | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/SG14/inplace_function.h b/SG14/inplace_function.h index b0c1bf74..cddd81ee 100644 --- a/SG14/inplace_function.h +++ b/SG14/inplace_function.h @@ -218,8 +218,8 @@ class inplace_function } template - inplace_function(const inplace_function& rhs) - : inplace_function(rhs.vtable_ptr_, rhs.vtable_ptr_->copy_ptr, std::addressof(rhs.storage_)) + inplace_function(const inplace_function& 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 @@ -227,14 +227,14 @@ class inplace_function } template - inplace_function(inplace_function&& rhs) - : inplace_function(rhs.vtable_ptr_, rhs.vtable_ptr_->relocate_ptr, std::addressof(rhs.storage_)) + inplace_function(inplace_function&& 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); + other.vtable_ptr_ = std::addressof(inplace_function_detail::empty_vtable); } inplace_function(std::nullptr_t) noexcept : diff --git a/SG14_test/inplace_function_test.cpp b/SG14_test/inplace_function_test.cpp index b1ec6874..e21b00a9 100644 --- a/SG14_test/inplace_function_test.cpp +++ b/SG14_test/inplace_function_test.cpp @@ -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; + using IPF40 = stdext::inplace_function; + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_assignable::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_assignable::value, ""); +} + // https://bugs.llvm.org/show_bug.cgi?id=32072 struct test_bug_32072_C; struct test_bug_32072 { @@ -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