Hello I have a class like std::vector and I want to be able to do this:
MyVec<int> vec(2, 5, 91, 27);
this is the code:
template <typename... args>
explicit MyVec(const args&... _args)
{
// some code...
size_t i = 0;
(void(m_data[i++] = _args), ...); // ERROR C2679
}
I don't understand how fold expressions work this is my first time using it so I wonder what am I doing wrong here and how to use fold expressions correctly?
Error: Severity Code Description Project File Line Suppression State Error C2679 binary '=': no operator found which takes a right-hand operand of type 'const int' (or there is no acceptable conversion)
So for some reason I think _args
is type of const int
or something when I cast it to type T
which in above example would be int
like this void(m_data[i++] = *(T*)&_args), ...);
error is gone but m_data
contains integers of valye -842150451.
what is going on there?