]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/cpp-btree: use static_assert()
authorKefu Chai <kchai@redhat.com>
Tue, 24 Dec 2019 10:03:05 +0000 (18:03 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 24 Dec 2019 16:25:39 +0000 (00:25 +0800)
instead of using a homebrew replacement

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/cpp-btree/btree.h

index 321b30a6af3f75bdb0483c1f146cf55c392c3dc5..df103cf1517851bb6424120f979143a16e6e6ab0 100644 (file)
@@ -149,14 +149,6 @@ struct big_ {
   char dummy[2];
 };
 
-// A compile-time assertion.
-template <bool>
-struct CompileAssert {
-};
-
-#define COMPILE_ASSERT(expr, msg) \
-  typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-
 // A helper type used to indicate that a key-compare-to functor has been
 // provided. A user can specify a key-compare-to functor by doing:
 //
@@ -1406,20 +1398,20 @@ class btree : public Params::key_compare {
   // key_compare_checker() to instantiate and then figure out the size of the
   // return type of key_compare_checker() at compile time which we then check
   // against the sizeof of big_.
-  COMPILE_ASSERT(
+  static_assert(
       sizeof(key_compare_checker(key_compare_helper()(key_type(), key_type()))) ==
       sizeof(big_),
-      key_comparison_function_must_return_bool);
+      "key comparison function must return bool");
 
   // Note: We insist on kTargetValues, which is computed from
   // Params::kTargetNodeSize, must fit the base_fields::field_type.
-  COMPILE_ASSERT(kNodeValues <
-                 (1 << (8 * sizeof(typename base_fields::field_type))),
-                 target_node_size_too_large);
+  static_assert(kNodeValues <
+                (1 << (8 * sizeof(typename base_fields::field_type))),
+                "target node size too large");
 
   // Test the assumption made in setting kNodeValueSpace.
-  COMPILE_ASSERT(sizeof(base_fields) >= 2 * sizeof(void*),
-                 node_space_assumption_incorrect);
+  static_assert(sizeof(base_fields) >= 2 * sizeof(void*),
+                "node space assumption incorrect");
 };
 
 ////