[glibmm] Glib::OptionGroup: Don't allow copy or move
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Glib::OptionGroup: Don't allow copy or move
- Date: Thu, 23 Mar 2017 16:21:03 +0000 (UTC)
commit bec7c75197056293d185a297e357181e20d5a83b
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Thu Mar 23 17:17:11 2017 +0100
Glib::OptionGroup: Don't allow copy or move
The GOptionGroup contains a pointer to the Glib::OptionGroup wrapper.
That pointer can't be changed. Copying (adding a ref) or moving a
GOptionGroup to a second Glib::OptionGroup would be problematic.
glib/src/optiongroup.ccg | 20 --------------------
glib/src/optiongroup.hg | 9 +++++++--
2 files changed, 7 insertions(+), 22 deletions(-)
---
diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg
index ab80bcb..08cfe6d 100644
--- a/glib/src/optiongroup.ccg
+++ b/glib/src/optiongroup.ccg
@@ -294,26 +294,6 @@ OptionGroup::OptionGroup(GOptionGroup* castitem) : gobject_(castitem)
// Always takes ownership - never takes copy.
}
-OptionGroup::OptionGroup(OptionGroup&& other) noexcept
- : map_entries_(std::move(other.map_entries_)),
- gobject_(std::move(other.gobject_))
-{
- other.gobject_ = nullptr;
-}
-
-OptionGroup&
-OptionGroup::operator=(OptionGroup&& other) noexcept
-{
- release_gobject();
-
- map_entries_ = std::move(other.map_entries_);
- gobject_ = std::move(other.gobject_);
-
- other.gobject_ = nullptr;
-
- return *this;
-}
-
void
OptionGroup::release_gobject() noexcept
{
diff --git a/glib/src/optiongroup.hg b/glib/src/optiongroup.hg
index 456f238..5fbdcbf 100644
--- a/glib/src/optiongroup.hg
+++ b/glib/src/optiongroup.hg
@@ -78,8 +78,13 @@ public:
explicit OptionGroup(GOptionGroup* castitem);
_IGNORE(g_option_group_new, g_option_group_ref)
- OptionGroup(OptionGroup&& other) noexcept;
- OptionGroup& operator=(OptionGroup&& other) noexcept;
+ // OptionGroup can't be copied or moved. The underlying GOptionGroup contains
+ // a pointer to the wrapper, set in the call to g_option_group_new().
+ // That pointer can't be changed.
+ OptionGroup(const OptionGroup& other) = delete;
+ OptionGroup& operator=(const OptionGroup& other) = delete;
+ OptionGroup(OptionGroup&& other) = delete;
+ OptionGroup& operator=(OptionGroup&& other) = delete;
virtual ~OptionGroup();
_IGNORE(g_option_group_free, g_option_group_unref)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]