I am having trouble trying to insert a std::pair
in the std::vector
, with this code:
template <class R>
class AVectorContainner
{
public:
AVectorContainner()
{
mVector= new std::vector<entry>;
}
typedef std::pair<int ,R *> entry;
void insert(R* aPointer, int aID)
{
entry aEntry;
aEntry=std::make_pair(aID,aPointer );
mVector->push_back(aEntry);
}
private:
std::vector<entry> * mVector;
}
This is the part of the main file, that I declare a pointer of a class and then I used it in the initialization of the template class.
In the main.cpp:
int main()
{
SomeType * aTipe= new SomeType;
int aID=1;
AVectorContainer<SomeType> * aContainer= new AVectorContainer;
aContainer->insert(aTipe,aId);//error line
delete aTipe;
delete aContainer;
return 0;
}
Compiler Output:
error: non-static reference member 'const int& std::pair<const int&, SomeType *>::first', can't use default assignment operator
error: value-initialization of reference type 'const int&'