Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
tests
regress
23.vector.stdcxx-1037.cpp
Go to the documentation of this file.
1
29
#include <cassert>
// for assert()
30
#include <cstddef>
// for size_t
31
#include <memory>
// for allocator
32
#include <vector>
// for vector
33
34
template
<
typename
T>
35
struct
Alloc
: std::allocator<T>
36
{
37
Alloc
(
int
i
) :
i_
(
i
) { }
38
39
template
<
typename
U>
40
struct
rebind
{
41
typedef
Alloc<U>
other
;
42
};
43
44
template
<
typename
U>
45
Alloc
(
const
Alloc<U>
& other)
46
:
std
::allocator<
T
>(other),
i_
(other.
i_
) { }
47
48
template
<
typename
U>
49
Alloc
& operator= (
const
Alloc<U>
& other)
50
{
51
std::allocator<T>::operator= (other);
52
i_
= other.
i_
;
53
return
*
this
;
54
}
55
56
int
i_
;
57
};
58
59
template
<
typename
T>
60
bool
operator==
(
const
Alloc<T>
&
a1
,
const
Alloc<T>
&
a2
)
61
{
62
return
a1
.i_ ==
a2
.i_;
63
}
64
65
int
main
()
66
{
67
std::vector<int, Alloc<int> >
v1
(
Alloc<int>
(1));
68
v1
.push_back (1);
69
assert
(1 ==
v1
.size () && 1 ==
v1
.front ());
70
71
std::vector<int, Alloc<int> >
v2
(
Alloc<int>
(2));
72
v2
.push_back (2);
73
assert
(1 ==
v2
.size () && 2 ==
v2
.front ());
74
75
v1
.swap (
v2
);
76
77
assert
(1 ==
v1
.size () && 2 ==
v1
.front ());
78
assert
(1 ==
v2
.size () && 1 ==
v2
.front ());
79
80
return
0;
81
}
i
#define i
Definition
17.names.cpp:126
T
#define T
Definition
17.names.cpp:163
i_
#define i_
Definition
17.names.cpp:180
v2
#define v2
Definition
17.names.cpp:271
a2
#define a2
Definition
17.names.cpp:251
a1
#define a1
Definition
17.names.cpp:225
v1
#define v1
Definition
17.names.cpp:245
operator==
bool operator==(const Alloc< T > &a1, const Alloc< T > &a2)
Definition
23.vector.stdcxx-1037.cpp:60
main
int main()
Definition
23.vector.stdcxx-1037.cpp:65
assert
#define assert(expr)
Definition
_cassert.h:40
Alloc
Definition
23.list.special.stdcxx-334.cpp:32
Alloc::i_
int i_
Definition
23.vector.stdcxx-1037.cpp:56
Alloc::Alloc
Alloc(int i)
Definition
23.vector.stdcxx-1037.cpp:37
Alloc::Alloc
Alloc(const Alloc< U > &other)
Definition
23.vector.stdcxx-1037.cpp:45
std
Definition
json.h:5363
Alloc::rebind
Definition
23.vector.stdcxx-1037.cpp:40
Alloc::rebind::other
Alloc< U > other
Definition
23.vector.stdcxx-1037.cpp:41
Generated by
1.9.8