]> git.lyx.org Git - lyx.git/blobdiff - src/support/lyxalgo.h
Fix bugs #6078 and #9364
[lyx.git] / src / support / lyxalgo.h
index b3a08241b42523727a9cd5777544b8d49f9cb24c..9e44838a795233bf70df36686f3d9eacea068d1a 100644 (file)
@@ -4,7 +4,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS.
  *
@@ -83,6 +83,32 @@ void eliminate_duplicates(C & c)
        c.erase(std::unique(c.begin(), c.end()), c.end());
 }
 
+
+#ifdef LYX_USE_CXX11
+using std::next;
+#else
+/// Replacement of std::next for older compilers
+template <typename It, typename Diff>
+inline It next(It i, Diff n = 1)
+{
+       std::advance(i, n);
+       return i;
+}
+#endif
+
+
+#ifdef LYX_USE_CXX11
+using std::prev;
+#else
+/// Replacement of std::prev for older compilers
+template <typename It, typename Diff>
+inline It prev(It i, Diff n = 1)
+{
+       std::advance(i, -n);
+       return i;
+}
+#endif
+
 } // namespace lyx
 
 #endif // LYX_ALGO_H