Index: test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp =================================================================== --- test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp +++ test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp @@ -44,7 +44,7 @@ auto &v = a.emplace(); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -60,7 +60,7 @@ auto &v = a.emplace(101); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -76,7 +76,7 @@ auto &v = a.emplace(-1, 42, -1); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -97,7 +97,7 @@ assert(Tracked::count == 1); auto &v = a.emplace(); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assertArgsMatch(a); @@ -107,7 +107,7 @@ assert(Tracked::count == 1); auto &v = a.emplace(-1, 42, -1); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assertArgsMatch(a); @@ -118,7 +118,7 @@ assert(Tracked::count == 1); auto &v = a.emplace({-1, 42, -1}); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assertArgsMatch>(a); @@ -129,7 +129,7 @@ assert(Tracked::count == 1); auto &v = a.emplace({-1, 42, -1}, x); static_assert( std::is_same_v, "" ); - assert(&v == std::any_cast(&a)); + assert(&v == std::any_cast(&a)); assert(Tracked::count == 0); assertArgsMatch, int&>(a); @@ -159,7 +159,8 @@ std::any a(small{42}); assert(small::count == 1); try { - a.emplace(101); + auto &v = a.emplace(101); + static_assert( std::is_same_v, "" ); assert(false); } catch (int const&) { } @@ -169,7 +170,8 @@ std::any a(small{42}); assert(small::count == 1); try { - a.emplace({1, 2, 3}, 101); + auto &v = a.emplace({1, 2, 3}, 101); + static_assert( std::is_same_v, "" ); assert(false); } catch (int const&) { } @@ -180,7 +182,8 @@ std::any a(large{42}); assert(large::count == 1); try { - a.emplace(101); + auto &v = a.emplace(101); + static_assert( std::is_same_v, "" ); assert(false); } catch (int const&) { } @@ -190,7 +193,8 @@ std::any a(large{42}); assert(large::count == 1); try { - a.emplace({1, 2, 3}, 101); + auto &v = a.emplace({1, 2, 3}, 101); + static_assert( std::is_same_v, "" ); assert(false); } catch (int const&) { } Index: test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp =================================================================== --- test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -254,7 +254,9 @@ { assert(static_cast(opt) == true); assert(Y::dtor_called == false); - opt.emplace(1); + auto &v = opt.emplace(1); + static_assert( std::is_same_v, "" ); + assert(false); } catch (int i) { Index: test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp =================================================================== --- test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp @@ -11,7 +11,7 @@ // // template -// void optional::emplace(initializer_list il, Args&&... args); +// T& optional::emplace(initializer_list il, Args&&... args); #include #include @@ -76,21 +76,27 @@ X x; optional opt(x); assert(X::dtor_called == false); - opt.emplace({1, 2}); + auto &v = opt.emplace({1, 2}); + static_assert( std::is_same_v, "" ); assert(X::dtor_called == true); assert(*opt == X({1, 2})); + assert(&v == &*opt); } { optional> opt; - opt.emplace({1, 2, 3}, std::allocator()); + auto &v = opt.emplace({1, 2, 3}, std::allocator()); + static_assert( std::is_same_v&, decltype(v)>, "" ); assert(static_cast(opt) == true); assert(*opt == std::vector({1, 2, 3})); + assert(&v == &*opt); } { optional opt; - opt.emplace({1, 2}); + auto &v = opt.emplace({1, 2}); + static_assert( std::is_same_v, "" ); assert(static_cast(opt) == true); assert(*opt == Y({1, 2})); + assert(&v == &*opt); } #ifndef TEST_HAS_NO_EXCEPTIONS { @@ -100,7 +106,9 @@ { assert(static_cast(opt) == true); assert(Z::dtor_called == false); - opt.emplace({1, 2}); + auto &v = opt.emplace({1, 2}); + static_assert( std::is_same_v, "" ); + assert(false); } catch (int i) {