Teach __tree how to handle map's __value_type
authorEric Fiselier <eric@efcs.ca>
Thu, 31 Mar 2016 02:15:15 +0000 (02:15 +0000)
committerEric Fiselier <eric@efcs.ca>
Thu, 31 Mar 2016 02:15:15 +0000 (02:15 +0000)
commit5e3ea4dd7931a010de30ebef7606215b667ab529
tree63f02ab5481d32d3ac8563a382a06a9526af127c
parent8a0313d4b6a5dfa2560da46bc5fa4776d0ff8592
Teach __tree how to handle map's __value_type

This patch is fairly large and contains a number of changes. The changes all work towards
allowing __tree to properly handle __value_type esspecially when inserting into the __tree.
I chose not to break this change into smaller patches because it wouldn't be possible to
write meaningful standard-compliant tests for each patch.

It is very similar to r260513 "[libcxx] Teach __hash_table how to handle unordered_map's __hash_value_type".

Changes in <map>
 * Remove __value_type's constructors because it should never be constructed directly.

 * Make map::emplace and multimap::emplace forward to __tree and remove the old definitions

 * Remove "__construct_node" map and multimap member functions. Almost all of the construction is done within __tree.

 * Fix map's move constructor to access "__value_type.__nc" directly and pass this object to __tree::insert.

Changes in <__tree>
 * Add traits to detect, handle, and unwrap, map's "__value_type".

 * Convert methods taking "value_type" to take "__container_value_type" instead. Previously these methods caused
  unwanted implicit conversions from "std::pair<Key, Value>" to "__value_type<Key, Value>".

 * Delete __tree_node and __tree_node_base's constructors and assignment operators. The node types should never be constructed
   because the "__value_" member of __tree_node must be constructed directly by the allocator.

 * Make the __tree_node_destructor class and "__construct_node" methods unwrap "__node_value_type" into "__container_value_type" before invoking the allocator. The user's allocator can only be used to construct and destroy the container's value_type. Passing it map's "__value_type" was incorrect.

 * Cleanup the "__insert" and "__emplace" methods. Have __insert forward to an __emplace function wherever possible to reduce
   code duplication. __insert_unique(value_type const&) and __insert_unique(value_type&&) forward to __emplace_unique_key_args.
   These functions will not allocate a new node if the value is already in the tree.

 * Change the __find* functions to take the "key_type" directly instead of passing in "value_type" and unwrapping the key later.
   This change allows the find functions to be used without having to construct a "value_type" first. This allows for a number
   of optimizations.

 * Teach __move_assign and __assign_multi methods to unwrap map's __value_type.

llvm-svn: 264986
libcxx/include/__config
libcxx/include/__tree
libcxx/include/map
libcxx/test/std/containers/associative/map/map.modifiers/insert_allocator_requirements.pass.cpp [new file with mode: 0644]
libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp [new file with mode: 0644]
libcxx/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp [new file with mode: 0644]
libcxx/test/std/containers/associative/set/insert_allocator_requirements.pass.cpp [new file with mode: 0644]