How to assign std :: a pair that has one of them typed by the const command?

I am trying to encode an associative container compatible with std :: map. To do this, I need to create an insert method that accepts a new element as std :: pair with the first component of type const. For example: std::pair<const int, int> p.

The problem is that such an object cannot be assigned to another. Therefore, in the internal code of my MapCompatibleContainer, I cannot copy a new pair into a private variable (a std :: vector).

How can I get around this?

thank

+5
source share
2 answers

As you say, you cannot assign a const object.

, . .

, , .

+2

<utility> , std::make_pair. , :

foo.insert( std::make_pair( bar.first, bar.second ) );

, "foo" - , "map".

0

All Articles