aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/variable.cxx46
1 files changed, 28 insertions, 18 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index a8e3c77..da7446d 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -73,19 +73,24 @@ namespace build2
// Now our types are the same. If the receiving value is NULL, then call
// copy_ctor() instead of copy_assign().
//
- if (type == nullptr)
+ if (!v.null ())
{
- if (null ())
- new (&data_) names (move (v).as<names> ());
+ if (type == nullptr)
+ {
+ if (null ())
+ new (&data_) names (move (v).as<names> ());
+ else
+ as<names> () = move (v).as<names> ();
+ }
+ else if (auto f = null () ? type->copy_ctor : type->copy_assign)
+ f (*this, v, true);
else
- as<names> () = move (v).as<names> ();
+ data_ = v.data_; // Assign as POD.
+
+ state = v.state;
}
- else if (auto f = null () ? type->copy_ctor : type->copy_assign)
- f (*this, v, true);
else
- data_ = v.data_; // Assign as POD.
-
- state = v.state;
+ *this = nullptr;
}
return *this;
@@ -109,19 +114,24 @@ namespace build2
// Now our types are the same. If the receiving value is NULL, then call
// copy_ctor() instead of copy_assign().
//
- if (type == nullptr)
+ if (!v.null ())
{
- if (null ())
- new (&data_) names (v.as<names> ());
+ if (type == nullptr)
+ {
+ if (null ())
+ new (&data_) names (v.as<names> ());
+ else
+ as<names> () = v.as<names> ();
+ }
+ else if (auto f = null () ? type->copy_ctor : type->copy_assign)
+ f (*this, v, false);
else
- as<names> () = v.as<names> ();
+ data_ = v.data_; // Assign as POD.
+
+ state = v.state;
}
- else if (auto f = null () ? type->copy_ctor : type->copy_assign)
- f (*this, v, false);
else
- data_ = v.data_; // Assign as POD.
-
- state = v.state;
+ *this = nullptr;
}
return *this;