Add remaining functions necessary for andersen's
[oota-llvm.git] / include / llvm / ADT / STLExtras.h
index 14137e3c1017e0ff6e13fb209ad2e9ff4b4b79be..9a17e6cce903580eb368320fd82e8ce79004d099 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <functional>
 #include <utility> // for std::pair
+#include <cstring> // for std::size_t
 #include "llvm/ADT/iterator"
 
 namespace llvm {
@@ -199,6 +200,24 @@ inline tier<T1, T2> tie(T1& f, T2& s) {
   return tier<T1, T2>(f, s);
 }
 
+//===----------------------------------------------------------------------===//
+//     Extra additions to arrays
+//===----------------------------------------------------------------------===//
+
+/// Find where an array ends (for ending iterators)
+/// This returns a pointer to the byte immediately
+/// after the end of an array.
+template<class T, std::size_t N>
+inline T *array_endof(T (&x)[N]) {
+  return x+N;
+}
+
+/// Find the length of an array.
+template<class T, std::size_t N>
+inline size_t array_lengthof(T (&x)[N]) {
+  return N;
+}
+
 } // End llvm namespace
 
 #endif