First of all, thanks for the help.
Although you are right in saying I'm not specifying the template argument, the compiler deduces it correctly itself, so the problem is not that.
Proof is the second line (the "note" one) or the fact that it works perfectly on the other 7 instances I mentioned.
Anyway, once I followed your suggestion, the compiler gave the same output (without the hypotesis on the type, since now I've specified it, of course):
Code:
error: no matching function for call to ‘Array_Append(TT**&, unsigned int&, TT*)’
Once again, it adds an & after TT**.
UPDATE:
There is a difference between the two cases, the one in which everything works and the one when I get the error. In the first case the Appendee is a pointer to a dynamic struct, the other time it is a pointer to struct in a dynamic array (&otherArray [item_number]). But in the end they are both pointers to a certain kind of struct, the fact that one is standalone and the other is in a collection (array) should not matter. Also, this is the 3rd field, the compiler is making funny stuff with the first one.
Or so I thought...
This does not spawn the error:
Code:
TT** Array (NULL);
int Elements (0);
Array = new TT* [1];
++Elements;
TT* AppendThis = new TT;
Array_Append (Array, Elements, AppendThis);
This does spawn the error
Code:
TT** Array (NULL);
int Elements (0);
Array = new TT* [1];
++Elements;
TT* AppendOneOfThese = new TT [10];
// I want to append a pointer to the 4th element of AppendOneOfThese in Array
Array_Append (Array, Elements, &AppendOneOfThese [3]);
I need to make it work in the second case, any idea? I still do not get why the error complains as he does.
UPDATE2:
Found a solution switching from:
Code:
template <typename ArrayType, typename SizeType>
inline ArrayType* Array_Append (ArrayType* Target, SizeType& Array_Size, ArrayType& Appendee)
to
Code:
template <typename ArrayType, typename SizeType>
inline ArrayType* Array_Append (ArrayType* Target, SizeType& Array_Size, ArrayType Appendee)
But it is still not clear to me the behavior of the compiler, and I would very much appreciate an explaination, if someone knows the reason of it.
Bookmarks