[Liblas-commits] r1219 - trunk/include/liblas/detail

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 16 11:12:57 EDT 2009


Author: mloskot
Date: Thu Apr 16 11:12:57 2009
New Revision: 1219
URL: http://liblas.org/changeset/1219

Log:
liblas/detail/utility.hpp: added template function static_array_size() to calculate size of static-defined arrays in compile-time.

Modified:
   trunk/include/liblas/detail/utility.hpp

Modified: trunk/include/liblas/detail/utility.hpp
==============================================================================
--- trunk/include/liblas/detail/utility.hpp	(original)
+++ trunk/include/liblas/detail/utility.hpp	Thu Apr 16 11:12:57 2009
@@ -44,28 +44,35 @@
 
 #include <liblas/cstdint.hpp>
 #include <liblas/detail/endian.hpp>
+// std
+#include <cstddef>
+#include <cstring>
+#include <cassert>
 #include <algorithm>
+#include <iosfwd>
 #include <limits>
 #include <sstream>
 #include <stdexcept>
-#include <iosfwd>
-#include <cstring>
-#include <cassert>
 
 //
 // Private macros definition
 //
-
 #ifndef UNREFERENCED_PARAMETER
 #define UNREFERENCED_PARAMETER(param) ((void)param)
 #endif
 
-//
-// Private utilities for internal use in libLAS
-//
-
+/// Defines utilities for internal use in libLAS.
+/// The liblas::detail elements do not belong to the public
+/// interface of libLAS.
 namespace liblas { namespace detail {
 
+/// Compile-time calculation size of array defined statically.
+template <typename T, std::size_t N>
+inline std::size_t static_array_size(T (&t)[N])
+{
+    return (sizeof(t) / sizeof(t[0]));
+}
+
 /// Simple RAII wrapper.
 /// It's dedicated to use with types associated with custom deleter,
 /// opaque pointers and C API objects.


More information about the Liblas-commits mailing list