[Bf-blender-cvs] [f7d5d4ee3ba] master: Cleanup: use c++17 helper variable templates

Jacques Lucke noreply at git.blender.org
Wed Jul 8 20:39:36 CEST 2020


Commit: f7d5d4ee3bad522691fba36fcfae321a28752d20
Author: Jacques Lucke
Date:   Wed Jul 8 20:39:12 2020 +0200
Branches: master
https://developer.blender.org/rBf7d5d4ee3bad522691fba36fcfae321a28752d20

Cleanup: use c++17 helper variable templates

===================================================================

M	source/blender/blenlib/BLI_hash_tables.hh
M	source/blender/blenlib/BLI_map.hh
M	source/blender/blenlib/BLI_memory_utils.hh
M	source/blender/blenlib/BLI_span.hh
M	source/blender/functions/FN_cpp_type.hh

===================================================================

diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh
index 5f9e06c5a64..aaed772071d 100644
--- a/source/blender/blenlib/BLI_hash_tables.hh
+++ b/source/blender/blenlib/BLI_hash_tables.hh
@@ -65,13 +65,13 @@ inline constexpr uint32_t power_of_2_max_u_constexpr(const uint32_t x)
 
 template<typename IntT> inline constexpr IntT ceil_division(const IntT x, const IntT y)
 {
-  BLI_STATIC_ASSERT(!std::is_signed<IntT>::value, "");
+  BLI_STATIC_ASSERT(!std::is_signed_v<IntT>, "");
   return x / y + ((x % y) != 0);
 }
 
 template<typename IntT> inline constexpr IntT floor_division(const IntT x, const IntT y)
 {
-  BLI_STATIC_ASSERT(!std::is_signed<IntT>::value, "");
+  BLI_STATIC_ASSERT(!std::is_signed_v<IntT>, "");
   return x / y;
 }
 
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index ab13305db6d..6bbd4ee09db 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -1050,7 +1050,7 @@ class Map {
   {
     using CreateReturnT = decltype(create_value(nullptr));
     using ModifyReturnT = decltype(modify_value(nullptr));
-    BLI_STATIC_ASSERT((std::is_same<CreateReturnT, ModifyReturnT>::value),
+    BLI_STATIC_ASSERT((std::is_same_v<CreateReturnT, ModifyReturnT>),
                       "Both callbacks should return the same type.");
 
     this->ensure_can_add();
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index 4e7234b85fb..16d6227a551 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -49,7 +49,7 @@ template<typename T> void destruct_n(T *ptr, uint n)
 
   /* This is not strictly necessary, because the loop below will be optimized away anyway. It is
    * nice to make behavior this explicitly, though. */
-  if (std::is_trivially_destructible<T>::value) {
+  if (std::is_trivially_destructible_v<T>) {
     return;
   }
 
@@ -73,7 +73,7 @@ template<typename T> void default_construct_n(T *ptr, uint n)
 {
   /* This is not strictly necessary, because the loop below will be optimized away anyway. It is
    * nice to make behavior this explicitly, though. */
-  if (std::is_trivially_constructible<T>::value) {
+  if (std::is_trivially_constructible_v<T>) {
     return;
   }
 
diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh
index 92d3124e01d..3da96f1f107 100644
--- a/source/blender/blenlib/BLI_span.hh
+++ b/source/blender/blenlib/BLI_span.hh
@@ -128,8 +128,7 @@ template<typename T> class Span {
    *   Span<T *> -> Span<const T *>
    *   Span<Derived *> -> Span<Base *>
    */
-  template<typename U,
-           typename std::enable_if<std::is_convertible<U *, T>::value>::type * = nullptr>
+  template<typename U, typename std::enable_if_t<std::is_convertible_v<U *, T>> * = nullptr>
   Span(Span<U *> array) : Span((T *)array.data(), array.size())
   {
   }
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh
index 890530805d8..7aa71952427 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/functions/FN_cpp_type.hh
@@ -204,7 +204,7 @@ class CPPType {
    * for optimization purposes.
    *
    * C++ equivalent:
-   *   std::is_trivially_destructible<T>::value;
+   *   std::is_trivially_destructible_v<T>;
    */
   bool is_trivially_destructible() const
   {
@@ -721,7 +721,7 @@ static std::unique_ptr<const CPPType> create_cpp_type(StringRef name, const T &d
   const CPPType *type = new CPPType(name,
                                     sizeof(T),
                                     alignof(T),
-                                    std::is_trivially_destructible<T>::value,
+                                    std::is_trivially_destructible_v<T>,
                                     construct_default_cb<T>,
                                     construct_default_n_cb<T>,
                                     construct_default_indices_cb<T>,



More information about the Bf-blender-cvs mailing list