mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-25 04:56:13 +08:00
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:
@@ -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, "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user