From 089a7cc5dea665f4088ed6b587e2f6ea058d7581 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 20 Feb 2016 05:28:30 +0000 Subject: Cleanup node-type handling in the associative containers. This patch is very similar to r260431. This patch is the first in a series of patches that's meant to better support map. map has a special "value_type" that differs from pair. In order to meet the EmplaceConstructible and CopyInsertable requirements we need to teach __tree about this special value_type. This patch creates a "__tree_node_types" traits class that contains all of the typedefs needed by the associative containers and their iterators. These typedefs include ones for each node type and node pointer type, as well as special typedefs for "map"'s value type. Although the associative containers already supported incomplete types, this patch makes it official by adding tests. This patch will be followed up shortly with various cleanups within __tree and fixes for various map bugs and problems. llvm-svn: 261416 --- .../containers/associative/iterator_types.pass.cpp | 131 +++++++++++++++++++++ .../associative/map/incomplete_type.pass.cpp | 29 +++++ .../associative/multimap/incomplete_type.pass.cpp | 29 +++++ .../associative/multiset/incomplete_type.pass.cpp | 29 +++++ .../associative/set/incomplete_type.pass.cpp | 29 +++++ 5 files changed, 247 insertions(+) create mode 100644 libcxx/test/std/containers/associative/iterator_types.pass.cpp create mode 100644 libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp create mode 100644 libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp create mode 100644 libcxx/test/std/containers/associative/multiset/incomplete_type.pass.cpp create mode 100644 libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp (limited to 'libcxx/test/std/containers') diff --git a/libcxx/test/std/containers/associative/iterator_types.pass.cpp b/libcxx/test/std/containers/associative/iterator_types.pass.cpp new file mode 100644 index 00000000000..2026219d86c --- /dev/null +++ b/libcxx/test/std/containers/associative/iterator_types.pass.cpp @@ -0,0 +1,131 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" +#include "test_allocator.h" + + +template +void testMap() { + typedef typename Map::difference_type Diff; + { + typedef typename Map::iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } + { + typedef typename Map::const_iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +} + + +template +void testSet() { + static_assert((std::is_same::value), ""); + typedef typename Set::difference_type Diff; + { + typedef typename Set::iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + } +} + +int main() { + { + typedef std::map Map; + typedef std::pair ValueTp; + testMap(); + } + { + typedef std::pair ValueTp; + typedef test_allocator Alloc; + typedef std::map, Alloc> Map; + testMap(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair ValueTp; + typedef min_allocator Alloc; + typedef std::map, Alloc> Map; + testMap, min_pointer>(); + } +#endif + { + typedef std::multimap Map; + typedef std::pair ValueTp; + testMap(); + } + { + typedef std::pair ValueTp; + typedef test_allocator Alloc; + typedef std::multimap, Alloc> Map; + testMap(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair ValueTp; + typedef min_allocator Alloc; + typedef std::multimap, Alloc> Map; + testMap, min_pointer>(); + } +#endif + { + typedef int ValueTp; + typedef std::set Set; + testSet(); + } + { + typedef int ValueTp; + typedef test_allocator Alloc; + typedef std::set, Alloc> Set; + testSet(); + } +#if TEST_STD_VER >= 11 + { + typedef int ValueTp; + typedef min_allocator Alloc; + typedef std::set, Alloc> Set; + testSet>(); + } +#endif + { + typedef int ValueTp; + typedef std::multiset Set; + testSet(); + } + { + typedef int ValueTp; + typedef test_allocator Alloc; + typedef std::multiset, Alloc> Set; + testSet(); + } +#if TEST_STD_VER >= 11 + { + typedef int ValueTp; + typedef min_allocator Alloc; + typedef std::multiset, Alloc> Set; + testSet>(); + } +#endif +} diff --git a/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp new file mode 100644 index 00000000000..84c2451ce08 --- /dev/null +++ b/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// Check that std::map and it's iterators can be instantiated with an incomplete +// type. + +#include + +struct A { + typedef std::map Map; + int data; + Map m; + Map::iterator it; + Map::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp new file mode 100644 index 00000000000..c461eb38139 --- /dev/null +++ b/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// Check that std::multimap and it's iterators can be instantiated with an incomplete +// type. + +#include + +struct A { + typedef std::multimap Map; + int data; + Map m; + Map::iterator it; + Map::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/libcxx/test/std/containers/associative/multiset/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/multiset/incomplete_type.pass.cpp new file mode 100644 index 00000000000..0355e18f9f2 --- /dev/null +++ b/libcxx/test/std/containers/associative/multiset/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// Check that std::multiset and it's iterators can be instantiated with an incomplete +// type. + +#include + +struct A { + typedef std::multiset Set; + int data; + Set m; + Set::iterator it; + Set::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp new file mode 100644 index 00000000000..d3a1d6638d7 --- /dev/null +++ b/libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// Check that std::set and it's iterators can be instantiated with an incomplete +// type. + +#include + +struct A { + typedef std::set Set; + int data; + Set m; + Set::iterator it; + Set::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} -- cgit v1.2.3