[libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.
Summary: __compressed_pair takes and passes it's constructor arguments by value. This causes arguments to be moved 3 times instead of once. This patch addresses that issue and fixes `constexpr` on the constructors. I would rather have this fix than D27564, and I'm fairly confident it's not ABI breaking but I'm not 100% sure. I prefer this solution because it removes a lot of code and makes the implementation *much* smaller. Reviewers: mclow.lists, K-ballo Reviewed By: K-ballo Subscribers: K-ballo, cfe-commits Differential Revision: https://reviews.llvm.org/D27565 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,24 +15,25 @@
|
||||
|
||||
// default unique_ptr ctor should require default Deleter ctor
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include "test_macros.h"
|
||||
|
||||
class Deleter
|
||||
{
|
||||
// expected-error@memory:* {{base class 'Deleter' has private default constructor}}
|
||||
// expected-note@memory:* + {{in instantiation of member function}}
|
||||
Deleter() {} // expected-note {{implicitly declared private here}}
|
||||
class Deleter {
|
||||
Deleter() {}
|
||||
|
||||
public:
|
||||
Deleter(Deleter&) {}
|
||||
Deleter& operator=(Deleter&) { return *this; }
|
||||
|
||||
Deleter(Deleter&) {}
|
||||
Deleter& operator=(Deleter&) { return *this; }
|
||||
|
||||
void operator()(void*) const {}
|
||||
void operator()(void*) const {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
std::unique_ptr<int[], Deleter> p;
|
||||
int main() {
|
||||
#if TEST_STD_VER >= 11
|
||||
// expected-error@memory:* {{call to implicitly-deleted default constructor}}
|
||||
// expected-note@memory:* {{implicitly deleted because base class 'Deleter' has an inaccessible default constructor}}
|
||||
#else
|
||||
// expected-error@memory:* {{base class 'Deleter' has private default constructor}}
|
||||
#endif
|
||||
std::unique_ptr<int[], Deleter> p; // expected-note {{requested here}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user