Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
21.string.stdcxx-162.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <string>
31
32#ifdef _RWSTD_POSIX_THREADS
33# include <pthread.h>
34# define MUTEX pthread_mutex_t
35#elif _RWSTD_SOLARIS_THREADS
36# include <thread.h>
37# define MUTEX mutex_t
38#endif // _RWSTD_POSIX_THREADS
39
40int main ()
41{
42 typedef std::char_traits<char> Traits;
43 typedef std::allocator<char> Allocator;
44 typedef __rw::__string_ref<char, Traits, Allocator> strref;
45
46 struct SmallRef {
47 int ref_count;
48 std::string::size_type capacity;
49 std::string::size_type size;
50 };
51
52 // verify that the reference-counted string body isn't bigger
53 // than the struct above
54 assert (sizeof (strref) <= sizeof (SmallRef));
55
56#ifdef MUTEX
57
58 struct LargeRef {
59 MUTEX mutex;
60 int ref_count;
61 std::string::size_type capacity;
62 std::string::size_type size;
63 };
64
65 // verify that the reference-counted string body is smaller
66 // than the struct containing a full-blown mutex object above
67 assert (sizeof (strref) < sizeof (LargeRef));
68
69#endif // MUTEX
70
71 return 0;
72}
#define Allocator
Definition 17.names.cpp:440
#define Traits
Definition 17.names.cpp:556
int main()
#define assert(expr)
Definition _cassert.h:40