]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/78595.cc
1 // Copyright (C) 2018-2023 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++11 } }
21 #include <testsuite_hooks.h>
27 mutable int conversions
= 0;
29 operator std::pair
<const int, int>() const {
30 if (++conversions
> 1)
36 std::multimap
<int, int> m
;
38 VERIFY( m
.size() == 1 );
39 m
.insert(m
.begin(), X());
40 VERIFY( m
.size() == 2 );
49 operator std::pair
<const int, int>() && {
50 if (++conversions
> 1)
56 std::multimap
<int, int> m
;
58 VERIFY( m
.size() == 1 );
59 m
.insert(m
.begin(), Y());
60 VERIFY( m
.size() == 2 );
65 bool operator<(const Key
& r
) const { return key
< r
.key
; }
69 operator std::pair
<const Key
, int>() const { return { { z
}, 0 }; }
79 Alloc(const Alloc
<U
>&) { }
83 T
* allocate(std::size_t n
) { return std::allocator
<T
>().allocate(n
); }
85 void deallocate(T
* p
, std::size_t n
) { std::allocator
<T
>().deallocate(p
, n
); }
88 void construct(U
* p
, const Z
& z
) { ::new (p
) U
{ { z
.z
+1 }, 0}; }
91 bool operator==(const Alloc
<U
>&) { return true; }
94 bool operator!=(const Alloc
<U
>&) { return false; }
100 std::multimap
<Key
, int, std::less
<Key
>, Alloc
<std::pair
<const Key
, int>>> m
;
103 VERIFY( m
.size() == 2 );
106 VERIFY( m
.size() == 4 );