]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
denc: remove conditional underlying_type_t from ceph_le* traits
authorCasey Bodley <cbodley@redhat.com>
Mon, 2 Mar 2020 20:23:48 +0000 (15:23 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 2 Mar 2020 21:09:23 +0000 (16:09 -0500)
an enum's underlying type must be integral, so it's not possible for
ceph_le<T> to match for enums. for example, this:

  enum class enum_class_16 : ceph_le16 {};

fails to compile with:
underlying type ‘ceph_le16’ {aka ‘ceph_le<short unsigned int>’} of
‘enum_class_16’ must be an integral type

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/include/denc.h

index adb93ad16a1afbd2b37b4497652c4047b2246178..6eb027cc0f5d103b92ad4bdac597ad2c9cac7149 100644 (file)
@@ -268,17 +268,7 @@ template<typename T> int DencDumper<T>::i = 0;
 namespace _denc {
 template<typename T, typename... Us>
 inline constexpr bool is_any_of = (... || std::is_same_v<T, Us>);
-
-template<typename T, typename=void> struct underlying_type {
-  using type = T;
-};
-template<typename T>
-struct underlying_type<T, std::enable_if_t<std::is_enum_v<T>>> {
-  using type = std::underlying_type_t<T>;
-};
-template<typename T>
-using underlying_type_t = typename underlying_type<T>::type;
-}
+} // namespace _denc
 
 template<class It>
 struct is_const_iterator
@@ -307,11 +297,12 @@ get_pos_add(It& i) {
   return *reinterpret_cast<T*>(i.get_pos_add(sizeof(T)));
 }
 
+// network-order integer encoding
 template<typename T>
 struct denc_traits<
   T,
   std::enable_if_t<
-    _denc::is_any_of<_denc::underlying_type_t<T>,
+    _denc::is_any_of<T,
                     ceph_le64, ceph_le32, ceph_le16, uint8_t
 #ifndef _CHAR_IS_SIGNED
                       , int8_t