From a054f7af95c6c21581c47bbce1ca8ce67f98c6e2 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Thu, 9 May 2019 11:48:06 -0700 Subject: [PATCH] Update mlir::interleaveComma to work on ranges with types other than Container. -- PiperOrigin-RevId: 247468184 --- mlir/include/mlir/Support/STLExtras.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mlir/include/mlir/Support/STLExtras.h b/mlir/include/mlir/Support/STLExtras.h index 7201c19..e46dcb2 100644 --- a/mlir/include/mlir/Support/STLExtras.h +++ b/mlir/include/mlir/Support/STLExtras.h @@ -28,6 +28,12 @@ namespace mlir { +namespace detail { +template +using ValueOfRange = typename std::remove_reference()))>::type; +} // end namespace detail + /// An STL-style algorithm similar to std::for_each that applies a second /// functor between every pair of elements. /// @@ -58,9 +64,11 @@ inline void interleave(const Container &c, UnaryFunctor each_fn, interleave(c.begin(), c.end(), each_fn, between_fn); } -template class Container, typename raw_ostream> -inline void interleaveComma(const Container &c, raw_ostream &os) { - interleave(c.begin(), c.end(), [&](T a) { os << a; }, [&]() { os << ", "; }); +template > +inline void interleaveComma(const Container &c, raw_ostream &os) { + interleave( + c.begin(), c.end(), [&](const T &a) { os << a; }, [&] { os << ", "; }); } /// A special type used to provide an address for a given class that can act as -- 2.7.4