Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Commit 2020-07-25 - Bugfixes and helpers for C++98.

Bugfixes and improvements on MSVC 2005, OpenWatcom compatibility.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | release | y2020 | bugfix
Files: files | file ages | folders
SHA3-256: 9229196f425d84b22b02bdbe795f77d41a5596a2ae6fc57fc4ea30e2818c3155
User & Date: luismachuca 2020-07-27 05:40:26
Context
2020-07-27
05:40
Commit 2020-07-25 - Bugfixes and helpers for C++98.

Bugfixes and improvements on MSVC 2005, OpenWatcom compatibility. Leaf check-in: 9229196f user: luismachuca tags: release, y2020, bugfix

2020-07-26
07:03
Commit 2020-07-24 - Fixes for C++20, Clang and MSVC.

Promotes ssize(), de-promotes make_array(), adds and fixes features to use under more recent Clang and MSVC versions. check-in: 22a54863 user: luismachuca tags: clang_min_400, gcc_min_408, msvc_min_1600, release, stable, y2020

Changes

Changes to cxxomfort/CHANGELOG.txt.














1
2
3
4
5
6
7














Commit 2020-07-24 - Fixes for C++20, Clang and MSVC.

Promotes <tt>ssize()</tt>, de-promotes <tt>make_array()</tt>, adds and fixes features to use under more recent Clang and MSVC versions.

  *  algorithm: Correctly announce <tt>minmax</tt> support for Clang.
  *  array: Moved make_array out to Fundamentals (cxxomfort::library).
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Commit 2020-07-25 - Bugfixes and helpers for C++98.

Bugfixes and improvements on MSVC 2005, OpenWatcom compatibility.

  *  cxxomfort: Various minor compatibility fixes for OpenWatcom 2 (enhances: [b8ea55b791]).
  *  cstddef: Fixed the helper functions for <tt>byte</tt>.
  *  cstdint: Removed unsupported template functions on <tt>tiny[u]int</tt> for pre-C++03 compilers (enhances: [b8ea55b791], [11f57a70cf]).
  *  memory: Removed a spurious <tt>addressof()</tt> overload in pre-C++03 compilers (enhances: [b8ea55b791]).
  *  system_error: Removed unsupported template functions for pre-C++03 compilers.
  *  library/numeric: Changes to <tt>to_signed/to_unsigned</tt>.
  *  library/typesafe_enum: Added <tt>to_value</tt> helper.


Commit 2020-07-24 - Fixes for C++20, Clang and MSVC.

Promotes <tt>ssize()</tt>, de-promotes <tt>make_array()</tt>, adds and fixes features to use under more recent Clang and MSVC versions.

  *  algorithm: Correctly announce <tt>minmax</tt> support for Clang.
  *  array: Moved make_array out to Fundamentals (cxxomfort::library).

Changes to cxxomfort/cxxomfort/base/explicit_cast.hpp.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
 * * @c @ref explicit_cast (as a synonym in C++11)
 * * @c CXXO_EXPLICIT_OPERATOR
 * 
 */

#include "../config.hpp"
#include "../base/move.hpp"
//#include <ostream> // debug
#define CXXOMFORT_IMPLEMENTS_n2333 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n2437 CXXO_IMPLSTATUS_EMULATION()

#undef  CXXOMFORT_IMPLEMENTS_explicit_operator
#define CXXOMFORT_IMPLEMENTS_explicit_operator CXXOMFORT_IMPLEMENTS_n2333


................................................................................
template <typename T>
struct explicit_cast {
    T value;

    //constexpr explicit_cast (T const& v) : value( std::move(v)) {}
    explicit_cast (T&& fm) noexcept
    : value(std::move(fm)) {
//        std::cout<< "[explicit_cast::inside constructor]"<< std::endl;
    }

    template <typename F >
    explicit_cast (F&& f)
    : value(std::forward<F>(f)) {}

    operator T const& () noexcept { return value; }
................................................................................

    #define explicit_cast static_cast
    #define CXXO_EXPLICIT_OPERATOR(T) explicit operator T 

//using ::cxxomfort::detail::explicit_cast;

#endif // c++<11

/*
template <typename T>
struct explicit_cast {
    T value;
    template <typename U>
    explicit_cast (U u): value(static_cast<T>(u)) {}
    explicit_cast (T const& t) : value(t) {}
    explicit_cast (T&& t) : value(std::move(t)) {}
    operator T () const { return value; }
};
*/


#if defined(DOXYGEN_DOC)
/**
 * 
 * @page explicit_cast explicit_cast
 * 
 * The cxxomfort library implements an emulation of the "explicit operator" feature of C++11 that allows classes to provide explicit conversion to a defined set of types. 







<







 







<







 







<
<
<
<
<
<
<
<
<
<
<
<
<







9
10
11
12
13
14
15

16
17
18
19
20
21
22
..
76
77
78
79
80
81
82

83
84
85
86
87
88
89
...
108
109
110
111
112
113
114













115
116
117
118
119
120
121
 * * @c @ref explicit_cast (as a synonym in C++11)
 * * @c CXXO_EXPLICIT_OPERATOR
 * 
 */

#include "../config.hpp"
#include "../base/move.hpp"

#define CXXOMFORT_IMPLEMENTS_n2333 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n2437 CXXO_IMPLSTATUS_EMULATION()

#undef  CXXOMFORT_IMPLEMENTS_explicit_operator
#define CXXOMFORT_IMPLEMENTS_explicit_operator CXXOMFORT_IMPLEMENTS_n2333


................................................................................
template <typename T>
struct explicit_cast {
    T value;

    //constexpr explicit_cast (T const& v) : value( std::move(v)) {}
    explicit_cast (T&& fm) noexcept
    : value(std::move(fm)) {

    }

    template <typename F >
    explicit_cast (F&& f)
    : value(std::forward<F>(f)) {}

    operator T const& () noexcept { return value; }
................................................................................

    #define explicit_cast static_cast
    #define CXXO_EXPLICIT_OPERATOR(T) explicit operator T 

//using ::cxxomfort::detail::explicit_cast;

#endif // c++<11














#if defined(DOXYGEN_DOC)
/**
 * 
 * @page explicit_cast explicit_cast
 * 
 * The cxxomfort library implements an emulation of the "explicit operator" feature of C++11 that allows classes to provide explicit conversion to a defined set of types. 

Changes to cxxomfort/cxxomfort/cstdint.hpp.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


namespace cxxomfort { 

/**
 * @brief Numeric type that models a 1-byte signed int (like @c int8_t ).
 * */
typedef cxxomfort::tinyint_<signed char> tinyint;
/**
 * @brief Numeric type that models a 1-byte unsigned int (like @c uint8_t ).
 * */
typedef cxxomfort::tinyint_<unsigned char> tinyuint;

static_assert (sizeof(tinyint)==1 && alignof(tinyint)==1, "tinyint check");
static_assert (alignof(tinyuint)==1 && alignof(tinyuint)==1, "tinyuint check");


namespace fix {
	using cxxomfort::tinyint;







|



|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


namespace cxxomfort { 

/**
 * @brief Numeric type that models a 1-byte signed int (like @c int8_t ).
 * */
typedef tinyint_<signed char> tinyint;
/**
 * @brief Numeric type that models a 1-byte unsigned int (like @c uint8_t ).
 * */
typedef tinyint_<unsigned char> tinyuint;

static_assert (sizeof(tinyint)==1 && alignof(tinyint)==1, "tinyint check");
static_assert (alignof(tinyuint)==1 && alignof(tinyuint)==1, "tinyuint check");


namespace fix {
	using cxxomfort::tinyint;

Changes to cxxomfort/cxxomfort/cxxo-utils.hpp.

134
135
136
137
138
139
140

141



142
143
144
145
146
147
148
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
214
215
216
217
218
219
220


221
222
223
224
225
226


227
228

229

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258




















259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
 * @brief noop function 
 * */
struct noop_t {
    void operator() (...) const CXXO_NOEXCEPTNOTHROW {  }

};
//! noop functor - when evaluated with arguments, it does nothing

static CXXO_CONSTEXPR14	const noop_t noop = {};





/**
 * @brief denotes a reference used as an output argument to a function.
 * @see https://foonathan.net/2016/10/output-parameter/
 * */
template <typename T>
................................................................................
template <>
struct prio<0> { enum { value = 0 }; };


// 
// tinyint_ impl
// 

template <typename Base> struct tinyint_;

template <typename T, typename B>
CXXO_CONSTEXPR static inline 
T to_integral (tinyint_<B> const) CXXO_NOEXCEPTNOTHROW ;


template <typename Base>
struct tinyint_ {
	static_assert( sizeof(Base)==1, "only basic types signed char, unsigned char allowed");
	public:
#if (CXXOMFORT_CXX_STD>=2014)
	constexpr tinyint_ () noexcept = default;
................................................................................
	}

	// tinyints are explicitly convertible to any type to which their base form casts
	template <typename T>
	CXXO_EXPLICIT_OPERATOR(T) () const CXXO_NOEXCEPTNOTHROW {
		return v;
	}



	tinyint_ const& operator+ () const CXXO_NOEXCEPTNOTHROW { return *this; }
	CXXO_CONSTEXPR 
	tinyint_  operator- () const CXXO_NOEXCEPTNOTHROW { return -v; }
	CXXO_CONSTEXPR 
	tinyint_  operator~ () const CXXO_NOEXCEPTNOTHROW { return ~v; }



	tinyint_& operator++ () CXXO_NOEXCEPTNOTHROW { ++v; return *this; }

	tinyint_& operator-- () CXXO_NOEXCEPTNOTHROW { --v; return *this; }


	friend  CXXO_CONSTEXPR 
	bool operator== (tinyint_ const n1, tinyint_ const n2) CXXO_NOEXCEPTNOTHROW {
		return n1.v == n2.v;
	}
	friend 
	bool operator< (tinyint_ const n1, tinyint_ const n2) CXXO_NOEXCEPTNOTHROW {
		return n1.v < n2.v;
	}
	
	tinyint_& operator+= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v+= x2.v; return *this; }
	tinyint_& operator-= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v-= x2.v; return *this; }
	tinyint_& operator*= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v*= x2.v; return *this; }
	tinyint_& operator/= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v/= x2.v; return *this; }
	tinyint_& operator%= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v%= x2.v; return *this; }
	tinyint_& operator<<= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v<<= x2.v; return *this; }
	tinyint_& operator>>= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v>>= x2.v; return *this; }
	
	
	template <typename T> friend CXXO_CONSTEXPR
	T to_integral (tinyint_ const x) CXXO_NOEXCEPTNOTHROW {
		return static_cast<T>(x.v);
	}

	Base v;
};

typedef tinyint_<signed char> tinyint;
typedef tinyint_<unsigned char> tinyuint;





















// relationals

CXXO_GENERATE_RELATIONALS(tinyint);
CXXO_GENERATE_RELATIONALS(tinyuint);

/*
 * arithmetic operators with other types promotes to them
 * */

#define TINYINT_OPERATOR_i(IntType,SYM)  \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (tinyint n1, IntType n2) CXXO_NOEXCEPTNOTHROW { \
	return to_integral<IntType>(n1) SYM n2; \
} \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (IntType n1, tinyint n2) CXXO_NOEXCEPTNOTHROW { \
	return n1 SYM to_integral<IntType>(n2); \
} \


#define TINYINT_OPERATOR_u(IntType,SYM)  \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (tinyuint n1, IntType n2) CXXO_NOEXCEPTNOTHROW { \
	return to_integral<IntType>(n1) SYM n2; \
} \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (IntType n1, tinyuint n2) CXXO_NOEXCEPTNOTHROW { \
	return n1 SYM to_integral<IntType>(n2); \
} \


TINYINT_OPERATOR_i(signed short,+);
TINYINT_OPERATOR_i(signed short,-);
TINYINT_OPERATOR_i(signed short,*);
TINYINT_OPERATOR_i(signed short,/);
TINYINT_OPERATOR_i(signed short,%);
TINYINT_OPERATOR_i(signed int,+);
TINYINT_OPERATOR_i(signed int,-);
TINYINT_OPERATOR_i(signed int,*);
TINYINT_OPERATOR_i(signed int,/);
TINYINT_OPERATOR_i(signed int,%);
TINYINT_OPERATOR_i(signed long,+);
TINYINT_OPERATOR_i(signed long,-);
TINYINT_OPERATOR_i(signed long,*);
TINYINT_OPERATOR_i(signed long,/);
TINYINT_OPERATOR_i(signed long,%);

TINYINT_OPERATOR_u(unsigned short,+);
TINYINT_OPERATOR_u(unsigned short,-);
TINYINT_OPERATOR_u(unsigned short,*);
TINYINT_OPERATOR_u(unsigned short,/);
TINYINT_OPERATOR_u(unsigned short,%);
TINYINT_OPERATOR_u(unsigned int,+);







>

>
>
>







 







<
<
<
<
<
<
<







 







>
>



|

|
>
>

|
>
|
>





|













<
<
<
<
<





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













|



|

>




|



|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
177
178
179
180
181
182
183







184
185
186
187
188
189
190
...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251





252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
 * @brief noop function 
 * */
struct noop_t {
    void operator() (...) const CXXO_NOEXCEPTNOTHROW {  }

};
//! noop functor - when evaluated with arguments, it does nothing
#if (CXXOMFORT_CXX_STD>=1997)
static CXXO_CONSTEXPR14	const noop_t noop = {};
#else
const noop_t noop;
#endif


/**
 * @brief denotes a reference used as an output argument to a function.
 * @see https://foonathan.net/2016/10/output-parameter/
 * */
template <typename T>
................................................................................
template <>
struct prio<0> { enum { value = 0 }; };


// 
// tinyint_ impl
// 








template <typename Base>
struct tinyint_ {
	static_assert( sizeof(Base)==1, "only basic types signed char, unsigned char allowed");
	public:
#if (CXXOMFORT_CXX_STD>=2014)
	constexpr tinyint_ () noexcept = default;
................................................................................
	}

	// tinyints are explicitly convertible to any type to which their base form casts
	template <typename T>
	CXXO_EXPLICIT_OPERATOR(T) () const CXXO_NOEXCEPTNOTHROW {
		return v;
	}
	CXXO_CONSTEXPR 
	Base       value () const CXXO_NOEXCEPTNOTHROW { return v; }

	tinyint_ const& operator+ () const CXXO_NOEXCEPTNOTHROW { return *this; }
	CXXO_CONSTEXPR 
	tinyint_   operator- () const CXXO_NOEXCEPTNOTHROW { return -v; }
	CXXO_CONSTEXPR 
	tinyint_   operator~ () const CXXO_NOEXCEPTNOTHROW { return ~v; }
	CXXO_CONSTEXPR 
	bool       operator! () const CXXO_NOEXCEPTNOTHROW { return !v; }

	tinyint_&  operator++ () CXXO_NOEXCEPTNOTHROW { ++v; return *this; }
	tinyint_   operator++ (int) CXXO_NOEXCEPTNOTHROW { tinyint_ ret(*this); ++*this; return ret; }
	tinyint_&  operator-- () CXXO_NOEXCEPTNOTHROW { --v; return *this; }
	tinyint_   operator-- (int) CXXO_NOEXCEPTNOTHROW { tinyint_ ret(*this); --*this; return ret; }

	friend  CXXO_CONSTEXPR 
	bool operator== (tinyint_ const n1, tinyint_ const n2) CXXO_NOEXCEPTNOTHROW {
		return n1.v == n2.v;
	}
	friend CXXO_CONSTEXPR 
	bool operator< (tinyint_ const n1, tinyint_ const n2) CXXO_NOEXCEPTNOTHROW {
		return n1.v < n2.v;
	}
	
	tinyint_& operator+= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v+= x2.v; return *this; }
	tinyint_& operator-= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v-= x2.v; return *this; }
	tinyint_& operator*= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v*= x2.v; return *this; }
	tinyint_& operator/= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v/= x2.v; return *this; }
	tinyint_& operator%= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v%= x2.v; return *this; }
	tinyint_& operator<<= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v<<= x2.v; return *this; }
	tinyint_& operator>>= (tinyint_ const x2) CXXO_NOEXCEPTNOTHROW { v>>= x2.v; return *this; }
	
	





	Base v;
};

typedef tinyint_<signed char> tinyint;
typedef tinyint_<unsigned char> tinyuint;

template <typename T> CXXO_CONSTEXPR
T to_integral (tinyint const x) CXXO_NOEXCEPTNOTHROW {
	return x.value();
}

template <typename T> CXXO_CONSTEXPR
T to_integral (tinyuint const x) CXXO_NOEXCEPTNOTHROW {
	return x.value();
}

CXXO_CONSTEXPR static inline 
signed int to_value (tinyint const x) CXXO_NOEXCEPTNOTHROW {
	return x.value();
}

CXXO_CONSTEXPR static inline 
unsigned int to_value (tinyuint const x) CXXO_NOEXCEPTNOTHROW {
	return x.value();
}

// relationals

CXXO_GENERATE_RELATIONALS(tinyint);
CXXO_GENERATE_RELATIONALS(tinyuint);

/*
 * arithmetic operators with other types promotes to them
 * */

#define TINYINT_OPERATOR_i(IntType,SYM)  \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (tinyint n1, IntType n2) CXXO_NOEXCEPTNOTHROW { \
	return (IntType)to_value(n1) SYM n2; \
} \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (IntType n1, tinyint n2) CXXO_NOEXCEPTNOTHROW { \
	return n1 SYM (IntType)to_value(n2); \
} \


#define TINYINT_OPERATOR_u(IntType,SYM)  \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (tinyuint n1, IntType n2) CXXO_NOEXCEPTNOTHROW { \
	return (IntType)to_value(n1) SYM n2; \
} \
CXXO_CONSTEXPR static inline  \
IntType operator SYM (IntType n1, tinyuint n2) CXXO_NOEXCEPTNOTHROW { \
	return n1 SYM (IntType)to_value(n2); \
} \


TINYINT_OPERATOR_i(signed short,+ );
TINYINT_OPERATOR_i(signed short,- );
TINYINT_OPERATOR_i(signed short,* );
TINYINT_OPERATOR_i(signed short,/ );
TINYINT_OPERATOR_i(signed short,% );
TINYINT_OPERATOR_i(signed int,+ );
TINYINT_OPERATOR_i(signed int,- );
TINYINT_OPERATOR_i(signed int,* );
TINYINT_OPERATOR_i(signed int,/ );
TINYINT_OPERATOR_i(signed int,% );
TINYINT_OPERATOR_i(signed long,+ );
TINYINT_OPERATOR_i(signed long,- );
TINYINT_OPERATOR_i(signed long,* );
TINYINT_OPERATOR_i(signed long,/ );
TINYINT_OPERATOR_i(signed long,% );

TINYINT_OPERATOR_u(unsigned short,+);
TINYINT_OPERATOR_u(unsigned short,-);
TINYINT_OPERATOR_u(unsigned short,*);
TINYINT_OPERATOR_u(unsigned short,/);
TINYINT_OPERATOR_u(unsigned short,%);
TINYINT_OPERATOR_u(unsigned int,+);

Changes to cxxomfort/cxxomfort/impl/07-array.hpp.

11
12
13
14
15
16
17

18
19
20
21
22
23
24
 * 
 */
#include <cxxomfort/base.hpp>
#include <cxxomfort/impl/relationals.hpp>
#include CXXO_INCLUDE_SYS(iterator)
#include CXXO_INCLUDE_SYS(algorithm)
#define CXXOMFORT_IMPLEMENTS_n1479 CXXO_IMPLSTATUS_BACKPORT()

#define CXXOMFORT_IMPLEMENTS_array CXXOMFORT_IMPLEMENTS_n1479

namespace cxxomfort {
namespace cxxostd {
namespace array {

namespace detail {







>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * 
 */
#include <cxxomfort/base.hpp>
#include <cxxomfort/impl/relationals.hpp>
#include CXXO_INCLUDE_SYS(iterator)
#include CXXO_INCLUDE_SYS(algorithm)
#define CXXOMFORT_IMPLEMENTS_n1479 CXXO_IMPLSTATUS_BACKPORT()
#undef  CXXOMFORT_IMPLEMENTS_array
#define CXXOMFORT_IMPLEMENTS_array CXXOMFORT_IMPLEMENTS_n1479

namespace cxxomfort {
namespace cxxostd {
namespace array {

namespace detail {

Changes to cxxomfort/cxxomfort/impl/07-type_traits.hpp.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 */


#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <cxxomfort/base/nullptr.hpp>
#include <cxxomfort/base/cstdint.hpp>

// #include <cxxomfort/base/nullptr.hpp>
//#include <stdint.h> // already handled by base/stdint.h

namespace cxxomfort { namespace traits {

namespace helper {

	
	template <bool Cond, typename T> struct enable_if;
	template <typename T> struct enable_if<true,T> { typedef T type; };

    template <bool Cond, typename T1, typename T2> struct conditional        { typedef T2 type; };
    template <typename T1, typename T2> struct conditional<true,T1,T2>    { typedef T1 type; };
    
    template <typename T> struct drop_cv { typedef T type; };
    template <typename T> struct drop_cv<T const> { typedef T type; };







>








|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 */


#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <cxxomfort/base/nullptr.hpp>
#include <cxxomfort/base/cstdint.hpp>
#include <stdint.h>
// #include <cxxomfort/base/nullptr.hpp>
//#include <stdint.h> // already handled by base/stdint.h

namespace cxxomfort { namespace traits {

namespace helper {

	
	template <bool Cond, typename T=void> struct enable_if;
	template <typename T> struct enable_if<true,T> { typedef T type; };

    template <bool Cond, typename T1, typename T2> struct conditional        { typedef T2 type; };
    template <typename T1, typename T2> struct conditional<true,T1,T2>    { typedef T1 type; };
    
    template <typename T> struct drop_cv { typedef T type; };
    template <typename T> struct drop_cv<T const> { typedef T type; };

Changes to cxxomfort/cxxomfort/impl/11-addressof.hpp.

22
23
24
25
26
27
28
29


30
31

32

33
34
35
36

37
38
39
40
41
42
43
 * @brief Returns the address of an object.
 * @ingroup cxx11-backports
 * @xrefitem std0memory "<memory>" ""
 * @cppref{memory/addressof}
 */
template <typename T> inline
T* addressof (T& arg) {
    return reinterpret_cast<T*>(&reinterpret_cast<char&> (arg) );


}


//! @overload addressof

template <typename T> inline
T const* addressof (T const& arg) {
    return reinterpret_cast<T const*>(&reinterpret_cast<char const&> (arg) );
}


} // memory
} // cxxomfort


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else







|
>
>


>

>




>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 * @brief Returns the address of an object.
 * @ingroup cxx11-backports
 * @xrefitem std0memory "<memory>" ""
 * @cppref{memory/addressof}
 */
template <typename T> inline
T* addressof (T& arg) {
    return reinterpret_cast<T*>(
		&const_cast<char&>( reinterpret_cast<const volatile char&>( arg) ) 
	);
}

/*
//! @overload addressof

template <typename T> inline
T const* addressof (T const& arg) {
    return reinterpret_cast<T const*>(&reinterpret_cast<char const&> (arg) );
}
*/

} // memory
} // cxxomfort


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else

Changes to cxxomfort/cxxomfort/impl/11-underlying_type.hpp.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
30
31
32
33
34
35
36




37
38
39
40
41
42
43
44
45
46
47
48
#define CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP

/**
 * @file
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/impl/07-type_traits.hpp> // make_signed; integral_of_size
//#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp> // conditional
//#include <cxxomfort/impl/zzzvarious.hpp> // integral_of_size


#define CXXOMFORT_IMPLEMENTS_n2984_1055 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_underlying_type CXXOMFORT_IMPLEMENTS_n2984_1055

#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC)
................................................................................
    #endif
#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
    #if (CXXOMFORT_CXX_STD<2011)
        #if (CXXOMFORT_COMPILER_VERSION<1700)
            #define CXXOMFORT_USING_underlying_type 1
        #endif
    #endif




#endif // support for underlying_type

#if (defined(DOXYGEN_DOC) || defined(CXXOMFORT_USING_underlying_type))
    //#include <type_traits>
    //#include <cxxomfort/type_traits.hpp>
    #if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_WARNING( " cxxomfort library - enabled underlying_type helper" )
    #endif

    #if (CXXOMFORT_CXX_STD < 2011)
namespace {
    using cxxomfort::traits::make_signed;







<

<







 







>
>
>
>


|
<
<







2
3
4
5
6
7
8

9

10
11
12
13
14
15
16
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41


42
43
44
45
46
47
48
#define CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP

/**
 * @file
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/impl/07-type_traits.hpp> // make_signed; integral_of_size

#include <cxxomfort/impl/11-conditional.hpp> // conditional



#define CXXOMFORT_IMPLEMENTS_n2984_1055 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_underlying_type CXXOMFORT_IMPLEMENTS_n2984_1055

#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC)
................................................................................
    #endif
#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
    #if (CXXOMFORT_CXX_STD<2011)
        #if (CXXOMFORT_COMPILER_VERSION<1700)
            #define CXXOMFORT_USING_underlying_type 1
        #endif
    #endif
#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
	#define CXXOMFORT_USING_underlying_type 1
#else

#endif // support for underlying_type

#if (defined(CXXOMFORT_USING_underlying_type))


    #if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_WARNING( " cxxomfort library - enabled underlying_type helper" )
    #endif

    #if (CXXOMFORT_CXX_STD < 2011)
namespace {
    using cxxomfort::traits::make_signed;

Changes to cxxomfort/cxxomfort/impl/17-byte.hpp.

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207

// to_value synonym

namespace cxxomfort { namespace cxxostd {

CXXO_CONSTEXPR static inline 
unsigned to_value (byte b) CXXO_NOEXCEPTNOTHROW {
	return to_integral(b);
}

}}

#undef  CXXOMFORT_IMPLEMENTS_byte 
#define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3








|







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207

// to_value synonym

namespace cxxomfort { namespace cxxostd {

CXXO_CONSTEXPR static inline 
unsigned to_value (byte b) CXXO_NOEXCEPTNOTHROW {
	return to_integer<unsigned>(b);
}

}}

#undef  CXXOMFORT_IMPLEMENTS_byte 
#define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3

Changes to cxxomfort/cxxomfort/impl/to_signed.hpp.

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * @brief Provides the equivalent signed integral type to an integral type @a T .
 */
template <typename T, typename If= void>
struct to_signed_t {};

template <typename T>
struct to_signed_t<T, typename std::enable_if< cxxomfort::traits::is_scalar<T>::value >::type> 
: public to_signed_impl<T> {};

/**
 * @brief Returns the equivalent @c signed equivalent of a C++ integer value.
 * @param t A value fo one of C++'s integer types.
 * @return A value of a type similar to @a t 's, except qualified as @c signed (eg.: "signed int").
 */







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * @brief Provides the equivalent signed integral type to an integral type @a T .
 */
template <typename T, typename If= void>
struct to_signed_t {};

template <typename T>
struct to_signed_t<T, typename cxxomfort::traits::helper::enable_if< cxxomfort::traits::is_scalar<T>::value >::type> 
: public to_signed_impl<T> {};

/**
 * @brief Returns the equivalent @c signed equivalent of a C++ integer value.
 * @param t A value fo one of C++'s integer types.
 * @return A value of a type similar to @a t 's, except qualified as @c signed (eg.: "signed int").
 */

Changes to cxxomfort/cxxomfort/impl/typesafe_enum-core.hpp.

64
65
66
67
68
69
70

71

72
73
74
75
76
77
78
79
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100





101









102
103
104
105
106
107
108
109
110
    /*
    template <typename Q>
    CXXO_CONSTEXPR explicit typesafe_enum (Q v
    , typename ::std::enable_if< false==::std::is_same<Q,underlying_type>::value, Q>::type* = nullptr) 
    : val(v) {}
    */


    CXXO_CONSTEXPR enum_type value() const CXXO_NOEXCEPTNOTHROW { return val; }

    CXXO_CONSTEXPR inner underlying() const CXXO_NOEXCEPTNOTHROW { return val; }

    CXXO_EXPLICIT_OPERATOR(underlying_type) () const CXXO_NOEXCEPTNOTHROW {
        return val;
    }

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    template <typename I>
................................................................................
        static_assert (T_is_compatible_type, "typesafe_enum construction invalid - not the enum's tags or the underlying type");
    };*/

    friend CXXO_CONSTEXPR bool
    operator== (typesafe_enum const& vl, typesafe_enum const& vr) CXXO_NOEXCEPTNOTHROW {
        return vl.val == vr.val;
    }
    
    private:
    struct disallowed_enum_conversion {};
    // we disallow other constructors

};
















// inequality (uses friend version of equality)
template<typename def, typename inner>
inline CXXO_CONSTEXPR 
bool operator!= (typesafe_enum<def,inner> const& e1, typesafe_enum<def,inner> const& e2) CXXO_NOEXCEPTNOTHROW {
    return !(e1==e2);
}

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC)
#else







>
|
>
|







 







|






>
>
>
>
>
|
>
>
>
>
>
>
>
>
>

|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    /*
    template <typename Q>
    CXXO_CONSTEXPR explicit typesafe_enum (Q v
    , typename ::std::enable_if< false==::std::is_same<Q,underlying_type>::value, Q>::type* = nullptr) 
    : val(v) {}
    */

    CXXO_CONSTEXPR 
    enum_type value() const CXXO_NOEXCEPTNOTHROW { return static_cast<enum_type>(val); }
    CXXO_CONSTEXPR 
    inner underlying() const CXXO_NOEXCEPTNOTHROW { return val; }

    CXXO_EXPLICIT_OPERATOR(underlying_type) () const CXXO_NOEXCEPTNOTHROW {
        return val;
    }

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    template <typename I>
................................................................................
        static_assert (T_is_compatible_type, "typesafe_enum construction invalid - not the enum's tags or the underlying type");
    };*/

    friend CXXO_CONSTEXPR bool
    operator== (typesafe_enum const& vl, typesafe_enum const& vr) CXXO_NOEXCEPTNOTHROW {
        return vl.val == vr.val;
    }
    	
    private:
    struct disallowed_enum_conversion {};
    // we disallow other constructors

};

template< typename def, typename inner>
CXXO_CONSTEXPR inline 
typename typesafe_enum<def,inner>::enum_type     
to_value (typesafe_enum<def,inner> e) CXXO_NOEXCEPTNOTHROW {
	return e.value();
}

template< typename def, typename inner>
CXXO_CONSTEXPR inline 
typename typesafe_enum<def,inner>::underlying_type
to_integer (typesafe_enum<def,inner> e) CXXO_NOEXCEPTNOTHROW {
	return e.underlying();
}


// inequality (uses friend version of equality)
template< typename def, typename inner>
inline CXXO_CONSTEXPR 
bool operator!= (typesafe_enum<def,inner> const& e1, typesafe_enum<def,inner> const& e2) CXXO_NOEXCEPTNOTHROW {
    return !(e1==e2);
}

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC)
#else

Changes to cxxomfort/cxxomfort/limits.hpp.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

























139
140
141
142
143
144
145

/*
 * Specialization for tinu[u]int 
 * */
namespace std {

template<> struct numeric_limits<cxxomfort::tinyint>
: std::numeric_limits<signed char> {
	static CXXO_CONSTEXPR cxxomfort::tinyint const min () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyint(SCHAR_MIN); }
	static CXXO_CONSTEXPR cxxomfort::tinyint const max () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyint(SCHAR_MAX); }
#if (CXXOMFORT_CXX_STD>=2011)
	static CXXO_CONSTEXPR cxxomfort::tinyint const lowest () CXXO_NOEXCEPTNOTHROW { return min(); }
#endif
};

template<> struct numeric_limits<cxxomfort::tinyuint>
: std::numeric_limits<unsigned char> {
	static CXXO_CONSTEXPR cxxomfort::tinyuint const min () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyuint(0); }
	static CXXO_CONSTEXPR cxxomfort::tinyuint const max () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyuint(UCHAR_MAX); }
#if (CXXOMFORT_CXX_STD>=2011)
	static CXXO_CONSTEXPR cxxomfort::tinyuint const lowest () CXXO_NOEXCEPTNOTHROW { return min(); }
#endif
};

................................................................................
 * all the types that are defined as integral. The list explicitly includes: 
 * 
 * <tt>short,  int,  long,  long long</tt> in their signed and unsigned variants.
 * 
 * */
template <typename T>
struct integral_limits {
    static_assert (std::is_integral<T>::value, "integral_limits is only defined for compiler integral types");
};

#define SPECIA_IMPL(Ty_,Min_,Max_) \
template <> struct integral_limits<Ty_>           \
: public std::numeric_limits<Ty_> {               \
    typedef std::numeric_limits<Ty_> Base_;       \
    static const Ty_ const_min= Min_;             \
    static const Ty_ const_lowest = Min_;         \
    static const Ty_ const_max= Max_;             \
    template <unsigned short B> struct digits_base {   \
        static const unsigned short value=             \
        /* (digits - is_signed) / impl::log_<B>::value; */  \
        impl::log_<const_max,B>::value;   \
    };                                            \
    typedef void narrower_type; \
    typedef void wider_type; \
}

SPECIA_IMPL(bool,false,true);
SPECIA_IMPL(signed int,INT_MIN,INT_MAX);
SPECIA_IMPL(unsigned int,0,UINT_MAX);
SPECIA_IMPL(char,CHAR_MIN,CHAR_MAX);
SPECIA_IMPL(signed char,SCHAR_MIN,SCHAR_MAX);
SPECIA_IMPL(unsigned char,0,UCHAR_MAX);
SPECIA_IMPL(signed short,SHRT_MIN,SHRT_MAX);
SPECIA_IMPL(unsigned short,0,USHRT_MAX);
SPECIA_IMPL(signed long,LONG_MIN,LONG_MAX);
SPECIA_IMPL(unsigned long,0,ULONG_MAX);
SPECIA_IMPL(signed long long,LLONG_MIN,LLONG_MAX);
SPECIA_IMPL(unsigned long long,0,ULLONG_MAX);

#undef SPECIA_IMPL


























} // fix

} // cxxomfort










|








|







 







|


|




|










|
|
|
|
|
|
|
|
|
|
|
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

/*
 * Specialization for tinu[u]int 
 * */
namespace std {

template<> struct numeric_limits<cxxomfort::tinyint>
: public std::numeric_limits<signed char> {
	static CXXO_CONSTEXPR cxxomfort::tinyint const min () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyint(SCHAR_MIN); }
	static CXXO_CONSTEXPR cxxomfort::tinyint const max () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyint(SCHAR_MAX); }
#if (CXXOMFORT_CXX_STD>=2011)
	static CXXO_CONSTEXPR cxxomfort::tinyint const lowest () CXXO_NOEXCEPTNOTHROW { return min(); }
#endif
};

template<> struct numeric_limits<cxxomfort::tinyuint>
: public std::numeric_limits<unsigned char> {
	static CXXO_CONSTEXPR cxxomfort::tinyuint const min () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyuint(0); }
	static CXXO_CONSTEXPR cxxomfort::tinyuint const max () CXXO_NOEXCEPTNOTHROW { return cxxomfort::tinyuint(UCHAR_MAX); }
#if (CXXOMFORT_CXX_STD>=2011)
	static CXXO_CONSTEXPR cxxomfort::tinyuint const lowest () CXXO_NOEXCEPTNOTHROW { return min(); }
#endif
};

................................................................................
 * all the types that are defined as integral. The list explicitly includes: 
 * 
 * <tt>short,  int,  long,  long long</tt> in their signed and unsigned variants.
 * 
 * */
template <typename T>
struct integral_limits {
    static_assert (std::numeric_limits<T>::is_integer, "integral_limits is only defined for compiler integral types");
};

#define SPECIA_IMPL(Ty_,Min_,Max_,Low_) \
template <> struct integral_limits<Ty_>           \
: public std::numeric_limits<Ty_> {               \
    typedef std::numeric_limits<Ty_> Base_;       \
    static const Ty_ const_min= Min_;             \
    static const Ty_ const_lowest = Low_;         \
    static const Ty_ const_max= Max_;             \
    template <unsigned short B> struct digits_base {   \
        static const unsigned short value=             \
        /* (digits - is_signed) / impl::log_<B>::value; */  \
        impl::log_<const_max,B>::value;   \
    };                                            \
    typedef void narrower_type; \
    typedef void wider_type; \
}

SPECIA_IMPL(bool,false,true,false);
SPECIA_IMPL(signed int,INT_MIN,INT_MAX,INT_MIN);
SPECIA_IMPL(unsigned int,0,UINT_MAX,0);
SPECIA_IMPL(char,CHAR_MIN,CHAR_MAX,CHAR_MIN);
SPECIA_IMPL(signed char,SCHAR_MIN,SCHAR_MAX,SCHAR_MIN);
SPECIA_IMPL(unsigned char,0,UCHAR_MAX,0);
SPECIA_IMPL(signed short,SHRT_MIN,SHRT_MAX,SHRT_MIN);
SPECIA_IMPL(unsigned short,0,USHRT_MAX,0);
SPECIA_IMPL(signed long,LONG_MIN,LONG_MAX,LONG_MIN);
SPECIA_IMPL(unsigned long,0,ULONG_MAX,0);
SPECIA_IMPL(signed long long,LLONG_MIN,LLONG_MAX,LLONG_MIN);
SPECIA_IMPL(unsigned long long,0,ULLONG_MAX,0);

#undef SPECIA_IMPL

#define SPECIA_IMPL(Ty_,Min_,Max_,Low_) \
template <> struct integral_limits<Ty_>           \
: public std::numeric_limits<Ty_> {               \
    typedef std::numeric_limits<Ty_> Base_;       \
    static const Ty_ const_min ;             \
    static const Ty_ const_lowest ;         \
    static const Ty_ const_max ;             \
    typedef void narrower_type; \
    typedef void wider_type; \
} ; \
Ty_ const integral_limits<Ty_>::const_min = Min_; \
Ty_ const integral_limits<Ty_>::const_max = Max_; \
Ty_ const integral_limits<Ty_>::const_lowest = Low_; \


// tinyint specializations


SPECIA_IMPL(cxxomfort::tinyint,SCHAR_MIN,SCHAR_MAX,SCHAR_MIN);
SPECIA_IMPL(cxxomfort::tinyuint,0,UCHAR_MAX,0);

#undef SPECIA_IMPL



} // fix

} // cxxomfort



Changes to cxxomfort/cxxomfort/memory.hpp.

175
176
177
178
179
180
181

182
183
184
185
186
187
188
...
300
301
302
303
304
305
306




307
308
309
310
311
312
313
	#define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_NATIVE()
#elif (CXXOMFORT_CXX_STD>=1997)
	#include "impl/unique_ptr.hpp"
	#undef  CXXOMFORT_IMPLEMENTS_unique_ptr
	#define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_EMULATION()
#else
	#include "impl/unique_ptr-poor.hpp"

	#define CXXOMFORT_IMPLEMENTS_unique_ptr 0

#endif

//
// make_unique
//
................................................................................

#endif // memtools


//
// assist: malloc_deleter extension
//




namespace cxxomfort { namespace fix {

/**
 * @brief Deleter operator that uses <tt>free()</tt> for <tt>malloc</tt>-reserved blocks.
 * @ingroup cxxomfort-fix
 * @xrefitem std0memory "<memory>" "Memory Management"
 * */







>







 







>
>
>
>







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
	#define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_NATIVE()
#elif (CXXOMFORT_CXX_STD>=1997)
	#include "impl/unique_ptr.hpp"
	#undef  CXXOMFORT_IMPLEMENTS_unique_ptr
	#define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_EMULATION()
#else
	#include "impl/unique_ptr-poor.hpp"
	#undef  CXXOMFORT_IMPLEMENTS_unique_ptr
	#define CXXOMFORT_IMPLEMENTS_unique_ptr 0

#endif

//
// make_unique
//
................................................................................

#endif // memtools


//
// assist: malloc_deleter extension
//
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
	#include <malloc>
#endif

namespace cxxomfort { namespace fix {

/**
 * @brief Deleter operator that uses <tt>free()</tt> for <tt>malloc</tt>-reserved blocks.
 * @ingroup cxxomfort-fix
 * @xrefitem std0memory "<memory>" "Memory Management"
 * */

Changes to cxxomfort/cxxomfort/ostream.hpp.

8
9
10
11
12
13
14
15
16
17
18
19
20


21
22

23
24
25

26










27
28
29
30

31
32
33

34
35
36
37
38
39
40
41
42
43
44
45
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
 * 
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/cxxo-utils.hpp>
#include CXXO_INCLUDE_SYS(ostream)

namespace cxxomfort {

/*
 * Outputs a tiny[u]int 
 * */



std::ostream& operator<< (std::ostream& os, tinyint const x) CXXO_NOEXCEPTNOTHROW {
	return os<< to_integral<signed int>(x);

}
std::ostream& operator<< (std::ostream& os, tinyuint const x) CXXO_NOEXCEPTNOTHROW {
	return os<< to_integral<unsigned int>(x);

}











/*
 * Outputs a rvoid 
 * */

std::ostream& operator<< (std::ostream& os, rvoid const) CXXO_NOEXCEPTNOTHROW {
	return os;
}


} // cxxomfort::

/*
 * Outputs the given string_view to a C++ output stream.
 * */
#include <cxxomfort/string_view.hpp>

#if (CXXOMFORT_CXX_STD>=2017)
	// nothing to do
#elif (CXXOMFORT_CXX_STD>=1997)

................................................................................
    os.width(0);
    return os;
}

} }

#else
std::ostream& 
operator<< (std::ostream& os, cxxomfort::cxxostd::string_view const v) {
    using namespace std;
    size_t const l = v.length();
    for (size_t i= 0; i < l; ++i) { os<< v[i]; }
    os.width(0);
    return os;
}


#endif // cxx-std for operator<<


#endif

/**
 * @page std0ostream <ostream>







<





>
>

<
>


<
>

>
>
>
>
>
>
>
>
>
>




>



>

<
<

|







 







|
|
|






>







8
9
10
11
12
13
14

15
16
17
18
19
20
21
22

23
24
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47


48
49
50
51
52
53
54
55
56
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 * 
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/cxxo-utils.hpp>
#include CXXO_INCLUDE_SYS(ostream)



/*
 * Outputs a tiny[u]int 
 * */

#if (CXXOMFORT_CXX_STD >= 1997)
namespace cxxomfort {
std::ostream& operator<< (std::ostream& os, tinyint const x) CXXO_NOEXCEPTNOTHROW {

	return os<< "i"<< (signed)to_value(x);
}
std::ostream& operator<< (std::ostream& os, tinyuint const x) CXXO_NOEXCEPTNOTHROW {

	return os<< "u"<< (unsigned)to_value(x);
}
}
#else
std::ostream& operator<< (std::ostream& os, cxxomfort::tinyint const x) CXXO_NOEXCEPTNOTHROW {
	return os<< (signed)cxxomfort::to_value(x);
}
std::ostream& operator<< (std::ostream& os, cxxomfort::tinyuint const x) CXXO_NOEXCEPTNOTHROW {
	return os<< (unsigned)cxxomfort::to_value(x);
}

#endif

/*
 * Outputs a rvoid 
 * */
/*
std::ostream& operator<< (std::ostream& os, rvoid const) CXXO_NOEXCEPTNOTHROW {
	return os;
}
*/



/*
 * Outputs the given string_view .
 * */
#include <cxxomfort/string_view.hpp>

#if (CXXOMFORT_CXX_STD>=2017)
	// nothing to do
#elif (CXXOMFORT_CXX_STD>=1997)

................................................................................
    os.width(0);
    return os;
}

} }

#else
namespace std {

ostream& operator<< (ostream& os, cxxomfort::cxxostd::string_view const v) {
    size_t const l = v.length();
    for (size_t i= 0; i < l; ++i) { os<< v[i]; }
    os.width(0);
    return os;
}

}
#endif // cxx-std for operator<<


#endif

/**
 * @page std0ostream <ostream>

Changes to cxxomfort/cxxomfort/string.hpp.

4
5
6
7
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
..
64
65
66
67
68
69
70
71
72
73
74
75
76




77



78
79


80
81
82

83
84

85
86
87
88
89
90
91
92
93
 * @file 
 * @brief Implementations and additions tied to <tt>\<string\></tt>.
 * @xrefitem std0string "" ""
 */

#include "base.hpp"
#include <string>
#include <cstring>

#if (CXXOMFORT_CXX_STD >= 1997)

	#include "cuchar.hpp"


	#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
		#pragma message CXXO_NOTICE("enabled <string> support.")
	#endif

namespace cxxomfort {
namespace cxxostd {
................................................................................
		#endif // gcc

	#endif // pre-2011


#else // CXX_STD < 1997

	//#include "impl/11-to_string.pre97.hpp"

// 
// missing operator<< under Watcom
//
	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)




//namespace std {




std::ostream& 


operator<< (std::ostream& os, std::string const& str) CXXO_NOEXCEPTNOTHROW {
	using namespace std;
	for (size_t i= 0; i < str.length(); ++i) { os<< str[i]; }

	return os;
}


//}
	#endif

#endif // CXX_STD


// 
// hash <u16string> , hash <u32string>







<




>







 







|





>
>
>
>
|
>
>
>
|
<
>
>
|
<
<
>


>

<







4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
22
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88


89
90
91
92
93

94
95
96
97
98
99
100
 * @file 
 * @brief Implementations and additions tied to <tt>\<string\></tt>.
 * @xrefitem std0string "" ""
 */

#include "base.hpp"
#include <string>


#if (CXXOMFORT_CXX_STD >= 1997)

	#include "cuchar.hpp"
	#include <cstring>

	#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
		#pragma message CXXO_NOTICE("enabled <string> support.")
	#endif

namespace cxxomfort {
namespace cxxostd {
................................................................................
		#endif // gcc

	#endif // pre-2011


#else // CXX_STD < 1997

	#include "impl/11-to_string.pre97.hpp"

// 
// missing operator<< under Watcom
//
	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)

		#include <ostream>

		#if 1
namespace std {
ostream& operator<< (ostream& os, string const& s) {
	for (unsigned long i= 0; i < s.length(); ++i) os<< s[i];
	return os;
}

} // std
		#else
std::ostream &operator<< (std::ostream& os, std::string const& s) {


	for (unsigned long i= 0; i < s.length(); ++i) os<< s[i];
	return os;
}
	#endif


	#endif

#endif // CXX_STD


// 
// hash <u16string> , hash <u32string>

Changes to cxxomfort/cxxomfort/system_error.hpp.

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
289
290
291
292
293
294
295
296

297

298
299
300
301






302
303
304
305
306
307
308
...
313
314
315
316
317
318
319






320
321
322
323
324
325
326
327
328
329
330
331
332
333
334

335
336
337
338
339
340
341
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
...
451
452
453
454
455
456
457

458
459
460
461
462



463
464
465
466
467
468
469
	#endif

namespace cxxomfort {
namespace cxxostd {

class error_code;


//
// error_condition and helpers
//

class error_condition;

template <typename T> struct is_error_condition_enum
................................................................................
struct generic_category_t : public error_category {
    ~generic_category_t () {}

    const char* name () const CXXO_NOEXCEPTNOTHROW {
        return "generic";
    }
    std::string message (int condition) const {
        return std::string(name()) + ": " + strerror(condition);
    }
};

//! Obtains a reference to the @c error_category object for generic errors.
static inline error_category const& generic_category() CXXO_NOEXCEPTNOTHROW {
    static generic_category_t g;
    return g;
................................................................................
struct system_category_t  : public error_category {
    ~system_category_t () {}

    const char* name () const CXXO_NOEXCEPTNOTHROW {
        return "system";
    }
    std::string message (int condition) const {
        return std::string(name()) + ": " + strerror(condition);
    }
};

//! Obtains a reference to the @c error_category object for errors reported by the operating system. 
static inline error_category const& system_category() CXXO_NOEXCEPTNOTHROW {
    static system_category_t g;
    return g;
................................................................................
    v_error(From.v_error), p_category(From.p_category) );

    error_condition ( int val, error_category const& cat ) CXXO_NOEXCEPTNOTHROW
    : v_error(val), p_category(std::addressof(cat))
    {};

    // DMC does not support SFINAE-esques in member template it seems
	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC)
    template <typename EnumE>
    error_condition (EnumE e) CXXO_NOEXCEPTNOTHROW {
        *this= make_error_condition(e);
    }
	#else
		#define CXXO_SIGCONDITION (is_error_condition_enum<EnumE>::value)
    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
................................................................................
    
    int v_error;
    error_category const* p_category;
    
};

CXXO_GENERATE_RELATIONALS(error_condition);


//! Creates an @c error_condition of generic category.

static inline 
error_condition make_error_condition ( errc e ) CXXO_NOEXCEPTNOTHROW {
    return error_condition( explicit_cast<int>(e), generic_category() );
}









//
// error_code and helpers
//
/**
................................................................................
    
    error_code () CXXO_NOEXCEPTNOTHROW 
    : V(0), C(std::addressof(system_category())) {}

    error_code (int err, error_category const& ecat) CXXO_NOEXCEPTNOTHROW
    : V(err), C(&ecat) {}







    #define CXXO_SIGCONDITION (is_error_code_enum<EnumE>::value)
    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
    error_code (EnumE e CXXO_ENABLEIF_FUNCTION() ) CXXO_NOEXCEPTNOTHROW 
    /* : v_error((int)e) , p_category(&ca)  */
    {
        // this is fine to do so long as we don't add bases to error_code
        new (this) error_code (make_error_code(e));
    }

    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
    error_code& operator= (EnumE e) CXXO_NOEXCEPTNOTHROW {
        *this= make_error_code(e);
        return *this;
    }
    #undef CXXO_SIGCONDITION


    void       assign (int err, error_category const& ecat) CXXO_NOEXCEPTNOTHROW {
        V= err; C= &ecat;
    }
    
    void       clear () CXXO_NOEXCEPTNOTHROW {
        *this = error_code(0, system_category());
................................................................................
}


//
// make helpers
//
static inline error_code make_error_code( errc e ) CXXO_NOEXCEPTNOTHROW {
    return error_code(explicit_cast<int>(e), generic_category());
}

static inline error_code make_error_code( errc e , error_category const& ec) CXXO_NOEXCEPTNOTHROW {
    return error_code(explicit_cast<int>(e), ec);
}

static error_condition make_error_condition ( errc ) CXXO_NOEXCEPTNOTHROW;



//
................................................................................
    : std::runtime_error(w), E(ec), W(w) {}
    system_error (int v, error_category const& ecat)
    : std::runtime_error(error_code(v,ecat).message()), E(v,ecat), W(error_code(v,ecat).message())
    {}
    system_error (int v, error_category const& ecat, const char* const w)
    : std::runtime_error(w), E(v,ecat), W(w) {}

	#if (CXXOMFORT_CXX_STD<2011)
    // we enable construction from a std::ios::failure for conversion
    system_error (std::ios::failure const& E)
    : std::runtime_error(E.what()), E(errno,system_category()), W(E.what())
    {}

	#endif

................................................................................

std::string error_condition::message () const {
    return category().message(value());
}

// nonmember helpers


template <typename C, typename CT>
std::basic_ostream<C,CT> & operator<< (std::basic_ostream<C,CT>& os, error_code const& ec) CXXO_NOEXCEPT {
    return os << ec.category().name() << ':' << ec.value();
}




// end namespaces

}}

	#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
		#pragma warning (default:4996) // MSVC: function may be unsafe
	#endif







<







 







|







 







|







 







|







 








>

>




>
>
>
>
>
>







 







>
>
>
>
>
>
|













|
>







 







|



|







 







|







 







>





>
>
>







91
92
93
94
95
96
97

98
99
100
101
102
103
104
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
...
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
...
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
	#endif

namespace cxxomfort {
namespace cxxostd {

class error_code;


//
// error_condition and helpers
//

class error_condition;

template <typename T> struct is_error_condition_enum
................................................................................
struct generic_category_t : public error_category {
    ~generic_category_t () {}

    const char* name () const CXXO_NOEXCEPTNOTHROW {
        return "generic";
    }
    std::string message (int condition) const {
        return std::string(name()) + ": " + std::strerror(condition);
    }
};

//! Obtains a reference to the @c error_category object for generic errors.
static inline error_category const& generic_category() CXXO_NOEXCEPTNOTHROW {
    static generic_category_t g;
    return g;
................................................................................
struct system_category_t  : public error_category {
    ~system_category_t () {}

    const char* name () const CXXO_NOEXCEPTNOTHROW {
        return "system";
    }
    std::string message (int condition) const {
        return std::string(name()) + ": " + std::strerror(condition);
    }
};

//! Obtains a reference to the @c error_category object for errors reported by the operating system. 
static inline error_category const& system_category() CXXO_NOEXCEPTNOTHROW {
    static system_category_t g;
    return g;
................................................................................
    v_error(From.v_error), p_category(From.p_category) );

    error_condition ( int val, error_category const& cat ) CXXO_NOEXCEPTNOTHROW
    : v_error(val), p_category(std::addressof(cat))
    {};

    // DMC does not support SFINAE-esques in member template it seems
	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
    template <typename EnumE>
    error_condition (EnumE e) CXXO_NOEXCEPTNOTHROW {
        *this= make_error_condition(e);
    }
	#else
		#define CXXO_SIGCONDITION (is_error_condition_enum<EnumE>::value)
    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
................................................................................
    
    int v_error;
    error_category const* p_category;
    
};

CXXO_GENERATE_RELATIONALS(error_condition);


//! Creates an @c error_condition of generic category.
#if (CXXOMFORT_CXX_STD >= 1997)
static inline 
error_condition make_error_condition ( errc e ) CXXO_NOEXCEPTNOTHROW {
    return error_condition( explicit_cast<int>(e), generic_category() );
}
#else
static inline 
error_condition make_error_condition ( errc e ) CXXO_NOEXCEPTNOTHROW {
    return error_condition( cxxomfort::impl::to_value(e), generic_category() );
}
#endif



//
// error_code and helpers
//
/**
................................................................................
    
    error_code () CXXO_NOEXCEPTNOTHROW 
    : V(0), C(std::addressof(system_category())) {}

    error_code (int err, error_category const& ecat) CXXO_NOEXCEPTNOTHROW
    : V(err), C(&ecat) {}

	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
    template <typename EnumE>
    error_code (EnumE e) CXXO_NOEXCEPTNOTHROW {
        *this= make_error_code(e);
    }
	#else
		#define CXXO_SIGCONDITION (is_error_code_enum<EnumE>::value)
    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
    error_code (EnumE e CXXO_ENABLEIF_FUNCTION() ) CXXO_NOEXCEPTNOTHROW 
    /* : v_error((int)e) , p_category(&ca)  */
    {
        // this is fine to do so long as we don't add bases to error_code
        new (this) error_code (make_error_code(e));
    }

    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
    error_code& operator= (EnumE e) CXXO_NOEXCEPTNOTHROW {
        *this= make_error_code(e);
        return *this;
    }
		#undef CXXO_SIGCONDITION
	#endif

    void       assign (int err, error_category const& ecat) CXXO_NOEXCEPTNOTHROW {
        V= err; C= &ecat;
    }
    
    void       clear () CXXO_NOEXCEPTNOTHROW {
        *this = error_code(0, system_category());
................................................................................
}


//
// make helpers
//
static inline error_code make_error_code( errc e ) CXXO_NOEXCEPTNOTHROW {
    return error_code(cxxomfort::impl::to_value(e), generic_category());
}

static inline error_code make_error_code( errc e , error_category const& ec) CXXO_NOEXCEPTNOTHROW {
    return error_code(cxxomfort::impl::to_value(e), ec);
}

static error_condition make_error_condition ( errc ) CXXO_NOEXCEPTNOTHROW;



//
................................................................................
    : std::runtime_error(w), E(ec), W(w) {}
    system_error (int v, error_category const& ecat)
    : std::runtime_error(error_code(v,ecat).message()), E(v,ecat), W(error_code(v,ecat).message())
    {}
    system_error (int v, error_category const& ecat, const char* const w)
    : std::runtime_error(w), E(v,ecat), W(w) {}

	#if (CXXOMFORT_CXX_STD>=1997)
    // we enable construction from a std::ios::failure for conversion
    system_error (std::ios::failure const& E)
    : std::runtime_error(E.what()), E(errno,system_category()), W(E.what())
    {}

	#endif

................................................................................

std::string error_condition::message () const {
    return category().message(value());
}

// nonmember helpers

	#if (CXXOMFORT_CXX_STD >= 1997)
template <typename C, typename CT>
std::basic_ostream<C,CT> & operator<< (std::basic_ostream<C,CT>& os, error_code const& ec) CXXO_NOEXCEPT {
    return os << ec.category().name() << ':' << ec.value();
}


	#endif

// end namespaces

}}

	#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
		#pragma warning (default:4996) // MSVC: function may be unsafe
	#endif

Changes to cxxomfort/cxxomfort/type_traits.hpp.

123
124
125
126
127
128
129

130
131
132
133
134
135
136
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#if (CXXOMFORT_CXX_STD>= 1997 && CXXOMFORT_CXX_STD<2011)
	#if (CXXOMFORT_CXX_EMULATION >= 2007)
	#else
	#endif
#endif



/*
 * "to_integral", "to_bool" conversion helpers for 
 * integral_constant in the contexts where they don't feature the 
 * integral conversion operator (eg.: pre-C++11).
 * */

namespace cxxomfort { namespace fix {
................................................................................
//! Helper function to return the value corresponding to a <tt>false_type</tt>.
CXXO_CONSTEXPR inline bool to_bool (std::false_type) CXXO_NOEXCEPTNOTHROW { return false; }
//! Helper function to return the value corresponding to a <tt>true_type</tt>.
CXXO_CONSTEXPR inline bool to_bool (std::true_type) CXXO_NOEXCEPTNOTHROW { return true; }


}} // cxxomfort::fix



#if (CXXOMFORT_CXX_STD>=1997)


/*
 * remove_cvref, from c++20







>







 







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#if (CXXOMFORT_CXX_STD>= 1997 && CXXOMFORT_CXX_STD<2011)
	#if (CXXOMFORT_CXX_EMULATION >= 2007)
	#else
	#endif
#endif


#if (CXXOMFORT_CXX_STD>=1997)
/*
 * "to_integral", "to_bool" conversion helpers for 
 * integral_constant in the contexts where they don't feature the 
 * integral conversion operator (eg.: pre-C++11).
 * */

namespace cxxomfort { namespace fix {
................................................................................
//! Helper function to return the value corresponding to a <tt>false_type</tt>.
CXXO_CONSTEXPR inline bool to_bool (std::false_type) CXXO_NOEXCEPTNOTHROW { return false; }
//! Helper function to return the value corresponding to a <tt>true_type</tt>.
CXXO_CONSTEXPR inline bool to_bool (std::true_type) CXXO_NOEXCEPTNOTHROW { return true; }


}} // cxxomfort::fix
#endif


#if (CXXOMFORT_CXX_STD>=1997)


/*
 * remove_cvref, from c++20