Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
examples.h
Go to the documentation of this file.
1
33#ifndef EXAMPLES_H_INCLUDED
34#define EXAMPLES_H_INCLUDED
35
36
37#ifdef _RWSTD_NO_NAMESPACE
38# define std
39#endif // _RWSTD_NO_NAMESPACE
40
41
42#ifdef _RWSTD_NO_FOR_LOCAL_SCOPE
43# define for if (0) ; else for
44#endif // _RWSTD_NO_FOR_LOCAL_SCOPE
45
46#include <cstddef> // for ptrdiff_t
47
48#ifdef _RWSTD_NO_LIBC_IN_STD
49
51
52// accomdate compilers that don't have size_t in namespace std
53_USING (::size_t);
54_USING (::ptrdiff_t);
55
56} // namespace std
57
58#endif // _RWSTD_NO_LIBC_IN_STD
59
60
61#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
62
63// supply conforming versions of count, count_if and distance for platforms
64// that do not correctly support partial specialization of class templates
65
67
68template<class InputIter, class T>
69size_t count (InputIter a, InputIter b, const T& x)
70{
71 size_t n = 0;
72 count (a, b, x, n);
73 return n;
74}
75
76template<class InputIter, class T>
77size_t count_if (InputIter a, InputIter b, const T& x)
78{
79 size_t n = 0;
80 count_if (a, b, x, n);
81 return n;
82
83}
84
85template<class InputIter>
87{
88 size_t n = 0;
89 distance (a, b, n);
90 return n;
91}
92
93} // namespace std
94
95#endif // _RWSTD_NO_CLASS_PARTIAL_SPEC
96
97
98
99
100#ifdef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
101
102#if !defined (_MSC_VER) || _MSC_VER > 1300
103
105
106#define has_facet fake_has_facet
107#define use_facet fake_use_facet
108
109// fake std::use_facet
110template <class Facet>
111struct has_facet
112{
113 has_facet (const std::locale &loc)
114
115#ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
116
117 : result (std::has_facet<Facet>(loc)) { }
118
119#else
120
121 : result (std::has_facet (loc, (Facet*)0)) { }
122
123#endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
124
125 operator bool () const {
126 return result;
127 }
128
129 bool result;
130};
131
132
133// fake std::use_facet
134template <class Facet>
135struct use_facet
136{
137 use_facet (const std::locale &loc)
138 : facet (std::_USE_FACET (Facet, loc)) { }
139
140 operator const Facet& () const {
141 return facet;
142 }
143
144 const Facet &facet;
145};
146
147} // namespace std
148
149#else // if defined (_MSC_VER) && _MSC_VER <= 1300
150# define _HAS_FACET(facet, locale) has_facet (locale, (facet*)0)
151#endif // !defined (_MSC_VER) || _MSC_VER > 1300
152
153#endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
154
155
156#ifdef _RWSTD_NO_EXCEPTIONS
157# define try if (1)
158# define catch(ex) else if (0) for (ex ; 0 ; )
159# define throw(ignore) abort ()
160#endif // _RWSTD_NO_EXCEPTIONS
161
162
163#ifdef _RWSTD_NO_WCHAR_T
164
165// remove `L' from wide string literals
166#define L
167
168// fake wide stream objects
169#define wcin cin
170#define wcout cout
171#define wcerr cerr
172#define wclog clog
173
174// fake wide string and stringstream
175#define wstring string
176#define wstringstream stringstream
177
178#define wchar_t char
179
180#endif // _RWSTD_NO_WCHAR_T
181
182
183// undefine macros #defined by some evil C libraries (e.g., MSVC)
184#undef max
185#undef min
186
187
188#endif // EXAMPLES_H_INCLUDED
void count(T, T, const U &,...)
void count_if(T, T, U,...)
void distance(T, T,...)
#define T
Definition 17.names.cpp:163
#define loc
Definition 17.names.cpp:492
#define x
Definition 17.names.cpp:140
#define a
Definition 17.names.cpp:109
#define b
Definition 17.names.cpp:110
#define n
Definition 17.names.cpp:130
volatile int result
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _USE_FACET(type, arg)
Definition _defs.h:921
#define _USING(name)
Definition _defs.h:568
Definition json.h:5363
#define bool
Definition stdbool.h:24