1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
24 #include <unordered_map>
25 #include <testsuite_hooks.h>
30 PathPoint(char t
, const std::vector
<double>& c
)
31 : type(t
), coords(c
) { }
32 PathPoint(char t
, std::vector
<double>&& c
)
33 : type(t
), coords(std::move(c
)) { }
34 char getType() const { return type
; }
35 const std::vector
<double>& getCoords() const { return coords
; }
38 std::vector
<double> coords
;
41 bool test
__attribute__((unused
)) = true;
45 typedef std::unordered_multimap
<char, std::vector
<double>> MMap
;
48 std::vector
<double> coord1
= { 0.0, 1.0, 2.0 };
50 auto it
= mm
.emplace('a', coord1
);
51 VERIFY( mm
.size() == 1 );
52 VERIFY( it
->first
== 'a' );
55 it
= mm
.emplace('a', coord1
);
56 VERIFY( mm
.size() == 2 );
57 VERIFY( it
->first
== 'a' );
58 VERIFY( it
->second
[0] == 3.0 );
60 it
= mm
.emplace_hint(mm
.begin(), 'b', coord1
);
61 VERIFY( it
!= mm
.end() );
62 VERIFY( it
->first
== 'b' );
63 VERIFY( it
->second
[0] == 3.0 );
65 double *px
= &coord1
[0];
66 it
= mm
.emplace('c', std::move(coord1
));
67 VERIFY( it
->first
== 'c' );
68 VERIFY( &(it
->second
[0]) == px
);
74 typedef unordered_multimap
<char, PathPoint
> Map
;
77 std::vector
<double> coord1
= { 0.0, 1.0, 2.0 };
79 auto it
= m
.emplace(piecewise_construct
,
80 make_tuple('a'), make_tuple('a', coord1
));
81 VERIFY( m
.size() == 1 );
82 VERIFY( it
->first
== 'a' );
85 it
= m
.emplace(piecewise_construct
,
86 make_tuple('a'), make_tuple( 'b', coord1
));
87 VERIFY( m
.size() == 2 );
88 VERIFY( it
->first
== 'a' );
89 VERIFY( it
->second
.getCoords()[0] == 3.0 );
91 it
= m
.emplace_hint(m
.begin(), piecewise_construct
,
92 make_tuple('b'), make_tuple('c', coord1
));
93 VERIFY( it
!= m
.end() );
94 VERIFY( it
->first
== 'b' );
95 VERIFY( it
->second
.getCoords()[0] == 3.0 );
97 double *px
= &coord1
[0];
98 it
= m
.emplace(piecewise_construct
,
99 make_tuple('c'), make_tuple('d', move(coord1
)));
100 VERIFY( it
->first
== 'c' );
101 VERIFY( &(it
->second
.getCoords()[0]) == px
);