diff options
author | Murray Cumming <murrayc@murrayc.com> | 2015-08-15 13:59:45 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2015-08-15 14:02:18 +0200 |
commit | c18212e3a4f10f449c4868e4db2fd46f95871812 (patch) | |
tree | 7d6c6c486b43ec2bcda02a0c4ac3b07de13406dc /tools | |
parent | a4695d98322d7d2e8c0a64dc5cb26e10e3dedb1e (diff) | |
download | glibmm-c18212e3a4f10f449c4868e4db2fd46f95871812.tar.gz |
Boxed types: Declare move operations as noexcept.
Because this can let standard containers more efficiently reallocate
memory while still preserving their own noexcept guarantees.
I found out about this in Scott Meyer's Effective Modern C++11:
Item 14.
Likewise make swap() noexcept because we use it in our noexcept
move assignment operator.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/m4/class_boxedtype.m4 | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/m4/class_boxedtype.m4 b/tools/m4/class_boxedtype.m4 index 1afa53a5..3df7f691 100644 --- a/tools/m4/class_boxedtype.m4 +++ b/tools/m4/class_boxedtype.m4 @@ -135,14 +135,14 @@ __CPPNAME__::__CPPNAME__`'(const __CPPNAME__& other) gobject_ ((other.gobject_) ? __BOXEDTYPE_FUNC_COPY`'(other.gobject_) : 0) {} -__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& other) +__CPPNAME__::__CPPNAME__`'(__CPPNAME__&& other) noexcept : gobject_(other.gobject_) { other.gobject_ = nullptr; } -__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__`'&& other) +__CPPNAME__& __CPPNAME__::operator=(__CPPNAME__`'&& other) noexcept { __CPPNAME__ temp (other); swap(temp); @@ -173,7 +173,7 @@ dnl This could be a free or an unref, we do not need to know. __BOXEDTYPE_FUNC_FREE`'(gobject_); } -void __CPPNAME__::swap(__CPPNAME__& other) +void __CPPNAME__::swap(__CPPNAME__& other) noexcept { __CNAME__ *const temp = gobject_; gobject_ = other.gobject_; @@ -222,13 +222,13 @@ ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else __CPPNAME__`'(const __CPPNAME__& other); __CPPNAME__& operator=(const __CPPNAME__& other); - __CPPNAME__`'(__CPPNAME__&& other); - __CPPNAME__& operator=(__CPPNAME__&& other); + __CPPNAME__`'(__CPPNAME__&& other) noexcept; + __CPPNAME__& operator=(__CPPNAME__&& other) noexcept; _IMPORT(SECTION_DTOR_DOCUMENTATION) ~__CPPNAME__`'(); - void swap(__CPPNAME__& other); + void swap(__CPPNAME__& other) noexcept; ///Provides access to the underlying C instance. __CNAME__* gobj() { return gobject_; } |