I have a seemingly simple question that I do not know how to solve.
Imagine the following method template
template<typename T> void Add(T& var);
where specializations can add something to the container (sort of). I can pass the POD or more complex types, such as strings , and that's why I give T as a reference.
The problem is that whenever I want to call the Add (...) with the result of another method, for example:
Add(MethodThatReturnsAnInt());
It will not work, and to save the result MethodThatReturnsAnInt() requires a temporary variable.
Is there a way to overload Add , so I had a reference transfer and non-reference version?
template<typename T> void Add(T& var); template<typename T> void Add(T var);
will std::enable_if be used in this situation?
source share