I'm including the algorithm library in my program but am getting this crazy error when I try and compile on my school's server.
1 2 3 4 5 6 7 8 9 10
proj4.cpp:272: error: expected initializer before ‘evolvePopulation’
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/algorithm:62,
from proj4.cpp:6:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algo.h: In function
‘void std::random_shuffle(_RAIter, _RAIter, _Generator&)
[with _RAIter = __gnu_cxx::__normal_iterator<City*, std::vector<City, std::allocator<City> > >
, _Generator = std::vector<City, std::allocator<City> >]’:
proj4.cpp:111: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algo.h:4998:
error: no match for call to ‘(std::vector<City, std::allocator<City> >) (ptrdiff_t)’
Does anyone know what this could be referring to?
I'll post the lines of code where it says the error is occurring.
Line 272: Population evolvePopulation(Population pop)
Line 111: random_shuffle(tour.begin(), tour.end(), tour);
When I try and compile in Visual Studio, it brings up the algorithm library and says that the error comes from here:
1 2 3 4 5 6 7 8 9
template<class _RanIt,
class _Fn1,
class _Diff> inlinevoid _Random_shuffle(_RanIt _First, _RanIt _Last, _Fn1& _Func, _Diff *)
{ // shuffle nonempty [_First, _Last) using random function _Func
_RanIt _Next = _First;
for (_Diff _Index = 2; ++_Next != _Last; ++_Index)
_STD iter_swap(_Next, _First + _Diff(_Func(_Index) % _Index));
}
With these errors:
error C2064: term does not evaluate to a function taking 1 arguments
error C1903: unable to recover from previous errors made
> I'll post the lines of code where it says the error is occurring. http://www.eelis.net/iso-c++/testcase.xhtml
A testcase consisting of randomly copy&paste'd bits of code that you thought were relevant can obviously not reproduce the problem.