gcc/libstdc++-v3/testsuite/20_util/optional/assignment/100982.cc
Jonathan Wakely b3fce1bd45 libstdc++: Fix constraint on std::optional assignment [PR 100982]
libstdc++-v3/ChangeLog:

	PR libstdc++/100982
	* include/std/optional (optional::operator=(const optional<U>&)):
	Fix value category used in is_assignable check.
	* testsuite/20_util/optional/assignment/100982.cc: New test.
2021-06-09 12:45:11 +01:00

18 lines
272 B
C++

// { dg-do compile { target c++17 } }
#include <optional>
struct U {};
struct T {
explicit T(const U&);
T& operator=(const U&);
T& operator=(U&&) = delete;
};
int main() {
std::optional<U> opt1;
std::optional<T> opt2;
opt2 = opt1; // PR libstdc++/100982
}