I have the following function:
template <typename T, size_t SIZE> void minSortLoop(array<T, SIZE>& a){ for(size_t o = 0; o < SIZE; o++) { size_t minIx = 0; for(size_t i = o + 1; i < SIZE; i++) { if(a[i] < a[minIx]) { minIx = i; } } swap(a[o], a[minIx]); } }
I like to call him from another place, for example:
std::array<int, 3> arr = {3,1,-9}; minSortLoop(arr);
But I get errors:
Description Resource access type Invalid argument type 'Candidates are: void minSortLoop (? &)' Test.cpp / gTest line 23 Semantic error
Description Resource path Source type There is no suitable function to call to 'minSortLoop (std :: array *)' Test.cpp / gTest line 23 C / C ++ Problem
How to call the sort function?
Best wishes: -)
PS: I am not allowed to use std :: sort.
EDIT 1:
@ François Moisan:
I tried to pass in another way, for example:
std::array<int, 3> arr = {3,1,-9}; minSortLoop(&arr);
with an error:
Description Resource access type Invalid argument type 'Candidates are: void minSortLoop (? &)' Test.cpp / gTest line 23 Semantic error
Description Resource path Source type There is no suitable function to call to 'minSortLoop (std :: array *)' Test.cpp / gTest line 23 C / C ++ Problem
and
std::array<int, 3> arr = {3,1,-9}; minSortLoop(*arr);
with an error:
Description Resource access type Invalid argument type 'Candidates are: void minSortLoop (? &)' Test.cpp / gTest line 23 Semantic error
Description Resource path Resource type No match for 'operator *' (operand type is "std :: array"). Test.cpp / gTest line 23 C / C ++ Problem
I don’t know what to call it. The link offers something like my first example here .
@tadman:
I need to pass the size. This is given from the description of the problem: - (
@ Jarod42: Which compiler is this? I am using Cygwin in eclipse under windows 7.
@pasasap: Yes, I compiled it, or at least try it. This leads to the described errors.
EDIT 2:
As mentioned in one of the comments, like @pasasap, the problem seems to be related to eclipse. Does anyone know a solution without turning off coding analysis?