diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
| commit | 51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch) | |
| tree | 91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/std/utilities/tuple/tuple.tuple/tuple.assign | |
| parent | bb5e33f003797b67974a8893f7f2930fc51b8210 (diff) | |
Notes
Diffstat (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.assign')
| -rw-r--r-- | test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp | 12 | ||||
| -rw-r--r-- | test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp | 19 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp index 2dde6b5521f2..91892efaf139 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp @@ -74,4 +74,16 @@ int main() assert(std::get<1>(t1) == int('a')); assert(std::get<2>(t1).id_ == 2); } + { + // Test that tuple evaluates correctly applies an lvalue reference + // before evaluating is_assignable (ie 'is_assignable<int&, int&>') + // instead of evaluating 'is_assignable<int&&, int&>' which is false. + int x = 42; + int y = 43; + std::tuple<int&&> t(std::move(x)); + std::tuple<int&> t2(y); + t = t2; + assert(std::get<0>(t) == 43); + assert(&std::get<0>(t) == &x); + } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp index 11bfdd0c94a9..afd3e0fdb8e3 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp @@ -37,6 +37,13 @@ struct D explicit D(int i) : B(i) {} }; +struct E { + E() = default; + E& operator=(int val) { + return *this; + } +}; + int main() { { @@ -88,4 +95,16 @@ int main() assert(std::get<1>(t1) == int('a')); assert(std::get<2>(t1)->id_ == 3); } + { + // Test that tuple evaluates correctly applies an lvalue reference + // before evaluating is_assignable (ie 'is_assignable<int&, int&&>') + // instead of evaluating 'is_assignable<int&&, int&&>' which is false. + int x = 42; + int y = 43; + std::tuple<int&&, E> t(std::move(x), E{}); + std::tuple<int&&, int> t2(std::move(y), 44); + t = std::move(t2); + assert(std::get<0>(t) == 43); + assert(&std::get<0>(t) == &x); + } } |
