]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: short variable template with suffix_v/_t
authorChangcheng Liu <changcheng.liu@aliyun.com>
Mon, 22 Jun 2020 01:39:59 +0000 (09:39 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Mon, 22 Jun 2020 02:08:37 +0000 (10:08 +0800)
Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/common/options.h
src/common/strtol.h

index f0ed014e3039412656902d451edd893c9e8186c1..75812c234503c9d5aa75aef1adea6803bab397ea 100644 (file)
@@ -236,12 +236,12 @@ struct Option {
 
   // bool is an integer, but we don't think so. teach it the hard way.
   template<typename T>
-  using is_not_integer = std::enable_if<!std::is_integral<T>::value ||
-                                       std::is_same<T, bool>::value, int>;
+  using is_not_integer_t =
+      std::enable_if_t<!std::is_integral_v<T> || std::is_same_v<T, bool>, int>;
   template<typename T>
-  using is_integer = std::enable_if<std::is_integral<T>::value &&
-                                   !std::is_same<T, bool>::value, int>;
-  template<typename T, typename is_not_integer<T>::type = 0>
+  using is_integer_t =
+      std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>, int>;
+  template<typename T, typename = is_not_integer_t<T>>
   Option& set_value(value_t& v, const T& new_value) {
     v = new_value;
     return *this;
@@ -250,7 +250,7 @@ struct Option {
   // For potentially ambiguous types, inspect Option::type and
   // do some casting.  This is necessary to make sure that setting
   // a float option to "0" actually sets the double part of variant.
-  template<typename T, typename is_integer<T>::type = 0>
+  template<typename T, typename = is_integer_t<T>>
   Option& set_value(value_t& v, T new_value) {
     switch (type) {
     case TYPE_INT:
index a7c0cc220b6f9c6f02c5c1dde5d612d3ff59d9b4..6d722269320b9e50556068bf59b13745fba5a186 100644 (file)
@@ -47,7 +47,7 @@ template<typename T, const unsigned base = 10, const unsigned width = 1>
 static inline
 char* ritoa(T u, char *buf)
 {
-  static_assert(std::is_unsigned<T>::value, "signed types are not supported");
+  static_assert(std::is_unsigned_v<T>, "signed types are not supported");
   static_assert(base <= 16, "extend character map below to support higher bases");
   unsigned digits = 0;
   while (u) {