types: Force underlying int conversion for enums

Boost 1.76.0 changed the behavior of numeric to not accept implicitly
converted ints from enum class types. This breaks many of our casts and
would require 2 casts in most cases.

This adds a convenience function to do the underlying type conversions
needed to cast enums to ints and vice versa.

Change-Id: Id653d6a10ef5cab8267c174848940807d693dbf1
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/user_channel/channelcommands.cpp b/user_channel/channelcommands.cpp
index b774d3f..de32316 100644
--- a/user_channel/channelcommands.cpp
+++ b/user_channel/channelcommands.cpp
@@ -177,7 +177,8 @@
         return responseInvalidFieldRequest();
     }
 
-    if ((accessSetMode == doNotSet) || (accessSetMode == reserved))
+    if ((types::enum_cast<EChannelActionType>(accessSetMode) == doNotSet) ||
+        (types::enum_cast<EChannelActionType>(accessSetMode) == reserved))
     {
         log<level::DEBUG>("Get channel access - Invalid Access mode");
         return responseInvalidFieldRequest();
@@ -197,11 +198,11 @@
 
     Cc compCode;
 
-    if (accessSetMode == nvData)
+    if (types::enum_cast<EChannelActionType>(accessSetMode) == nvData)
     {
         compCode = getChannelAccessPersistData(chNum, chAccess);
     }
-    else if (accessSetMode == activeData)
+    else if (types::enum_cast<EChannelActionType>(accessSetMode) == activeData)
     {
         compCode = getChannelAccessData(chNum, chAccess);
     }
@@ -215,9 +216,10 @@
     constexpr uint4_t reservedOut2 = 0;
 
     return responseSuccess(
-        static_cast<uint3_t>(chAccess.accessMode), chAccess.userAuthDisabled,
-        chAccess.perMsgAuthDisabled, chAccess.alertingDisabled, reservedOut1,
-        static_cast<uint4_t>(chAccess.privLimit), reservedOut2);
+        types::enum_cast<uint3_t>(chAccess.accessMode),
+        chAccess.userAuthDisabled, chAccess.perMsgAuthDisabled,
+        chAccess.alertingDisabled, reservedOut1,
+        types::enum_cast<uint4_t>(chAccess.privLimit), reservedOut2);
 }
 
 /** @brief implements the get channel info command