[libcxx] Fix C++14 and up constexpr members in MoveOnly.

Summary: a4b8ee6 made all MoveOnly members constexpr but, some members and constructors contain expressions that are only valid in C++14 and later. This patch prefixes those methods and constructors with TEST_CONSTEXPR_CXX14.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80482
This commit is contained in:
zoecarver 2020-05-23 14:43:12 -07:00
parent e0aefaedb6
commit 37ef15143a
1 changed files with 6 additions and 4 deletions

View File

@ -24,17 +24,19 @@ class MoveOnly
int data_;
public:
constexpr MoveOnly(int data = 1) : data_(data) {}
constexpr MoveOnly(MoveOnly&& x)
TEST_CONSTEXPR_CXX14 MoveOnly(MoveOnly&& x)
: data_(x.data_) {x.data_ = 0;}
constexpr MoveOnly& operator=(MoveOnly&& x)
TEST_CONSTEXPR_CXX14 MoveOnly& operator=(MoveOnly&& x)
{data_ = x.data_; x.data_ = 0; return *this;}
constexpr int get() const {return data_;}
constexpr bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
constexpr bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
constexpr MoveOnly operator+(const MoveOnly& x) const { return MoveOnly{data_ + x.data_}; }
constexpr MoveOnly operator*(const MoveOnly& x) const { return MoveOnly{data_ * x.data_}; }
TEST_CONSTEXPR_CXX14 MoveOnly operator+(const MoveOnly& x) const
{ return MoveOnly{data_ + x.data_}; }
TEST_CONSTEXPR_CXX14 MoveOnly operator*(const MoveOnly& x) const
{ return MoveOnly{data_ * x.data_}; }
};
namespace std {