What I'm trying to achieve is something like this:
template<typename T> void foo(T t) { TWithoutReferenceType t1 = Magic(t); //some magic here } TWithoutReference is the same type of T but without reference, so for example:
Magic(int i) -> int i Magic(int& i) -> int i Magic(int&& i) -> int i I don't know if this is possible for rvalue references or what it could mean in practice though.
WHY I NEED IT:
template <typename ReturnType, typename... Args> function<ReturnType(Args...)> memoize(const function<ReturnType(Args...)>& func) { return ([=](Args... args) mutable { static map<tuple<Args...>, ReturnType> cache; tuple<Args...> t(args...); auto result = cache.insert(make_pair(t, ReturnType{})); ... So for example if Args ... is vector<double> & and I change the order of the elements, the correspondent key in cache is changed also, and I don't want that this happens, so I don't want that a key change in the future as side effect.
Sorry if I posted the whole code, but I'm afraid that if I make it simpler I'll lose the point of the question.
tuple<Args...>to be a tuple of non-reference types