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
21.string.stdcxx-231.cpp
Go to the documentation of this file.
1
27
#include <cassert>
28
#include <string>
29
#include <sstream>
30
31
int
main
()
32
{
33
std::string
s
(100,
's'
);
34
35
const
std::string::size_type
n
=
s
.capacity ();
36
const
std::string::const_pointer
p
=
s
.c_str ();
37
38
// verify getline(), clear(), erase() and replace() do not
39
// unnecessarily resize or reallocate the data buffer
40
std::istringstream is (
"hello world"
);
41
std::getline (is,
s
);
42
assert
(
s
.capacity () ==
n
);
43
assert
(
s
.c_str () ==
p
);
44
45
s
.clear ();
46
assert
(
s
.capacity () ==
n
);
47
assert
(
s
.c_str () ==
p
);
48
49
s
.erase ();
50
assert
(
s
.capacity () ==
n
);
51
assert
(
s
.c_str () ==
p
);
52
53
s
.replace (0, std::string::npos,
"1"
, 0);
54
assert
(
s
.capacity () ==
n
);
55
assert
(
s
.c_str () ==
p
);
56
57
return
0;
58
}
59
s
#define s
Definition
rw_alg_test.h:221
n
#define n
Definition
17.names.cpp:130
p
#define p
Definition
17.names.cpp:132
main
int main()
Definition
21.string.stdcxx-231.cpp:31
assert
#define assert(expr)
Definition
_cassert.h:40
Generated by
1.9.8