From 0ea9d1cd23fa58281e3726c088fc7961d8a29a29 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 27 Nov 2022 12:57:42 +0200 Subject: [PATCH] Use constexpr instead of enum to define "typeless" constants --- source/graphics/glcontext.h | 7 ++----- source/input/gesturedetector.h | 5 +---- source/input/touchscreen.h | 5 +---- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/source/graphics/glcontext.h b/source/graphics/glcontext.h index 7f08f0e..c637b39 100644 --- a/source/graphics/glcontext.h +++ b/source/graphics/glcontext.h @@ -11,11 +11,8 @@ class Window; struct GLOptions { - enum - { - DEFAULT_VERSION = 0, - LATEST_VERSION = 0xFFFFFFFF - }; + static constexpr unsigned DEFAULT_VERSION = 0; + static constexpr unsigned LATEST_VERSION = 0xFFFFFFFF; bool alpha = false; bool stencil = false; diff --git a/source/input/gesturedetector.h b/source/input/gesturedetector.h index 7f9726c..0b31fd8 100644 --- a/source/input/gesturedetector.h +++ b/source/input/gesturedetector.h @@ -30,10 +30,7 @@ absolute values greater than one. class GestureDetector: public Device { private: - enum - { - MAX_POINTS = 3 - }; + static constexpr size_t MAX_POINTS = 3; struct TouchPoint { diff --git a/source/input/touchscreen.h b/source/input/touchscreen.h index 487a91c..d366a28 100644 --- a/source/input/touchscreen.h +++ b/source/input/touchscreen.h @@ -11,10 +11,7 @@ namespace Input { class Touchscreen: public Device, public sigc::trackable { private: - enum - { - UNUSED = static_cast(-1) - }; + static constexpr unsigned UNUSED = static_cast(-1); Graphics::Window &window; std::vector active_points; -- 2.45.2