CByteArray and stl::vector question

I am removing some MFC stuff from a project and converting it to stl.

I had a CByteArray which I have replaced with:
typedef std::vector<BYTE> ByteArray;

Now I have the following problem:

1
2
3
4
5
6
7
8
9
10
11
12
13
BOOL MyClass::DoSomething( ByteArray& byteArray)
{
  //Previously I had the following when I used the MFC CByteArray class
  byteArray.SetAt( add_index, byte_to_add );

  //So now I want to convert this to the std::vector equivalent
  //
  byteArray.insert( byteArray.begin()+add_index, byte_to_add );
  //But this is giving me the error:
'no instance of overloaded function "std::vector<_Ty, _Ax>::insert [with _Ty=BYTE, _Ax=std::allocator<BYTE>]" matches the argument list'

..
}


How do I solve this problem???
You also have to specify the number of elements to be inserted, in this case:
byteArray.insert( byteArray.begin()+add_index,1, byte_to_add );

See: http://cplusplus.com/reference/stl/vector/insert/
Last edited on
Topic archived. No new replies allowed.