[Groonga-commit] groonga/grnxx [master] Add a macro GRNXX_ASSERT_POD that checks if a type is a POD type or not.

Back to archive index

susumu.yata null+****@clear*****
Thu Dec 6 10:40:31 JST 2012


susumu.yata	2012-12-06 10:40:31 +0900 (Thu, 06 Dec 2012)

  New Revision: b14c9206174e9a2d9214a8751c58b29c4c3e69df
  https://github.com/groonga/grnxx/commit/b14c9206174e9a2d9214a8751c58b29c4c3e69df

  Log:
    Add a macro GRNXX_ASSERT_POD that checks if a type is a POD type or not.

  Modified files:
    lib/basic.hpp
    lib/duration.hpp
    lib/time.hpp

  Modified: lib/basic.hpp (+6 -0)
===================================================================
--- lib/basic.hpp    2012-12-06 10:10:38 +0900 (cfe684a)
+++ lib/basic.hpp    2012-12-06 10:40:31 +0900 (01010af)
@@ -48,6 +48,12 @@ using std::uint64_t;
 using std::intptr_t;
 using std::uintptr_t;
 
+// TODO: This should use std::is_pod. However, gcc-4.7 uses the C++03 concept.
+#define GRNXX_ASSERT_POD(type)\
+  static_assert(std::is_trivial<type>::value &&\
+                std::is_standard_layout<type>::value,\
+                #type " is not a POD type")
+
 }  // namespace grnxx
 
 #endif  // GRNXX_BASIC_HPP

  Modified: lib/duration.hpp (+2 -0)
===================================================================
--- lib/duration.hpp    2012-12-06 10:10:38 +0900 (b77625c)
+++ lib/duration.hpp    2012-12-06 10:40:31 +0900 (c6f4c56)
@@ -69,6 +69,8 @@ class Duration {
   // Copyable.
 };
 
+GRNXX_ASSERT_POD(Duration);
+
 inline constexpr Duration operator+(Duration duration) {
   return duration;
 }

  Modified: lib/time.hpp (+2 -0)
===================================================================
--- lib/time.hpp    2012-12-06 10:10:38 +0900 (30b3f89)
+++ lib/time.hpp    2012-12-06 10:40:31 +0900 (36d28d4)
@@ -46,6 +46,8 @@ class Time {
   // Copyable.
 };
 
+GRNXX_ASSERT_POD(Time);
+
 inline Time &operator+=(Time &lhs, Duration rhs) {
   lhs.set_nanoseconds(lhs.nanoseconds() + rhs.nanoseconds());
   return lhs;
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index