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:
- why change? upside?
- 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 returnedstd::make_pair
- , can call move constructor ofa
. in c++17 version, argument castedvalue_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
Post a Comment