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-494.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
35
template
<
class
T>
36
struct
EmptyAllocator
: std::allocator<T>
37
{
38
template
<
class
U>
39
struct
rebind
{
typedef
EmptyAllocator<U>
other
; };
40
41
EmptyAllocator
() { }
42
EmptyAllocator
(
const
EmptyAllocator
&
rhs
)
43
:
std
::allocator<
T
>(
rhs
) { }
44
45
template
<
class
U>
46
EmptyAllocator
(
const
EmptyAllocator<U>
&
rhs
)
47
:
std
::allocator<
T
>(
rhs
) { }
48
49
void
*
operator
new
(std::size_t) {
return
0; }
50
void
operator
delete
(
void
*) { }
51
};
52
53
54
int
main
()
55
{
56
// verify that vector doesn't derive from allocator
57
// (otherwise the replacement operator new and delete
58
// are in conflict)
59
60
typedef
std::vector<int, EmptyAllocator<int> > EmptyVector;
61
62
delete
new
EmptyVector;
63
64
// verifies empty base optimization
65
assert
(
sizeof
(std::vector<int>) ==
sizeof
(EmptyVector));
66
67
// assert that the size of vector is exactly 3 pointers
68
assert
(
sizeof
(std::vector<int>) == 3 *
sizeof
(
int
*));
69
70
return
0;
71
}
T
#define T
Definition
17.names.cpp:163
rhs
#define rhs
Definition
17.names.cpp:536
main
int main()
Definition
23.vector.stdcxx-494.cpp:54
assert
#define assert(expr)
Definition
_cassert.h:40
std
Definition
json.h:5363
EmptyAllocator::rebind
Definition
23.vector.stdcxx-494.cpp:39
EmptyAllocator::rebind::other
EmptyAllocator< U > other
Definition
23.vector.stdcxx-494.cpp:39
EmptyAllocator
Definition
23.vector.stdcxx-494.cpp:37
EmptyAllocator::EmptyAllocator
EmptyAllocator(const EmptyAllocator &rhs)
Definition
23.vector.stdcxx-494.cpp:42
EmptyAllocator::EmptyAllocator
EmptyAllocator()
Definition
23.vector.stdcxx-494.cpp:41
EmptyAllocator::EmptyAllocator
EmptyAllocator(const EmptyAllocator< U > &rhs)
Definition
23.vector.stdcxx-494.cpp:46
Generated by
1.9.8