summaryrefslogtreecommitdiff
path: root/gi/toggle.h
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2020-08-01 13:46:57 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2020-08-05 18:15:31 -0700
commita4d40792f6b39772197137d7737b3f4daf2022f0 (patch)
treed7ae826a5af234bc93d7e01b54f3fe464a37216e /gi/toggle.h
parenta1cf3f6330e9f98421c37a536f4acafc53d5a72a (diff)
downloadgjs-a4d40792f6b39772197137d7737b3f4daf2022f0.tar.gz
maint: Use C++17 attributes
Now that we depend on C++17, we can use these attributes that are part of the language, instead of relying on macros to make them portable. (GJS_USE still needs to be defined for public header files, which may be compiled in C.) Attributes which are new in C++17 are [[maybe_unused]], [[nodiscard]], and [[fallthrough]]. [skip cpplint] because cpplint doesn't deal with C++ attributes: https://github.com/google/styleguide/issues/165
Diffstat (limited to 'gi/toggle.h')
-rw-r--r--gi/toggle.h22
1 files changed, 8 insertions, 14 deletions
diff --git a/gi/toggle.h b/gi/toggle.h
index fa7e01ae..49f61b7f 100644
--- a/gi/toggle.h
+++ b/gi/toggle.h
@@ -34,7 +34,6 @@
#include <glib-object.h>
#include <glib.h>
-#include "gjs/macros.h"
#include "util/log.h"
/* Thread-safe queue for enqueueing toggle-up or toggle-down events on GObjects
@@ -69,16 +68,14 @@ private:
gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "ToggleQueue %s %p", did, what);
}
- GJS_USE
- std::deque<Item>::iterator find_operation_locked(const GObject *gobj,
- Direction direction);
+ [[nodiscard]] std::deque<Item>::iterator find_operation_locked(
+ const GObject* gobj, Direction direction);
- GJS_USE
- std::deque<Item>::const_iterator find_operation_locked(const GObject *gobj,
- Direction direction) const;
+ [[nodiscard]] std::deque<Item>::const_iterator find_operation_locked(
+ const GObject* gobj, Direction direction) const;
- GJS_USE
- bool find_and_erase_operation_locked(const GObject *gobj, Direction direction);
+ [[nodiscard]] bool find_and_erase_operation_locked(const GObject* gobj,
+ Direction direction);
static gboolean idle_handle_toggle(void *data);
static void idle_destroy_notify(void *data);
@@ -86,8 +83,7 @@ private:
public:
/* These two functions return a pair DOWN, UP signifying whether toggles
* are / were queued. is_queued() just checks and does not modify. */
- GJS_USE
- std::pair<bool, bool> is_queued(GObject *gobj) const;
+ [[nodiscard]] std::pair<bool, bool> is_queued(GObject* gobj) const;
/* Cancels pending toggles and returns whether any were queued. */
std::pair<bool, bool> cancel(GObject *gobj);
@@ -106,9 +102,7 @@ private:
Direction direction,
Handler handler);
- GJS_USE
- static ToggleQueue&
- get_default(void) {
+ [[nodiscard]] static ToggleQueue& get_default() {
static ToggleQueue the_singleton;
return the_singleton;
}