Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
17.extensions.cpp
Go to the documentation of this file.
1
30#undef _RWSTD_NO_EXTENSIONS
31#define _RWSTD_NO_EXTENSIONS
32
33
34// working around a SunOS/SunPro bug (PR #26255)
35#if defined (__SUNPRO_CC) && (defined (__SunOS_5_8) || defined (__SunOS_5_9))
36# include <time.h>
37#endif // SunPro && SunOS 5.{8,9}
38
39#include <cassert>
40#include <cctype>
41#include <cerrno>
42#include <cfloat>
43#include <ciso646>
44#include <climits>
45#include <clocale>
46#include <cmath>
47#include <csetjmp>
48#include <csignal>
49#include <cstdarg>
50#include <cstddef>
51#include <cstdio>
52#include <cstdlib>
53#include <cstring>
54#include <ctime>
55#include <cwchar>
56#include <cwctype>
57
58#include <assert.h>
59#include <ctype.h>
60#include <errno.h>
61#include <float.h>
62#include <iso646.h>
63#include <limits.h>
64#include <locale.h>
65#include <math.h>
66#include <setjmp.h>
67#include <signal.h>
68#include <stdarg.h>
69#include <stddef.h>
70#include <stdio.h>
71#include <stdlib.h>
72#include <string.h>
73#include <time.h>
74#include <wchar.h>
75#include <wctype.h>
76
77#include <algorithm>
78#include <bitset>
79#include <complex>
80#include <deque>
81#include <exception>
82#include <fstream>
83#include <functional>
84#include <iomanip>
85#include <ios>
86#include <iosfwd>
87#include <iostream>
88#include <istream>
89#include <iterator>
90#include <limits>
91#include <list>
92#include <locale>
93#include <map>
94#include <memory>
95#include <new>
96#include <numeric>
97#include <ostream>
98#include <queue>
99#include <set>
100#include <sstream>
101#include <stack>
102#include <stdexcept>
103#include <streambuf>
104#include <string>
105#include <typeinfo>
106#include <utility>
107#include <valarray>
108#include <vector>
109
110
115
116
117#if !defined (__SUNPRO_CC) || __SUNPRO_CC > 0x550
118
119template <class T, class U>
120void count (T, T, const U&, ...) { ++count_called; }
121
122
123template <class T, class U>
124void count_if (T, T, U, ...) { ++count_pred_called; }
125
126
127template <class T>
128void distance (T, T, ...) { ++distance_called; }
129
130#else
131
132// working around a SunPro bug (PR #28678)
133
134template <class T, class U>
135void count (T, T, const U&, std::size_t&) { ++count_called; }
136
137
138template <class T, class U>
139void count_if (T, T, U, std::size_t&) { ++count_pred_called; }
140
141
142template <class T>
143void distance (T, T, std::size_t&) { ++distance_called; }
144
145#endif // SunPro
146
147
148#if !defined (__GNUG__) || __GNUG__ > 2
149
150int ellipsis_called /* = 0 */;
151
152struct NumGet: std::num_get<char>
153{
154 typedef std::num_get<char> Base;
155
156# ifndef _RWSTD_NO_USING_ACCESS_ADJUSTMENT
157
158 _USING (Base::get);
159
160# else // if defined (_RWSTD_NO_USING_ACCESS_ADJUSTMENT)
161
162 Base::get;
163
164# endif // _RWSTD_NO_USING_ACCESS_ADJUSTMENT
165
166 iter_type get (iter_type, iter_type,
167 std::ios_base&, std::ios_base::iostate&, ...) const {
169 return iter_type ();
170 }
171};
172
173#endif // gcc > 2.x
174
175
176template <class T>
178{
179 operator T () const {
180 static union {
181 void *dummy;
182 char buffer [sizeof (T)];
183 } u;
184
185 return (T)*u.buffer;
186 }
187};
188
189
190struct base { /* empty */ };
191struct badbit_set: base { /* empty */ };
192struct eofbit_set: base { /* empty */ };
193struct failbit_set: base { /* empty */ };
194
195struct Bin: base { /* empty */ } *bin;
196struct Nolock: base { /* empty */ } *nolock;
197struct NolockBuf: base { /* empty */ } *nolockbuf;
198
199
200struct IosBase: std::ios_base
201{
202 static bool check (int, base*) { return true; }
203 static bool check (int, ...) { return false; }
204
205 // members are preferred over non-members during unqualified lookup
206 static bool check_badbit () { return check (0, (badbit_set*)0); }
207 static bool check_eofbit () { return check (0, (eofbit_set*)0); }
208 static bool check_failbit () { return check (0, (failbit_set*)0); }
209
210 static bool check_bin () { return check (0, bin); }
211
212 static bool check_nolock () { return check (0, nolock); }
213 static bool check_nolockbuf () { return check (0, nolockbuf); }
214};
215
216
218
219
220// define bogus primary templates to verify
221// that they are not defined by the library
222
223#ifdef _RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY
224
225template <class charT>
226struct char_traits { /* empty */ };
227
228#endif // _RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY
229
230
231#ifdef _RWSTD_NO_EXT_CODECVT_PRIMARY
232
233template <class internT, class externT, class stateT>
234struct codecvt { /* empty */ };
235
236#endif // _RWSTD_NO_EXT_CODECVT_PRIMARY
237
238
239#ifdef _RWSTD_NO_EXT_CTYPE_PRIMARY
240
241template <class charT>
242struct ctype { /* empty */ };
243
244#endif // _RWSTD_NO_EXT_CTYPE_PRIMARY
245
246
247#ifdef _RWSTD_NO_EXT_COLLATE_PRIMARY
248
249template <class charT>
250struct collate { /* empty */ };
251
252#endif // _RWSTD_NO_EXT_COLLATE_PRIMARY
253
254
255#ifdef _RWSTD_NO_EXT_MONEYPUNCT_PRIMARY
256
257template <class charT, bool Intl>
258struct moneypunct { /* empty */ };
259
260#endif // _RWSTD_NO_EXT_MONEYPUNCT_PRIMARY
261
262
263#ifdef _RWSTD_NO_EXT_NUMPUNCT_PRIMARY
264
265template <class charT>
266struct numpunct { /* empty */ };
267
268#endif // _RWSTD_NO_EXT_NUMPUNCT_PRIMARY
269
270
271#ifdef _RWSTD_NO_EXT_TIME_GET_PRIMARY
272
273template <class charT, class InputIterator>
274struct time_get { /* empty */ };
275
276#endif // _RWSTD_NO_EXT_TIME_GET_PRIMARY
277
278
279#ifdef _RWSTD_NO_EXT_TIME_PUT_PRIMARY
280
281template <class charT, class OutputIterator>
282struct time_put { /* empty */ };
283
284#endif // _RWSTD_NO_EXT_TIME_PUT_PRIMARY
285
286
287#ifdef _RWSTD_NO_EXT_MESSAGES_PRIMARY
288
289template <class charT>
290struct messages { /* empty */ };
291
292#endif // _RWSTD_NO_EXT_MESSAGES_PRIMARY
293
294} // namespace std
295
296
298#include <rw_driver.h>
299
300bool predicate (int /* unused */) { return true; }
301
302static int
303run_test (int /* unused */, char* /* unused */ [])
304{
305 // exercise _RWSTD_NO_EXT_VOID_COUNT
306 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_VOID_COUNT");
307
308 std::reverse_iterator<int*> it (0);
309
310 std::size_t n = 0;
311
312#ifndef _RWSTD_NO_EXT_VOID_COUNT
313 rw_assert (0, __FILE__, __LINE__,
314 "_RWSTD_NO_EXT_VOID_COUNT not #defined");
315#endif
316
317 // call the 4-argument overload of count() and expect Koenig lookup
318 // to find ::count(); the std::count() extension will be preferred
319 // if it exists and is a viable candidate, in which case the test
320 // below will fail
321 count (it, it, 0, n);
322
323 rw_assert (1 == count_called, __FILE__, __LINE__,
324 "_RWSTD_NO_EXTENSIONS #defined and an extended "
325 "definition of std::count() found");
326
327 // call the 4-argument overload of count() and expect Koenig lookup
328 // to find ::count(); the std::count() extension will be preferred
329 // if it exists and is a viable candidate
330 count_if (it, it, predicate, n);
331
332 rw_assert (1 == count_pred_called, __FILE__, __LINE__,
333 "_RWSTD_NO_EXTENSIONS #defined and an extended "
334 "definition of std::count_if() found");
335
336
337 // exercise _RWSTD_NO_EXT_VOID_DISTANCE
338 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_VOID_DISTANCE");
339
340#ifndef _RWSTD_NO_EXT_VOID_DISTANCE
341 rw_assert (0, __FILE__, __LINE__,
342 "_RWSTD_NO_EXT_VOID_DISTANCE not #defined");
343#endif
344
345 // call the 3-argument overload of distance() and expect Koenig
346 // lookup to find ::distance(); std::distance() will be preferred
347 // if it exists and is a viable candidate
348 distance (it, it, n);
349
350 rw_assert (1 == distance_called, __FILE__, __LINE__,
351 "_RWSTD_NO_EXTENSIONS #defined and an extended "
352 "definition of std::distance() found");
353
354
355 // exercise _RWSTD_NO_EXT_NUM_GET
356 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_NUM_GET");
357
358#ifndef _RWSTD_NO_EXT_NUM_GET
359 rw_assert (0, __FILE__, __LINE__,
360 "_RWSTD_NO_EXT_NUM_GET not #defined");
361#endif
362
363#if !defined (__GNUG__) || __GNUG__ > 2
364
365# define STRING(x) #x
366# define TEST_GET(T) \
367 do { \
368 NumGet::iter_type in; \
369 std::ios_base::iostate err = std::ios_base::failbit; \
370 ellipsis_called = 0; \
371 NumGet ().get (in, in, std::cin, err, convertible<T&>()); \
372 rw_assert (1 == ellipsis_called, __FILE__, __LINE__, \
373 "_RWSTD_NO_EXTENSIONS #defined and std::" \
374 "num_get<char>::get(..., " STRING(T) ") found"); \
375 } while (0)
376
377 TEST_GET (short);
378 TEST_GET (int);
379
380# ifdef _RWSTD_LONG_LONG
381
383 TEST_GET (unsigned _RWSTD_LONG_LONG);
384
385# endif // _RWSTD_NO_LONG_LONG
386
387#endif // gcc > 2.x
388
389
390 // exercise _RWSTD_NO_EXT_FAILURE
391 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_FAILURE");
392
393#ifndef _RWSTD_NO_EXT_FAILURE
394 rw_assert (0, __FILE__, __LINE__, "_RWSTD_NO_EXT_FAILURE not #defined");
395#endif
396
397 rw_assert (IosBase::check_badbit (), __FILE__, __LINE__,
398 "_RWSTD_NO_EXTENSIONS #defined and "
399 " class std::ios_base::badbit_set found");
400
401 rw_assert (IosBase::check_eofbit (), __FILE__, __LINE__,
402 "_RWSTD_NO_EXTENSIONS #defined and "
403 " class std::ios_base::eofbit_set found");
404
405 rw_assert (IosBase::check_eofbit (), __FILE__, __LINE__,
406 "_RWSTD_NO_EXTENSIONS #defined and "
407 " class std::ios_base::failbit_set found");
408
409
410 // exercise _RWSTD_NO_EXT_BIN_IO
411 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_BIN_IO");
412
413#ifndef _RWSTD_NO_EXT_BIN_IO
414 rw_assert (0, __FILE__, __LINE__,
415 "_RWSTD_NO_EXT_BIN_IO not #defined");
416#endif
417
418 rw_assert (IosBase::check_bin (), __FILE__, __LINE__,
419 "_RWSTD_NO_EXTENSIONS #defined and "
420 " std::ios_base::bin found");
421
422
423 // exercise _RWSTD_NO_EXT_REENTRANT_IO
424 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_REENTRANT_IO");
425
426#ifndef _RWSTD_NO_EXT_REENTRANT_IO
427 rw_assert (0, __FILE__, __LINE__,
428 "_RWSTD_NO_EXT_REENTRANT_IO not #defined");
429#endif
430
431 rw_assert (IosBase::check_nolock (), __FILE__, __LINE__,
432 "_RWSTD_NO_EXTENSIONS #defined and "
433 " std::ios_base::nolock found");
434
435 rw_assert (IosBase::check_nolockbuf (), __FILE__, __LINE__,
436 "_RWSTD_NO_EXTENSIONS #defined and "
437 " std::ios_base::nolockbuf found");
438
439
440 // exercise _RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY
441 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY");
442
443#ifndef _RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY
444 rw_assert (0, __FILE__, __LINE__,
445 "_RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY not #defined");
446#endif // _RWSTD_NO_EXT_CHAR_TRAITS_PRIMARY
447
448
449 // exercise _RWSTD_NO_EXT_CODECVT_PRIMARY
450 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_CODECVT_PRIMARY");
451
452#ifndef _RWSTD_NO_EXT_CODECVT_PRIMARY
453 rw_assert (0, __FILE__, __LINE__,
454 "_RWSTD_NO_EXT_CODECVT_PRIMARY not #defined");
455#endif // _RWSTD_NO_EXT_CODECVT_PRIMARY
456
457
458 // exercise _RWSTD_NO_EXT_COLLATE_PRIMARY
459 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_COLLATE_PRIMARY");
460
461#ifndef _RWSTD_NO_EXT_COLLATE_PRIMARY
462 rw_assert (0, __FILE__, __LINE__,
463 "_RWSTD_NO_EXT_COLLATE_PRIMARY not #defined");
464#endif // _RWSTD_NO_EXT_COLLATE_PRIMARY
465
466
467 // exercise _RWSTD_NO_EXT_CTYPE_PRIMARY
468 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_CTYPE_PRIMARY");
469
470#ifndef _RWSTD_NO_EXT_CTYPE_PRIMARY
471 rw_assert (0, __FILE__, __LINE__,
472 "_RWSTD_NO_EXT_CTYPE_PRIMARY not #defined");
473#endif // _RWSTD_NO_EXT_CTYPE_PRIMARY
474
475
476 // exercise _RWSTD_NO_EXT_MONEYPUNCT_PRIMARY
477 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_MONEYPUNCT_PRIMARY");
478
479#ifndef _RWSTD_NO_EXT_MONEYPUNCT_PRIMARY
480 rw_assert (0, __FILE__, __LINE__,
481 "_RWSTD_NO_EXT_MONEYPUNCT_PRIMARY not #defined");
482#endif // _RWSTD_NO_EXT_MONEYPUNCT_PRIMARY
483
484
485 // exercise _RWSTD_NO_EXT_NUMPUNCT_PRIMARY
486 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_NUMPUNCT_PRIMARY");
487
488#ifndef _RWSTD_NO_EXT_NUMPUNCT_PRIMARY
489 rw_assert (0, __FILE__, __LINE__,
490 "_RWSTD_NO_EXT_NUMPUNCT_PRIMARY not #defined");
491#endif // _RWSTD_NO_EXT_NUMPUNCT_PRIMARY
492
493
494 // exercise _RWSTD_NO_EXT_TIME_GET_PRIMARY
495 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_TIME_GET_PRIMARY");
496
497#ifndef _RWSTD_NO_EXT_TIME_GET_PRIMARY
498 rw_assert (0, __FILE__, __LINE__,
499 "_RWSTD_NO_EXT_TIME_GET_PRIMARY not #defined");
500#endif // _RWSTD_NO_EXT_TIME_GET_PRIMARY
501
502
503 // exercise _RWSTD_NO_EXT_TIME_PUT_PRIMARY
504 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_TIME_PUT_PRIMARY");
505
506#ifndef _RWSTD_NO_EXT_TIME_PUT_PRIMARY
507 rw_assert (0, __FILE__, __LINE__,
508 "_RWSTD_NO_EXT_TIME_PUT_PRIMARY not #defined");
509#endif // _RWSTD_NO_EXT_TIME_PUT_PRIMARY
510
511
512 // exercise _RWSTD_NO_EXT_MESSAGES_PRIMARY
513 rw_info (0, 0, __LINE__, "_RWSTD_NO_EXT_MESSAGES_PRIMARY");
514
515#ifndef _RWSTD_NO_EXT_MESSAGES_PRIMARY
516 rw_assert (0, __FILE__, __LINE__,
517 "_RWSTD_NO_EXT_MESSAGES_PRIMARY not #defined");
518#endif // _RWSTD_NO_EXT_MESSAGES_PRIMARY
519
520 return 0;
521}
522
523/* extern */ int
524main (int argc, char* argv [])
525{
526 return rw_test (argc, argv, __FILE__,
527 "intro.compliance",
528 0, // no comment
529 run_test, "", 0);
530}
531
void count(T, T, const U &,...)
int count_called
NolockBuf * nolockbuf
#define TEST_GET(T)
int ellipsis_called
Nolock * nolock
int count_pred_called
void count_if(T, T, U,...)
int distance_called
Bin * bin
void distance(T, T,...)
#define T
Definition 17.names.cpp:163
#define u
Definition 17.names.cpp:137
#define buffer
Definition 17.names.cpp:453
#define n
Definition 17.names.cpp:130
#define U
Definition 17.names.cpp:164
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define main
#define _RWSTD_LONG_LONG
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
Definition json.h:5363
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
Definition driver.cpp:1681
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
Definition driver.cpp:1630
static bool check_eofbit()
static bool check(int,...)
static bool check_badbit()
static bool check_nolock()
static bool check_bin()
static bool check_failbit()
static bool check_nolockbuf()
static bool check(int, base *)
std::num_get< char > Base
_USING(Base::get)
iter_type get(iter_type, iter_type, std::ios_base &, std::ios_base::iostate &,...) const