From: Mikko Rasa Date: Sun, 27 Nov 2022 10:57:42 +0000 (+0200) Subject: Use constexpr instead of enum to define "typeless" constants X-Git-Url: http://git.tdb.fi/?p=libs%2Fgui.git;a=commitdiff_plain;h=0ea9d1cd23fa58281e3726c088fc7961d8a29a29 Use constexpr instead of enum to define "typeless" constants --- 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;