R
Ravi
I came across code which contains:
std::sort<unsigned char*>((newAnswer.begin()+1),newAnswer.end());
with newAnswer defined as
std::vector<unsigned char>& newAnswer
However upon attempting to compile the above code I got the following
errors (I am using g++ ver 3.3.1 on Cygwin)
error: cannot convert `
__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char,
std::allocator<unsigned char> > >' to `unsigned char*' for argument
`1' to `
void std::sort(_RandomAccessIter, _RandomAccessIter) [with
_RandomAccessIter
= unsigned char*]'
My questions are:
1. Why do we need to specify <unsigned char*> when calling sort? I have
seen many exmaples where std::sort is called as
std::vector<int> v;
//populate v
std::sort(v.begin(),v.end())
2. What does the above error message mean? How to resolve this problem?
Thanks.
std::sort<unsigned char*>((newAnswer.begin()+1),newAnswer.end());
with newAnswer defined as
std::vector<unsigned char>& newAnswer
However upon attempting to compile the above code I got the following
errors (I am using g++ ver 3.3.1 on Cygwin)
error: cannot convert `
__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char,
std::allocator<unsigned char> > >' to `unsigned char*' for argument
`1' to `
void std::sort(_RandomAccessIter, _RandomAccessIter) [with
_RandomAccessIter
= unsigned char*]'
My questions are:
1. Why do we need to specify <unsigned char*> when calling sort? I have
seen many exmaples where std::sort is called as
std::vector<int> v;
//populate v
std::sort(v.begin(),v.end())
2. What does the above error message mean? How to resolve this problem?
Thanks.