Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
22.locale.stdcxx-554.cpp
Go to the documentation of this file.
1
27#include <cstring> // for memset()
28#include <cassert> // for assert()
29
30#include <locale> // for std::moneypunct, std::messages
31
32enum { fill = '\xdc' };
33
34template <class charT>
36{
37 typedef std::moneypunct <charT> PunctT;
38
39 // Use a pointer to properly align buffer for placment new.
40 union {
41 void* ptr;
42 char buf [sizeof (PunctT) + 1];
43 } u;
44
45 std::memset (u.buf, fill, sizeof (u.buf));
46
47 PunctT* p = new (u.buf) PunctT ();
48
49 assert (fill == u.buf [sizeof (PunctT)]);
50
51 p->~PunctT ();
52}
53
54template <class charT>
56{
57 typedef std::messages <charT> MessagesT;
58
59 union {
60 void* ptr;
61 char buf [sizeof (MessagesT) + 1];
62 } u;
63
64 std::memset (u.buf, fill, sizeof (u.buf));
65
66 MessagesT* p = new (u.buf) MessagesT ();
67
68 assert (fill == u.buf [sizeof (MessagesT)]);
69
70 p->~MessagesT ();
71}
72
73int main (int, char* [])
74{
75 test_moneypunct (char ());
76 test_messages (char ());
77
78#ifndef _RWSTD_NO_WCHAR_T
79 test_moneypunct (wchar_t ());
80 test_messages (wchar_t ());
81#endif
82
83 return 0;
84}
#define u
Definition 17.names.cpp:137
#define ptr
Definition 17.names.cpp:525
#define buf
Definition 17.names.cpp:452
#define charT
Definition 17.names.cpp:456
#define p
Definition 17.names.cpp:132
void test_moneypunct(charT)
void test_messages(charT)
#define main
#define assert(expr)
Definition _cassert.h:40