Commit 447346e4 by Ville Voutilainen Committed by Ville Voutilainen

re PR libstdc++/84601 (std::optional<std::pair<int, int>> is not assignment copyable)

PR libstdc++/84601
* include/std/optional (_Optional_payload): Split into multiple
specializations that can handle different cases of trivial or
non-trivial assignment operators.
* testsuite/20_util/optional/84601.cc: New.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust.

From-SVN: r258304
parent 1dc23505
2018-03-06 Ville Voutilainen <ville.voutilainen@gmail.com>
PR libstdc++/84601
* include/std/optional (_Optional_payload): Split into multiple
specializations that can handle different cases of trivial or
non-trivial assignment operators.
* testsuite/20_util/optional/84601.cc: New.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust.
2018-03-02 Jonathan Wakely <jwakely@redhat.com> 2018-03-02 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/84671 PR libstdc++/84671
......
// { dg-options "-std=gnu++17" }
// { dg-do compile }
#include <optional>
using pair_t = std::pair<int, int>;
using opt_t = std::optional<pair_t>;
static_assert(std::is_copy_constructible_v<opt_t::value_type>);
static_assert(std::is_copy_assignable_v<opt_t::value_type>);
static_assert(std::is_copy_assignable_v<opt_t>); // assertion fails.
class A
{
void f(const opt_t& opt)
{
_opt = opt;
}
opt_t _opt;
};
...@@ -37,8 +37,8 @@ int main() ...@@ -37,8 +37,8 @@ int main()
std::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" } std::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" }
struct U { explicit U(std::in_place_t); }; struct U { explicit U(std::in_place_t); };
std::optional<U> ou(std::in_place); // { dg-error "no matching" } std::optional<U> ou(std::in_place); // { dg-error "no matching" }
// { dg-error "no type" "" { target { *-*-* } } 647 } // { dg-error "no type" "" { target { *-*-* } } 1015 }
// { dg-error "no type" "" { target { *-*-* } } 657 } // { dg-error "no type" "" { target { *-*-* } } 1025 }
// { dg-error "no type" "" { target { *-*-* } } 714 } // { dg-error "no type" "" { target { *-*-* } } 1082 }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment