summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-03-23 18:38:30 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-03-23 21:22:34 (GMT)
commitde0d57c97abe88a1025d5a26ed94a82438468349 (patch)
treee87f638c094b27dd37fdb2af9895bc618f941c67 /Source/cmTarget.cxx
parentecc782c75d7ce98c03164f616e9adf9760ce0d7f (diff)
downloadCMake-de0d57c97abe88a1025d5a26ed94a82438468349.zip
CMake-de0d57c97abe88a1025d5a26ed94a82438468349.tar.gz
CMake-de0d57c97abe88a1025d5a26ed94a82438468349.tar.bz2
cmTarget: Use std::unique_ptr instead of custom smart pointer
To manage the lifetime of `cmTargetInternals`, the private implementation of `cmTarget`, use `std::unique_ptr<cmTargetInternals>` instead of `cmTargetInternalPointer`, which is removed. `cmTarget` is made non-copyable but movable.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx40
1 files changed, 6 insertions, 34 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index a92bb9b..38bff1b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -215,6 +215,7 @@ public:
cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
Visibility vis, cmMakefile* mf)
+ : impl(cm::make_unique<cmTargetInternals>())
{
assert(mf);
impl->TargetType = type;
@@ -500,6 +501,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
}
}
+cmTarget::cmTarget(cmTarget&&) noexcept = default;
+cmTarget::~cmTarget() = default;
+
+cmTarget& cmTarget::operator=(cmTarget&&) noexcept = default;
+
cmStateEnums::TargetType cmTarget::GetType() const
{
return impl->TargetType;
@@ -1967,37 +1973,3 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
return true;
}
-
-cmTargetInternalPointer::cmTargetInternalPointer()
-{
- this->Pointer = new cmTargetInternals;
-}
-
-cmTargetInternalPointer::cmTargetInternalPointer(
- cmTargetInternalPointer const& r)
-{
- // Ideally cmTarget instances should never be copied. However until
- // we can make a sweep to remove that, this copy constructor avoids
- // allowing the resources (Internals) to be copied.
- this->Pointer = new cmTargetInternals(*r.Pointer);
-}
-
-cmTargetInternalPointer::~cmTargetInternalPointer()
-{
- delete this->Pointer;
-}
-
-cmTargetInternalPointer& cmTargetInternalPointer::operator=(
- cmTargetInternalPointer const& r)
-{
- if (this == &r) {
- return *this;
- } // avoid warning on HP about self check
- // Ideally cmTarget instances should never be copied. However until
- // we can make a sweep to remove that, this copy constructor avoids
- // allowing the resources (Internals) to be copied.
- cmTargetInternals* oldPointer = this->Pointer;
- this->Pointer = new cmTargetInternals(*r.Pointer);
- delete oldPointer;
- return *this;
-}