aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTypes.h
diff options
context:
space:
mode:
authorGravatar Chris Blume <cblume@google.com>2017-04-25 17:33:13 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-26 01:24:24 +0000
commit2b6be207a1b4595646950324ab1ccf0e3b9f73ac (patch)
tree6ee7055940faefc3736737db29152c24901e2160 /include/core/SkTypes.h
parent101806f4526d0ba5d48515c82a28dbf6956aca4d (diff)
Make SkNoncopyable movable
SkNoncopyable declares (but does not define) its copy constructor and copy assignment operator. These are also private so the error for misuse happens at compile-time instead of link-time. However, this seems to be from before C++11. Because other constructors were declared, the compiler does not generate a move constructor or a move assignment operator. The result of this is perfectly legal non-copying scenarios are also accidentally blocked. An example of this is returning the non-copyable type. The object being returned is a candidate for a move, since it is about to be destroyed. And in C++17 copy elision is actually guaranteed. Change-Id: Ia31be9091c644f31a45dd18216330a68be3cf456 Reviewed-on: https://skia-review.googlesource.com/14294 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'include/core/SkTypes.h')
-rw-r--r--include/core/SkTypes.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index beb2be5143..1dd672bea4 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -442,11 +442,13 @@ be copied. It hides its copy-constructor and its assignment-operator.
*/
class SK_API SkNoncopyable {
public:
- SkNoncopyable() {}
+ SkNoncopyable() = default;
-private:
- SkNoncopyable(const SkNoncopyable&);
- SkNoncopyable& operator=(const SkNoncopyable&);
+ SkNoncopyable(SkNoncopyable&&) = default;
+ SkNoncopyable& operator =(SkNoncopyable&&) = default;
+
+ SkNoncopyable(const SkNoncopyable&) = delete;
+ SkNoncopyable& operator=(const SkNoncopyable&) = delete;
};
#endif /* C++ */