Revert r276548 - Make pair/tuples assignment operators SFINAE properly.

This is a breaking change. The SFINAE required is instantiated the second
the class is instantiated, and this can cause hard SFINAE errors
when applied to references to incomplete types. Ex.

struct IncompleteType;
extern IncompleteType it;
std::tuple<IncompleteType&> t(it); // SFINAE will blow up.




git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276598 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-07-25 01:45:07 +00:00
parent 775417d97c
commit c76d8f7ff4
7 changed files with 7 additions and 352 deletions

View File

@@ -19,22 +19,6 @@
#include <string>
#include <cassert>
#include "test_macros.h"
struct NonAssignable {
NonAssignable& operator=(NonAssignable const&) = delete;
NonAssignable& operator=(NonAssignable&&) = delete;
};
struct CopyAssignable {
CopyAssignable& operator=(CopyAssignable const&) = default;
CopyAssignable& operator=(CopyAssignable &&) = delete;
};
static_assert(std::is_copy_assignable<CopyAssignable>::value, "");
struct MoveAssignable {
MoveAssignable& operator=(MoveAssignable const&) = delete;
MoveAssignable& operator=(MoveAssignable&&) = default;
};
int main()
{
{
@@ -67,37 +51,4 @@ int main()
assert(std::get<1>(t) == 'a');
assert(std::get<2>(t) == "some text");
}
{
// test reference assignment.
using T = std::tuple<int&, int&&>;
int x = 42;
int y = 100;
int x2 = -1;
int y2 = 500;
T t(x, std::move(y));
T t2(x2, std::move(y2));
t = t2;
assert(std::get<0>(t) == x2);
assert(&std::get<0>(t) == &x);
assert(std::get<1>(t) == y2);
assert(&std::get<1>(t) == &y);
}
{
// test that the implicitly generated copy assignment operator
// is properly deleted
using T = std::tuple<std::unique_ptr<int>>;
static_assert(!std::is_copy_assignable<T>::value, "");
}
{
using T = std::tuple<int, NonAssignable>;
static_assert(!std::is_copy_assignable<T>::value, "");
}
{
using T = std::tuple<int, CopyAssignable>;
static_assert(std::is_copy_assignable<T>::value, "");
}
{
using T = std::tuple<int, MoveAssignable>;
static_assert(!std::is_copy_assignable<T>::value, "");
}
}