I want a function to have a universal reference argument with a concrete type. I want it to be universal reference so I can pass a temporary object when I'm not interested in checking the value stored in it.
Here is the example:
bool bCompareData(const uint8_t *arg_0, const uint8_t *arg_1, size_t &szComparedData)
{
size_t &i = szComparedData;
for (; arg_1[i]; ++i)
if (arg_1[i] != arg_0[i])
return false;
return true;
}
And the possible function calls:
bCompareData(Obj.uIdObject.data(), Ref.uIdTargetObject.data(), size_t()) // here we are passing a temporary (rvalue)
/*________________________*/
size_t lval;
bCompareData(Obj.uIdObject.data(), Ref.uIdTargetObject.data(), lval) // here we are passing a named variable (lvalue)
Using the above function declarations in the first function call compiler will give an error, if I change "size_t &szComparedData" to rvalue reference "size_t &&szComparedData" it will fail at the second call.
Now what I need is Universal References but I would also like to have a concrete type on my argument and not use templates.
I'm using VC++ U3 2013 compiler.