c++ - std::map::insert change in C++17 -


i see insert method of std::map , std::unordered_map going change from

template<class p> std::pair<iterator,bool> insert(p&& value); (c++11) 

to

std::pair<iterator,bool> insert(value_type&& value);  (c++17) 

however, these containers, value_type std::pair<a const, int>. 2 questions here:

  1. why change? upside?
  2. how going work move key on insertion? c++11 version accepts (the constraint on p default_constructible<value_type, p&&>), std::pair<a, int> - of time type of argument 1 returned std::make_pair - , can call move constructor of a. in c++17 version, argument casted value_type, a const, non-movable. has copied, if not overlooking something. or c++17 change on side too?

thanks!

an additional non-template overload insert added in c++17.

such overload has advantage permits .insert( { {key}, {value, args} } ) syntax -- {} based construction. template arguments cannot passed {} based construction instructions without explicit type.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -