I have function which should taken several parameters and after add all parameters to *this
, operator+=
is overloaded and work for one parameter. Function look like
template <typename T, typename U>
struct are_equal :
std::is_same<typename std::decay<T>::type, U>::type
{};
template<typename T>
template<typename... U>
std::enable_if_t<are_equal<U ..., Object<T>>::value>
Object<T>::addd(U &&... u)
{
// *this += std::forward<U>(u)...;
}
Probably i have two problems.
1. I think that i should change part of my code with type_traits
, but my experiments don't give correctly result.
Error with comments line (where is operator +=
)
C2893 Failed to specialize function template 'enable_if<_Test,_Ty>::type Object::addd(U &&...)' C2672 'Object::addd': no matching overloaded function found
Problem with dictionary(?) in comment line:
*this += std::forward<U>(u)...;
Error:
C2143 syntax error: missing ';' before '...'
C2059 syntax error: '...'
C3520 'u': parameter pack must be expanded in this context
Operator+=
work fine for one element (I'm sure).
I think you want the following: