I am building a simple piping operator for vectors, which the user would use like this (pseudocode):
auto x = std::vector{1,2,3} | push_back(10)
| push_back(100)
;
Now I tried defining the piping operator like so:
template <typename T>
constexpr inline auto& operator| (std::vector<T>&& vec, std::invocable<std::vector<T>> auto&& func);
But now vec only to r-values (because the type of vec itself is not deduced) ! But I want it to bind to l-values too. How can I do it?
One ugly but functional solution would be to make another overload for my piping operator but with std::vector<int>&. However this is not scalable, ( 2 ^ n overloads for n arguments!), and I believe this is the very reason universal references were created.
How can I use universal references in this case?