Add a new (simple) StringMap::clear method, patch by Pratik
[oota-llvm.git] / include / llvm / ADT / STLExtras.h
index 14137e3c1017e0ff6e13fb209ad2e9ff4b4b79be..f1883959d762c351250bfc6388ac772a409bfdf2 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -19,7 +19,8 @@
 
 #include <functional>
 #include <utility> // for std::pair
-#include "llvm/ADT/iterator"
+#include <cstring> // for std::size_t
+#include "llvm/ADT/iterator.h"
 
 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