[llvm] r202883 - APFloat: Add a move ctor and operator=
Benjamin Kramer
benny.kra at googlemail.com
Tue Mar 4 12:26:52 PST 2014
Author: d0k
Date: Tue Mar 4 14:26:51 2014
New Revision: 202883
URL: http://llvm.org/viewvc/llvm-project?rev=202883&view=rev
Log:
APFloat: Add a move ctor and operator=
Modified:
llvm/trunk/include/llvm/ADT/APFloat.h
llvm/trunk/lib/Support/APFloat.cpp
Modified: llvm/trunk/include/llvm/ADT/APFloat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=202883&r1=202882&r2=202883&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APFloat.h (original)
+++ llvm/trunk/include/llvm/ADT/APFloat.h Tue Mar 4 14:26:51 2014
@@ -196,6 +196,7 @@ public:
explicit APFloat(double d);
explicit APFloat(float f);
APFloat(const APFloat &);
+ APFloat(APFloat &&);
~APFloat();
/// @}
@@ -411,6 +412,7 @@ public:
/// @}
APFloat &operator=(const APFloat &);
+ APFloat &operator=(APFloat &&);
/// \brief Overload to compute a hash code for an APFloat value.
///
Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=202883&r1=202882&r2=202883&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Tue Mar 4 14:26:51 2014
@@ -683,6 +683,20 @@ APFloat::operator=(const APFloat &rhs)
return *this;
}
+APFloat &
+APFloat::operator=(APFloat &&rhs) {
+ freeSignificand();
+
+ semantics = rhs.semantics;
+ significand = rhs.significand;
+ exponent = rhs.exponent;
+ category = rhs.category;
+ sign = rhs.sign;
+
+ rhs.semantics = &Bogus;
+ return *this;
+}
+
bool
APFloat::isDenormal() const {
return isFiniteNonZero() && (exponent == semantics->minExponent) &&
@@ -806,6 +820,10 @@ APFloat::APFloat(const APFloat &rhs) {
assign(rhs);
}
+APFloat::APFloat(APFloat &&rhs) : semantics(&Bogus) {
+ *this = std::move(rhs);
+}
+
APFloat::~APFloat()
{
freeSignificand();
More information about the llvm-commits
mailing list