1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
16 // iterator insert(node_type&&);
19 #include <type_traits>
20 #include "min_allocator.h"
22 template <class Container>
23 typename Container::node_type
24 node_factory(typename Container::key_type const& key)
27 auto it = c.insert(key);
31 template <class Container>
32 void test(Container& c)
34 auto* nf = &node_factory<Container>;
36 for (int i = 0; i != 10; ++i)
38 typename Container::node_type node = nf(i);
39 assert(!node.empty());
40 typename Container::iterator it = c.insert(std::move(node));
42 assert(it == c.find(i) && it != c.end());
47 assert(c.size() == 10);
49 { // Insert empty node.
50 typename Container::node_type def;
51 auto it = c.insert(std::move(def));
53 assert(it == c.end());
56 { // Insert duplicate node.
57 typename Container::node_type dupl = nf(0);
58 auto it = c.insert(std::move(dupl));
62 assert(c.size() == 11);
64 assert(c.count(0) == 2);
65 for (int i = 1; i != 10; ++i)
67 assert(c.count(i) == 1);
75 std::multiset<int, std::less<int>, min_allocator<int>> m2;