From 6c61a8a9fa3d569761b5bdf5f98d654efc038271 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Wed, 3 May 2023 20:15:00 +0300 Subject: [PATCH] Use unsigned char as the underlying type for the tribool state. This makes sizeof(tribool) == 1, which is similar to sizeof(bool) on most platforms. This is only enabled when C++11 scoped enums are supported. --- include/boost/logic/tribool.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/logic/tribool.hpp b/include/boost/logic/tribool.hpp index b4c4a01..e5eb0a4 100644 --- a/include/boost/logic/tribool.hpp +++ b/include/boost/logic/tribool.hpp @@ -131,7 +131,11 @@ class tribool * The actual stored value in this 3-state boolean, which may be false, true, * or indeterminate. */ - enum value_t { false_value, true_value, indeterminate_value } value; + enum value_t +#if !defined( BOOST_NO_CXX11_SCOPED_ENUMS ) + : unsigned char +#endif + { false_value, true_value, indeterminate_value } value; }; // Check if the given tribool has an indeterminate value. Also doubles as a