[PATCH] D131289: [ADT] Add is_splat overload accepting initializer_list

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 7 10:55:31 PDT 2022


kuhar added inline comments.


================
Comment at: llvm/include/llvm/ADT/STLExtras.h:1801
+template <typename T> bool is_splat(std::initializer_list<T> Values) {
+  return is_splat(make_range(Values.begin(), Values.end()));
+}
----------------
dblaikie wrote:
> hmm, `Values` is already a valid range, so it's a bit awkward/unfortunate to make a new range from it.
> 
> could we make this add the template parameter explicitly?
> ```
> return is_splat<std::initializer_list<T>>(std::move(Values));
> ```
> (the move doesn't do much (since `std::initializer_list` is immutable, yeah?), but I think it's that or you have to make the parameter a reference type, to work with the universal reference stuff?)
This looked like an infinite recursion to me initially, but you are right, `move` does fix it. Thanks for the suggestion!





CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131289/new/

https://reviews.llvm.org/D131289



More information about the llvm-commits mailing list