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

Overview
Comment:Commit 2020-02-27 - The 27F Release [1].
  • cxxomfort: No longer needs or uses a TR1 forwarder. Note this is a breaking change. (Closes: [5a9e81910e]).
  • cxxomfort: Base components now no longer rely on any header inside impl/.
  • cxxomfort: portable stdint header moved to new vendor/ folder.
  • cxxomfort: explicit_cast support now correctly checked in when Clang announces explicit operators as an extension, for compatibility and for avoiding warnings (Enhances: [f245681931]) (See also: [1cbdc0b48d], [5ba7743db6)). * functional: Added missing namespace std connection to <tt>invoke</tt>. * functional: Added partial <tt>invoke</tt> emulation for C++03. * functional: <tt>invoke()</tt> implementation moved to its own file for clarity. * functional: <tt>invoke()</tt> now uses std version when in C++>=17. * ostream: Added, with implementations of <tt><ostream></tt>-dependent functionality in other headers. * string_view: Now works with Open Watcom (Enhances: [b8ea55b791]).
  • tuple: Partial implementation of tuple_cat for C++03.
  • type_traits: Added is_[bounded/unbounded]_array from C++20.
  • type_traits: Added remove_cvref from C++20.
  • type_traits: Added remove_all_extents from C++11.
  • type_traits: Added fix to_bool(), to_integral() for pre-C++11 integral_constant.
  • type_traits: Enabled OpenWatcom to default missing intrinsics to false_type when using cxxomfort's internal TR1 (Enhances: [b8ea55b791]).
  • utility: Changes to integer_sequence implementation to compile better under C++11.
  • utility: integer_sequence now uses std version when in C++>=14.
  • library:algorithm: Add is_clamped from p1440 .
  • library:algorithm: Add clamp_halfopen and is_clamped_halfopen, half-open interval clamping operations complementary to std::clamp.
  • library:tuple: Partial implementation of tuple_pop, tuple_shift for tuples up to 5 elements.
  • library:tuple: Now clearly exposes types for tuple pop, push, shift and unshift operations.
  • impl: Moved type_traits from util to the impl directory.
  • impl: Reworked type_traits.

This is the first "major" release of cxxomfort for 202x and thus it is marked as release and trunk. Users pulling from the default repo should be able to upgrade automagically.

There are a number of major, "shaking" changes starting with this version which feature what could be considered the "final" structure for the project. Among the most important:

* The baseline is now more streamlined. In fact, it is possible from now on to set up a minimal base with only the cxxomfort basics by keeping only these five files and folders:
cxxomfort.hpp, base.hpp, config.hpp, base/, config/. * Starting this version cxxomfort no longer requires a TR1 forwarder (and in fact, might not even work with one) when working with compilers in pre-C++11 mode that require one (see Per-Compiler Notes in the wiki). * Conversely, when needing a TR1 implementation (such as in pre-TR1 compilers), the library now honors the previously unsupported macro CXXOMFORT_USE_INTERNAL_TR1 which enables automatically a minimum TR1 featureset. * The compiler now discerns between a C++98/03 mode with TR1 support available ("C++2007"), normal C++98 mode, and a C++ mode without C++98 support ("pre-1997"). This distinction is mostly relevant for compilers such as MSVC <= 2008 and OpenWatcom. * Some files from external sources are now moved to a vendor directory space. * When on Windows, the library now requires and enforces the value of the __STDC_LIMIT_MACROS macro.

This release has been tested on: GCC 4.6 to 5.5 in C++03 mode; GCC 4.6 to 6.0 in C++11 mode; GCC 6 in C++14 mode; MSVC 2008 SP1; MSVC 2012; MSVC 2013 (partially); clang 3.0 to 3.4 in C++03 mode; clang 3.2 to 4.0 in C++11 mode; clang 4.0 in C++14 mode; Open Watcom CI release (partial).

The autogenerated documentation ( http://ryan.gulix.cl/fossil.cgi/cxxomfort/uv/html/) is updated for this release.

Planned updates for the future:

  • Evaluating in full invoke() for C++03.
  • Backporting shift operations from <algorithm> down to at least C++11.
  • Backporting bind_front() down to at least C++11.
  • Backporting bit_cast() down to at least C++11.
  • A true arithmetic type with sizeof()==1 (à-la signed/unsigned char).
  • p0192 "short floats" (16-bit floating point types for storage only).
  • p1402 "cstring_view" (view of native C++ strings).
  • Refining is_contiguous_sequence.
  • "Moving" accumulate and partial_sum as per p0616.

[1] "27F": The release coincides with the 10th anniversary of the 27F Event or Great Cobquecura Earthquake of 2010 (2010-02-27): see https://en.wikipedia.org/wiki/2010_Chile_earthquake . This is why I say it is a shaking release.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | msvc_min_1500 | clang_min_302 | openwatcom_min_200 | release | y2020 | gcc_min_406
Files: files | file ages | folders
SHA3-256:4dad71eb2a7ac367250927727f311cd1fb83646ad7d29d29ba29af7c7ac3277c
User & Date: luismachuca 2020-02-28 03:36:12
References
2020-02-28
03:53 Ticket [1cbdc0b4] Progress Tracking for Clang (2.6-2.8) status still Open with 6 other changes artifact: b0735d8b user: luismachuca
03:52 Ticket [f2456819] clang: Feature detection via has_feature vs has_extension status still Open with 5 other changes artifact: 98f1d119 user: luismachuca
03:48 Ticket [b8ea55b7] Progress Tracking for OpenWatcom status still Open with 6 other changes artifact: 4898216c user: luismachuca
Context
2020-06-15
04:19
Commit 2020-06-12 - Not the isolation that kills your commits
  • cxxomfort: Fixed an error with the previous release where cxxomfort's cstdint is ignored and a potentially non-existing stdint.h is included in MSVC < 2010.
  • cxxomfort: Now implements a SD-6 header that tests for and backports some of the SD-6 support macros.
  • cxxomfort: Added cxxo-utils.hpp with some base utilities.
  • cxxomfort: Added outp<T>.
  • cxxomfort: Added CXXO_TYPEOF_OR(), CXXO_AUTO_OR macros.
  • algorithm: Added fix / helper ct_clamp.
  • cerrno: New implementation of errc picks most enumerator values and errno names from the underlying system.
  • system_error: Minor simplifications to the code when in C++<11.
  • library:array_ref: Now supports index types shorter than size_t (via default template parameter), for eg.: small-buffers.
  • library:fixed_vector: Now supports index types shorter than size_t (via allocator), for eg.: short-allocator or small size vectors.
  • library:typesafe_enum: Fixed a missing dependency in C++<11.
  • library:tuple: Fixed implementation of tuple_shift for C++03.
  • library:tuple: Fixed a bug in tuple_pop where the first element of the returned tuple would always be default-constructed.
  • tags: Updated tags.
check-in: 70919e9e user: luismachuca tags: trunk, release, y2020, gcc_min_408, clang_min_400, geany_tags, msvc_min_1700
2020-02-28
03:36
Commit 2020-02-27 - The 27F Release [1].
  • cxxomfort: No longer needs or uses a TR1 forwarder. Note this is a breaking change. (Closes: [5a9e81910e]).
  • cxxomfort: Base components now no longer rely on any header inside impl/.
  • cxxomfort: portable stdint header moved to new vendor/ folder.
  • cxxomfort: explicit_cast support now correctly checked in when Clang announces explicit operators as an extension, for compatibility and for avoiding warnings (Enhances: [f245681931]) (See also: [1cbdc0b48d], [5ba7743db6)). * functional: Added missing namespace std connection to <tt>invoke</tt>. * functional: Added partial <tt>invoke</tt> emulation for C++03. * functional: <tt>invoke()</tt> implementation moved to its own file for clarity. * functional: <tt>invoke()</tt> now uses std version when in C++>=17. * ostream: Added, with implementations of <tt><ostream></tt>-dependent functionality in other headers. * string_view: Now works with Open Watcom (Enhances: [b8ea55b791]).
  • tuple: Partial implementation of tuple_cat for C++03.
  • type_traits: Added is_[bounded/unbounded]_array from C++20.
  • type_traits: Added remove_cvref from C++20.
  • type_traits: Added remove_all_extents from C++11.
  • type_traits: Added fix to_bool(), to_integral() for pre-C++11 integral_constant.
  • type_traits: Enabled OpenWatcom to default missing intrinsics to false_type when using cxxomfort's internal TR1 (Enhances: [b8ea55b791]).
  • utility: Changes to integer_sequence implementation to compile better under C++11.
  • utility: integer_sequence now uses std version when in C++>=14.
  • library:algorithm: Add is_clamped from p1440 .
  • library:algorithm: Add clamp_halfopen and is_clamped_halfopen, half-open interval clamping operations complementary to std::clamp.
  • library:tuple: Partial implementation of tuple_pop, tuple_shift for tuples up to 5 elements.
  • library:tuple: Now clearly exposes types for tuple pop, push, shift and unshift operations.
  • impl: Moved type_traits from util to the impl directory.
  • impl: Reworked type_traits.

This is the first "major" release of cxxomfort for 202x and thus it is marked as release and trunk. Users pulling from the default repo should be able to upgrade automagically.

There are a number of major, "shaking" changes starting with this version which feature what could be considered the "final" structure for the project. Among the most important:

* The baseline is now more streamlined. In fact, it is possible from now on to set up a minimal base with only the cxxomfort basics by keeping only these five files and folders:
cxxomfort.hpp, base.hpp, config.hpp, base/, config/. * Starting this version cxxomfort no longer requires a TR1 forwarder (and in fact, might not even work with one) when working with compilers in pre-C++11 mode that require one (see Per-Compiler Notes in the wiki). * Conversely, when needing a TR1 implementation (such as in pre-TR1 compilers), the library now honors the previously unsupported macro CXXOMFORT_USE_INTERNAL_TR1 which enables automatically a minimum TR1 featureset. * The compiler now discerns between a C++98/03 mode with TR1 support available ("C++2007"), normal C++98 mode, and a C++ mode without C++98 support ("pre-1997"). This distinction is mostly relevant for compilers such as MSVC <= 2008 and OpenWatcom. * Some files from external sources are now moved to a vendor directory space. * When on Windows, the library now requires and enforces the value of the __STDC_LIMIT_MACROS macro.

This release has been tested on: GCC 4.6 to 5.5 in C++03 mode; GCC 4.6 to 6.0 in C++11 mode; GCC 6 in C++14 mode; MSVC 2008 SP1; MSVC 2012; MSVC 2013 (partially); clang 3.0 to 3.4 in C++03 mode; clang 3.2 to 4.0 in C++11 mode; clang 4.0 in C++14 mode; Open Watcom CI release (partial).

The autogenerated documentation ( http://ryan.gulix.cl/fossil.cgi/cxxomfort/uv/html/) is updated for this release.

Planned updates for the future:

  • Evaluating in full invoke() for C++03.
  • Backporting shift operations from <algorithm> down to at least C++11.
  • Backporting bind_front() down to at least C++11.
  • Backporting bit_cast() down to at least C++11.
  • A true arithmetic type with sizeof()==1 (à-la signed/unsigned char).
  • p0192 "short floats" (16-bit floating point types for storage only).
  • p1402 "cstring_view" (view of native C++ strings).
  • Refining is_contiguous_sequence.
  • "Moving" accumulate and partial_sum as per p0616.

[1] "27F": The release coincides with the 10th anniversary of the 27F Event or Great Cobquecura Earthquake of 2010 (2010-02-27): see https://en.wikipedia.org/wiki/2010_Chile_earthquake . This is why I say it is a shaking release. check-in: 4dad71eb user: luismachuca tags: trunk, msvc_min_1500, clang_min_302, openwatcom_min_200, release, y2020, gcc_min_406

2020-02-07
16:45
Commit 2020-02-04 - Compatibility improvements for MSVC 2012, GCC 6.x [2]
  • Fixed missing hexdump.hpp.
check-in: 2e1ff340 user: luismachuca tags: msvc_max_1700, msvc_min_1500, release, y2020, gcc_max_605, gcc_min_408, tagfiles
Changes

Changes to cxxomfort/CHANGELOG.txt.




























































































1
2
3
4
5
6
7



























































































Commit 2020-01-13 - The “don't ask me for documentation fixes, I don't have 2020 vision” release.

  *  cxxomfort: Added detection of Clang 4.x with some features.
  *  cxxomfort: CXXOMFORT_VERSION now copies CXXOMFORT_DATE.
  *  config: Slightly improved detection of Clang <tt>__has_extension</tt>.
  *  algorithm: Fixed <tt>any_of</tt> returning always true (Fixes: [98efdadf5b]).
  *  functional: Fixed missing connection of documentation for heterogeneous functors.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
Commit 2020-02-27 - The 27F Release [1].

  *  cxxomfort: No longer needs or uses a TR1 forwarder. Note this is a breaking change. (Closes: [5a9e81910e]).
  *  cxxomfort: Base components now no longer rely on any header inside <tt>impl/</tt>.
  *  cxxomfort: portable stdint header moved to new <tt>vendor/</tt> folder.
  *  cxxomfort: <tt>explicit_cast</tt> support now correctly checked in when Clang announces explicit operators as an extension, for compatibility and for avoiding warnings (Enhances: [f245681931]) (See also: [1cbdc0b48d], [5ba7743db6)).
  *  functional: Added missing namespace std connection to <tt>invoke</tt>.
  *  functional: Added partial <tt>invoke</tt> emulation for C++03.
  *  functional: <tt>invoke()</tt> implementation moved to its own file for clarity.
  *  functional: <tt>invoke()</tt> now uses std version when in C++>=17.
  *  ostream: Added, with implementations of <tt><ostream></tt>-dependent functionality in other headers.
  *  string_view: Now works with Open Watcom (Enhances: [b8ea55b791]).
  *  tuple: Partial implementation of <tt>tuple_cat</tt> for C++03.
  *  type_traits: Added <tt>is_[bounded/unbounded]_array</tt> from C++20.
  *  type_traits: Added <tt>remove_cvref</tt> from C++20.
  *  type_traits: Added <tt>remove_all_extents</tt> from C++11.
  *  type_traits: Added fix <tt>to_bool()</tt>, <tt>to_integral()</tt> for pre-C++11 <tt>integral_constant</tt>.
  *  type_traits: Enabled OpenWatcom to default missing intrinsics to <tt>false_type</tt> when using cxxomfort's internal TR1 (Enhances: [b8ea55b791]).
  *  utility: Changes to <tt>integer_sequence</tt> implementation to compile better under C++11.
  *  utility: <tt>integer_sequence</tt> now uses std version when in C++>=14.
  *  library:algorithm: Add <tt>is_clamped</tt> from p1440 .
  *  library:algorithm: Add <tt>clamp_halfopen</tt> and <tt>is_clamped_halfopen</tt>, half-open interval clamping operations complementary to <tt>std::clamp</tt>.
  *  library:tuple: Partial implementation of <tt>tuple_pop</tt>, <tt>tuple_shift</tt> for tuples up to 5 elements.
  *  library:tuple: Now clearly exposes types for tuple pop, push, shift and unshift operations.
  *  impl: Moved type_traits from util to the impl directory.
  *  impl: Reworked type_traits.

This is the first "major" release of cxxomfort for <tt>202x</tt> and thus it is marked as <tt>release</tt> and <tt>trunk</tt>. Users pulling from the default repo should be able to upgrade automagically. 

There are a number of major, "<em>shaking</em>" changes starting with this version which feature what could be considered the "final" structure for the project. Among the most important: 

  * The baseline is now more streamlined. In fact, it is possible from now on to set up a minimal base with only the cxxomfort basics by keeping only these five files and folders: <br/><tt>cxxomfort.hpp, base.hpp, config.hpp, base/, config/</tt>.
  * Starting this version cxxomfort <b>no longer requires a TR1 forwarder</b> (and in fact, might not even work with one) when working with compilers in pre-C++11 mode that require one (see Per-Compiler Notes in the wiki).
  * Conversely, when needing a TR1 implementation (such as in pre-TR1 compilers), the library now honors the previously unsupported macro <tt>CXXOMFORT_USE_INTERNAL_TR1</tt> which enables automatically a minimum TR1 featureset.
  * The compiler now discerns between a C++98/03 mode with TR1 support available ("C++2007"), normal C++98 mode, and a C++ mode without C++98 support ("pre-1997"). This distinction is mostly relevant for compilers such as MSVC <= 2008 and OpenWatcom.
  * Some files from external sources are now moved to a <tt>vendor</tt> directory space.
  * When on Windows, the library now requires and enforces the value of the <tt>__STDC_LIMIT_MACROS</tt> macro.

This release has been tested on: GCC 4.6 to 5.5 in C++03 mode; GCC 4.6 to 6.0 in C++11 mode; GCC 6 in C++14 mode; MSVC 2008 SP1; MSVC 2012; MSVC 2013 (partially); clang 3.0 to 3.4 in C++03 mode; clang 3.2 to 4.0 in C++11 mode; clang 4.0 in C++14 mode; Open Watcom CI release (partial).

The autogenerated documentation ( http://ryan.gulix.cl/fossil.cgi/cxxomfort/uv/html/) is updated for this release.

Planned updates for the future:

  *  Evaluating in full <tt>invoke()</tt> for C++03.
  *  Backporting shift operations from <tt><algorithm></tt> down to at least C++11.
  *  Backporting <tt>bind_front()</tt> down to at least C++11.
  *  Backporting <tt>bit_cast()</tt> down to at least C++11.
  *  A true arithmetic type with <tt>sizeof()==1</tt> (à-la <tt>signed/unsigned char</tt>).
  *  p0192 "short floats" (16-bit floating point types for storage only).
  *  p1402 "<tt>cstring_view</tt>" (view of native C++ strings).
  *  Refining <tt>is_contiguous_sequence</tt>.
  *  "Moving" accumulate and partial_sum as per p0616.

[1] "27F": The release coincides with the 10th anniversary of the 27F Event or Great Cobquecura Earthquake of 2010 (2010-02-27): see https://en.wikipedia.org/wiki/2010_Chile_earthquake . This is why I say it is a shaking release.


Commit 2020-02-04 - Compatibility improvements for MSVC 2012, GCC 6.x [2]

  *  Fixed missing hexdump.hpp.

Commit 2020-02-04 - Compatibility improvements for MSVC 2012, GCC 6.x.

  *  cxxomfort: Added better compatibility with GCC in C++14 mode (Enhances: []).
  *  cxxomfort: Added better detection of MSVC 2012 and MSVC 2013 (Enhances: [70b70d8017]).
  *  cstddef: Moved CXXOMFORT_IMPLEMENTS_decltype from utility.
  *  cstddef: Moved <tt>to_byte</tt> to fixes (<tt>cxxomfort::fix</tt>).
  *  ctime: Now uses POSIX <tt>timespec</tt> functions when in POSIX env.
  *  ctime: Now implements <tt>timespec_get()</tt> in terms of <tt>GetSystemTime()</tt> when in Windows env.
  *  memory: Fixed <tt>make_unique</tt> double / conflicting definition in GCC C++14 emulation mode (Enhances: []).
  *  numeric: Fixed an issue where the template argument names for gcd, lcm cause conflicts in MSVC >= 2010.
  *  string_view: Fixed a copy-ctor and assignment compilation error due to partial constexpr support (see library:array_ref).
  *  string_view: Fixed missing reverse iterators.
  *  system_error: Fixed an issue where code including the header would not compile if it was the only backported header it was using.
  *  tuple: Fixed <tt>get<type>(tuple<...>)</tt> not being backported to C++11 in GCC≥5.
  *  tuple: Fixed <tt>get<type>(tuple<...>)</tt> clashing with GCC 6.x in C++14 emulation mode (<tt>__cplusplus==201500</tt>) (Enhances: []).
  *  tuple: Fixed <tt>make_from_tuple</tt> not being backported to C++11, C++14 in GCC≥5.
  *  utility: moved CXXOMFORT_IMPLEMENTS_decltype to cstddef.
  *  library:algorithm: Added <tt>[any,all,none]_on</tt>.
  *  library:array_ref: Made front, back noexcept where available.
  *  library:array_ref: Added <tt>size_bytes</tt> member function, adapting from C++20 span.
  *  library:array_ref: Added a workaround for GCC bug on "defaulted declaration differs" for GCC < 7 (see [E1])
  *  library:array_ref: Added missing <tt>operator==, operator!=</tt>.
  *  library:functional: Fixed anachronistic parameter passing in <tt>constant_fn()</tt>.
  *  library:numeric: <tt>static_min</tt>, <tt>static_max</tt> now take up to 10 arguments.
  *  library:utility: Added <tt>hexdump</tt>, <tt>hexload</tt>.
  *  library:utility: Added utility typedefs <tt>bytes_view</tt>, <tt>const_bytes_view</tt> and utility function <tt>as_bytes_view()</tt>.

[E1] https://stackoverflow.com/questions/20610658/defaulted-move-assignment-cannot-be-explicitly-noexcept-if-a-member-has-a-non-tr


Commit 2020-01-13 - The “don't ask me for documentation fixes, I don't have 2020 vision” release.

  *  cxxomfort: Added detection of Clang 4.x with some features.
  *  cxxomfort: CXXOMFORT_VERSION now copies CXXOMFORT_DATE.
  *  config: Slightly improved detection of Clang <tt>__has_extension</tt>.
  *  algorithm: Fixed <tt>any_of</tt> returning always true (Fixes: [98efdadf5b]).
  *  functional: Fixed missing connection of documentation for heterogeneous functors.

Changes to cxxomfort/cxxomfort/algorithm.hpp.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
273
274
275
276
277
278
279

280

281
282
283
284
285
286
287
...
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
...
346
347
348
349
350
351
352

353
354
355
356
357
358
359
 * A general listing of the Standard utilities here, with sample implementations, 
 * can be found at @cppref{header/algorithm}.
 * 
 */

#include "base.hpp"
#include CXXO_INCLUDE_SYS(algorithm)
//#include "util/meta.hpp" // conditional

namespace cxxomfort { namespace cxxostd {

#if (1)

/**
 * @brief Copy elements conditionally to @a dest if they fulfill @a f .
................................................................................
} } //~namespace cxxomfort::cxxostd



// These are in their own files
// included in c++11 onwards
#include "impl/11-is_xxx_of.hpp"

#include "impl/11-minmax.hpp"

#include "impl/11-permutations.hpp"
// c++14 onwards
#include "impl/14-algorithm-equal.hpp"
// c++17 onwards
#include "impl/17-clamp.hpp"

#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
................................................................................
	using ::cxxomfort::cxxostd::shuffle;
	//using ::cxxomfort::cxxostd::all_of;
	//using ::cxxomfort::cxxostd::any_of;
	//using ::cxxomfort::cxxostd::none_of;
	//using ::cxxomfort::cxxostd::minmax;
	//using ::cxxomfort::cxxostd::minmax_element;
	#endif

	#if (CXXOMFORT_CXX_STD < 2014 && CXXOMFORT_CXX_EMULATION < 2014)
	using ::cxxomfort::cxxostd::equal;
	using ::cxxomfort::cxxostd::mismatch;
	#endif

	#if (CXXOMFORT_CXX_STD < 2017 && CXXOMFORT_CXX_EMULATION < 2017)
	using ::cxxomfort::cxxostd::for_each_n;
	//using ::cxxomfort::cxxostd::clamp;
	#endif

	#if (CXXOMFORT_CXX_STD < 2020 && CXXOMFORT_CXX_EMULATION < 2020)
	using ::cxxomfort::cxxostd::count;
	using ::cxxomfort::cxxostd::count_if;
	#endif
	
	
#endif


#endif

/**
 * @page std0algorithm <algorithm>
 * @brief Backports related to Standard header <tt><algorithm></tt>
 * 
................................................................................
 * * @c clamp() (C++17) - constrain values.
 * * @c count() , @c count_if() (C++17) - count elements in a sequence.
 * * @c for_each_n() (C++17) - execute functors across a sequence.
 * 
 * Pending:
 * 
 * * @c shuffle

 * 
 * 
 *
 * Algorithm demonstrations:
 * 
 * Copies and prints elements from a list via 
 * @c copy_if() and @c for_each_n() .







<







 







>

>







 







>
|



>




>







<







 







>







9
10
11
12
13
14
15

16
17
18
19
20
21
22
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
...
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
331
332
333
...
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
 * A general listing of the Standard utilities here, with sample implementations, 
 * can be found at @cppref{header/algorithm}.
 * 
 */

#include "base.hpp"
#include CXXO_INCLUDE_SYS(algorithm)


namespace cxxomfort { namespace cxxostd {

#if (1)

/**
 * @brief Copy elements conditionally to @a dest if they fulfill @a f .
................................................................................
} } //~namespace cxxomfort::cxxostd



// These are in their own files
// included in c++11 onwards
#include "impl/11-is_xxx_of.hpp"
//! @include{doc} impl/11-is_xxx_of.hpp
#include "impl/11-minmax.hpp"
//! @include{doc} impl/11-minmax.hpp
#include "impl/11-permutations.hpp"
// c++14 onwards
#include "impl/14-algorithm-equal.hpp"
// c++17 onwards
#include "impl/17-clamp.hpp"

#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
................................................................................
	using ::cxxomfort::cxxostd::shuffle;
	//using ::cxxomfort::cxxostd::all_of;
	//using ::cxxomfort::cxxostd::any_of;
	//using ::cxxomfort::cxxostd::none_of;
	//using ::cxxomfort::cxxostd::minmax;
	//using ::cxxomfort::cxxostd::minmax_element;
	#endif

	#if (CXXOMFORT_CXX_STD < 2014 || defined(CXXOMFORT_IMPLEMENTS_two_ranges_equal_mismatch))
	using ::cxxomfort::cxxostd::equal;
	using ::cxxomfort::cxxostd::mismatch;
	#endif
	
	#if (CXXOMFORT_CXX_STD < 2017 && CXXOMFORT_CXX_EMULATION < 2017)
	using ::cxxomfort::cxxostd::for_each_n;
	//using ::cxxomfort::cxxostd::clamp;
	#endif

	#if (CXXOMFORT_CXX_STD < 2020 && CXXOMFORT_CXX_EMULATION < 2020)
	using ::cxxomfort::cxxostd::count;
	using ::cxxomfort::cxxostd::count_if;
	#endif
	
	
#endif


#endif

/**
 * @page std0algorithm <algorithm>
 * @brief Backports related to Standard header <tt><algorithm></tt>
 * 
................................................................................
 * * @c clamp() (C++17) - constrain values.
 * * @c count() , @c count_if() (C++17) - count elements in a sequence.
 * * @c for_each_n() (C++17) - execute functors across a sequence.
 * 
 * Pending:
 * 
 * * @c shuffle
 * * @c shift_left, @c shift_right
 * 
 * 
 *
 * Algorithm demonstrations:
 * 
 * Copies and prints elements from a list via 
 * @c copy_if() and @c for_each_n() .

Changes to cxxomfort/cxxomfort/array.hpp.

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
75
76
77
78
79
80
81




82
83
84
85
86
87
88
89
90
91
92
93
	#endif

#elif (CXXOMFORT_CXX_STD < 2011)
	#if defined(CXXOMFORT_USE_INTERNAL_TR1)
		// not even C++03
		#include "impl/07-array.hpp"


namespace std {
	using ::cxxomfort::cxxostd::array::array;
	using ::cxxomfort::cxxostd::array::get;
}

	#elif (CXXOFLAG_tr1 > 0)
		// c++03, with TR1
................................................................................
#endif // CXX_STD

#endif


/**
 * @page std0array <array>
 * @brief Backports from @c <array> 
 * 
 * @code
#include <cxxomfort/array.hpp>
 * @endcode
 * 
 * Including the header brings up @c std::array , accounting for eg.: 
 * location being @c std::tr1::array where set up in C++03.
................................................................................
 * type and size set up at compile time, but it also adds an interface 
 * similar to most of C++'s sequence containers: 
 * it has a <tt>begin/end</tt>, an <tt>iterator</tt> type, and 
 * accepts indexing of elements via the <tt>operator[]</tt>.
 * 
 * Interfaces defined in this section:
 * 




 * * @c std::array (C++11) - C++ type version of a C-array.
 * * @c get() - Get an element from an array by its compile-time index.
 * 
 * 
 * @section See Also 
 * 
 * @see @cppref{header/array} (cppreference)
 * @see @cppref{array}
 * @see @ref{libarrayref,cxxomfort's @c array_ref }
 * 
 * */








<







 







|







 







>
>
>
>












26
27
28
29
30
31
32

33
34
35
36
37
38
39
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	#endif

#elif (CXXOMFORT_CXX_STD < 2011)
	#if defined(CXXOMFORT_USE_INTERNAL_TR1)
		// not even C++03
		#include "impl/07-array.hpp"


namespace std {
	using ::cxxomfort::cxxostd::array::array;
	using ::cxxomfort::cxxostd::array::get;
}

	#elif (CXXOFLAG_tr1 > 0)
		// c++03, with TR1
................................................................................
#endif // CXX_STD

#endif


/**
 * @page std0array <array>
 * @brief Backports related to Standard header <tt><array></tt> 
 * 
 * @code
#include <cxxomfort/array.hpp>
 * @endcode
 * 
 * Including the header brings up @c std::array , accounting for eg.: 
 * location being @c std::tr1::array where set up in C++03.
................................................................................
 * type and size set up at compile time, but it also adds an interface 
 * similar to most of C++'s sequence containers: 
 * it has a <tt>begin/end</tt>, an <tt>iterator</tt> type, and 
 * accepts indexing of elements via the <tt>operator[]</tt>.
 * 
 * Interfaces defined in this section:
 * 
 * * (none)
 * 
 * Interfaces repointed in this section:
 * 
 * * @c std::array (C++11) - C++ type version of a C-array.
 * * @c get() - Get an element from an array by its compile-time index.
 * 
 * 
 * @section See Also 
 * 
 * @see @cppref{header/array} (cppreference)
 * @see @cppref{array}
 * @see @ref{libarrayref,cxxomfort's @c array_ref }
 * 
 * */

Changes to cxxomfort/cxxomfort/backports.hpp.

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41




42
43
44
45
46
47
#include "iterator.hpp" // <iterator> backports: global begin/end, etc
#include "string.hpp" // <string> backports: to_string
#include "utility.hpp" // <utility> backports: declval, exchange, pair, etc...

#include "array.hpp" // std::array
#include "forward_list.hpp" // std::forward_list
#include "string_view.hpp" // <string_view> backports
#include "typeindex.hpp" // std::type_index

#include "functional.hpp" // <functional> backports (transparent functors, etc...)
#include "memory.hpp" // <memory> backports (pointer_traits, alignof, unique_ptr, etc...)
#include "numeric.hpp" // <numeric> backports (iota, etc...)
#include "random.hpp" // <random> backports (rename fixes, std::random_device, etc...)
#include "system_error.hpp" // <system_error> backports
#include "tuple.hpp" // <tuple> backports (tuple get<type>, etc...)




#include "type_traits.hpp" // <type_traits> backports (common_type, decay, is_literal, is_null_pointer, etc...)

//#include "ios.hpp" // <ios> stuff.
//#include "span.php" // <span> stuff.

#endif







<





<

>
>
>
>


|



27
28
29
30
31
32
33

34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
#include "iterator.hpp" // <iterator> backports: global begin/end, etc
#include "string.hpp" // <string> backports: to_string
#include "utility.hpp" // <utility> backports: declval, exchange, pair, etc...

#include "array.hpp" // std::array
#include "forward_list.hpp" // std::forward_list
#include "string_view.hpp" // <string_view> backports


#include "functional.hpp" // <functional> backports (transparent functors, etc...)
#include "memory.hpp" // <memory> backports (pointer_traits, alignof, unique_ptr, etc...)
#include "numeric.hpp" // <numeric> backports (iota, etc...)
#include "random.hpp" // <random> backports (rename fixes, std::random_device, etc...)

#include "tuple.hpp" // <tuple> backports (tuple get<type>, etc...)

#include "typeindex.hpp" // std::type_index
#include "ostream.hpp" // ostream<< helpers
#include "system_error.hpp" // <system_error> backports
#include "type_traits.hpp" // <type_traits> backports (common_type, decay, is_literal, is_null_pointer, etc...)

#include "ios.hpp" // <ios> stuff.
//#include "span.php" // <span> stuff.

#endif

Changes to cxxomfort/cxxomfort/base/cstdint.hpp.

6
7
8
9
10
11
12

13

14
15
16
17
18
19
20
21
22
23
24
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

/*
 * This header file redirects to the header providing
 * the standard integer types; in C++11 this is
 * <cstdint>, whereas in C++03 this is <stdint.h>
 */
#include "../config.hpp"

#define __STDC_LIMIT_MACROS


#if (CXXOMFORT_CXX_STD>=2011)
    #if defined(CXXOMFORT_NOTICES)  && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("Including <cstdint> in C++11 mode")
    #endif
    #include <cstdint>
    #define CXXOMFORT_USING_NATIVE_stdint
#else
    #if 0
        #error ("Unreachable.");
    
................................................................................
#endif // c++11

#if (!defined(CXXOMFORT_USING_NATIVE_stdint))
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("cstdint forwarded to portable-stdint")
    #endif
    //#define __STDC_LIMIT_MACROS
    #include "../impl/pstdint.h"
    #define CXXOMFORT_USING_PSTDINT_stdint
    // use up the macro guard of stdint.h to prevent a collission
    #define _MSC_STDINT_H_ // win32
#endif // using pstdint

#include <climits>
#include <stddef.h>
#endif // header








>
|
>

|

|







 







|









6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

/*
 * This header file redirects to the header providing
 * the standard integer types; in C++11 this is
 * <cstdint>, whereas in C++03 this is <stdint.h>
 */
#include "../config.hpp"
#if !defined(__STDC_LIMIT_MACROS)
	#define __STDC_LIMIT_MACROS
#endif

#if (CXXOMFORT_CXX_STD>=2011 || CXXO_CXXSTDHEADER_cstdint)
    #if defined(CXXOMFORT_NOTICES)  && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("Including <cstdint> in C++11 mode or native")
    #endif
    #include <cstdint>
    #define CXXOMFORT_USING_NATIVE_stdint
#else
    #if 0
        #error ("Unreachable.");
    
................................................................................
#endif // c++11

#if (!defined(CXXOMFORT_USING_NATIVE_stdint))
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("cstdint forwarded to portable-stdint")
    #endif
    //#define __STDC_LIMIT_MACROS
    #include "../vendor/pstdint.h"
    #define CXXOMFORT_USING_PSTDINT_stdint
    // use up the macro guard of stdint.h to prevent a collission
    #define _MSC_STDINT_H_ // win32
#endif // using pstdint

#include <climits>
#include <stddef.h>
#endif // header

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

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
57
58
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 * * @c CXXO_EXPLICIT_OPERATOR
 * 
 */

#include "../config.hpp"
#include "../base/move.hpp"
#include <iostream> // debug
//#include <cxxomfort/util/type_traits.hpp>
#define CXXOMFORT_IMPLEMENTS_n2333 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n2437 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_explicit_operator CXXOMFORT_IMPLEMENTS_n2333


#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
    #pragma message CXXO_NOTICE("enabled 'explicit operator' emulation")
#endif

namespace cxxomfort {
namespace detail {

template <typename T> 
struct addref_t {
    typedef T& type;
};

template <typename T> 
struct addref_t<T&> {
    typedef T& type;
};

template <typename A, typename B> struct detail_is_same { enum { value = false }; };
template <typename A> struct detail_is_same<A,A> { enum { value = true }; };


#if (CXXOMFORT_CXX_STD< 2011 && CXXO_COMPILER_SUPPORT_explicit_operator==0)
template <typename T>
struct explicit_cast {
    T value;
    
    //explicit_cast (T t) throw() 
    //: value (std::move(t)) {}

    explicit_cast (T const& t) throw ()
    : value(t) {}
    operator T const& () const throw () {
        return value;
    }
    
    private:
................................................................................
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; }







<












|
|
|
|

|
|
|
|

|
|






<
<
<
<







 







|







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
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 * * @c CXXO_EXPLICIT_OPERATOR
 * 
 */

#include "../config.hpp"
#include "../base/move.hpp"
#include <iostream> // debug

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


#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
    #pragma message CXXO_NOTICE("enabled 'explicit operator' emulation")
#endif

namespace cxxomfort {
namespace detail {

	template <typename T> 
	struct addref_t {
		typedef T& type;
	};

	template <typename T> 
	struct addref_t<T&> {
		typedef T& type;
	};

	template <typename A, typename B> struct detail_is_same { enum { value = false }; };
	template <typename A> struct detail_is_same<A,A> { enum { value = true }; };


#if (CXXOMFORT_CXX_STD< 2011 && CXXO_COMPILER_SUPPORT_explicit_operator==0)
template <typename T>
struct explicit_cast {
    T value;




    explicit_cast (T const& t) throw ()
    : value(t) {}
    operator T const& () const throw () {
        return value;
    }
    
    private:
................................................................................
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; }

Changes to cxxomfort/cxxomfort/base/move-03.hpp.

1
2
3
4
5
6
7
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
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
180
#ifndef CXXOMFORT_UTIL_MOVE_03_HPP
#define CXXOMFORT_UTIL_MOVE_03_HPP

// Move emulation, deboostified from Boost
// (Dunno what's the point, Boost.Move is pretty self-standing)

#include "../config.hpp"
//#include "../impl/11-conditional.hpp"
#include "../util/type_traits.hpp"
//#include "../util/meta.hpp"
#if (CXXOMFORT_CXX_STD >= 2011)
    #error "Library error - this file should only be invoked with c++03"
#endif


//Move emulation rv breaks standard aliasing rules so add workarounds for some compilers
#ifdef __GNUC__
................................................................................
  #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__))
#else
  #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS
#endif

namespace cxxomfort{

namespace move_detail {

template <typename T> struct identity { typedef T type; };





template <bool If, typename T>
struct enable_if;

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

................................................................................
    static false_t dispatch(...);
    static T& trigger();
    public:
    enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
};

template <typename U>
class is_convertible<void, U> {
    public:
    static const bool value= false;
};

struct empty {};

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

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

} // move_detail

template <class T>
class rv
: public move_detail::conditional
    < (traits::is_class<T>::value || traits::is_union<T>::value)
    , T
    , move_detail::empty
>::type {
    rv();
    ~rv();
    rv(rv const&);
    void operator=(rv const&);
} BOOST_MOVE_ATTRIBUTE_MAY_ALIAS;

template <class T>
struct is_rv
: traits::false_type
{};

template <class T>
struct is_rv< rv<T> >
: traits::true_type
{};

template <class T>
struct is_rv< const rv<T> >
: public traits::true_type
{};


template<class T>
struct has_move_emulation_enabled
  : move_detail::is_convertible< T, rv<T>& >
{};

template<class T>
struct has_move_emulation_enabled<T&>
  : traits::false_type
{};

template<class T>
struct has_move_emulation_enabled< rv<T> >
  : traits::false_type
{};

template <class T>
struct has_move_emulation_enabled_aux
 : has_move_emulation_enabled<T> {};

template <class T>
struct has_nothrow_move
  : traits::false_type
{};

template<class T> struct enable_move_utility_emulation {
    static const bool value = true;
};

//
//                            move()
//

template <typename T>
inline typename
move_detail::enable_if<!has_move_emulation_enabled_aux<T>::value, T&>::type 
move (T& x) {
	return x;
}

template <typename T>
inline typename
move_detail::enable_if<has_move_emulation_enabled<T>::value, rv<T>&>::type 
move (T& x) {
	return *static_cast<rv<T>* >(move_detail::addressof(x));
}

template <class T>
inline typename
move_detail::enable_if<has_move_emulation_enabled<T>::value, rv<T>&>::type 
move (rv<T>& x) {
	return x;
}

//
//                            forward()
//

template <typename T> inline 
typename move_detail::enable_if<
    enable_move_utility_emulation<T>::value && is_rv<T>::value, T &
>::type 
forward (const typename move_detail::identity<T>::type &x) CXXO_NOEXCEPTNOTHROW {
    return const_cast<T&>(x);
}

template <typename T> inline
typename move_detail::enable_if<
    enable_move_utility_emulation<T>::value && !is_rv<T>::value, T const&
>::type 
forward (const typename move_detail::identity<T>::type &x) CXXO_NOEXCEPTNOTHROW {
    return x;
}

#undef noexcept

} //::cxxomfort::








|
<
<







 







|


>
>
>
>







 







|
|
<
<







 







|



|
|

|









|




|




|





|




|




|








|


|
|
<







|






|

|




|









|


|




|


|







1
2
3
4
5
6
7
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
..
50
51
52
53
54
55
56
57
58


59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
#ifndef CXXOMFORT_UTIL_MOVE_03_HPP
#define CXXOMFORT_UTIL_MOVE_03_HPP

// Move emulation, deboostified from Boost
// (Dunno what's the point, Boost.Move is pretty self-standing)

#include "../config.hpp"
//#include "../impl/07-type_traits.hpp"


#if (CXXOMFORT_CXX_STD >= 2011)
    #error "Library error - this file should only be invoked with c++03"
#endif


//Move emulation rv breaks standard aliasing rules so add workarounds for some compilers
#ifdef __GNUC__
................................................................................
  #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__))
#else
  #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS
#endif

namespace cxxomfort{

namespace mvdetail {

template <typename T> struct identity { typedef T type; };

template <bool B> struct bool_constant { enum { value= B }; };
struct false_type : bool_constant<false> {};
struct true_type : bool_constant<true> {};

template <bool If, typename T>
struct enable_if;

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

................................................................................
    static false_t dispatch(...);
    static T& trigger();
    public:
    enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
};

template <typename U>
class is_convertible<void, U> 
: false_type {};



struct empty {};

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

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

} // mvdetail

template <class T>
class rv
: public mvdetail::conditional
    < (__is_class(T) || __is_union(T))
    , T
    , mvdetail::empty
>::type {
    rv();
    ~rv();
    rv(rv const&);
    void operator=(rv const&);
} BOOST_MOVE_ATTRIBUTE_MAY_ALIAS;

template <class T>
struct is_rv
: mvdetail::false_type
{};

template <class T>
struct is_rv< rv<T> >
: mvdetail::true_type
{};

template <class T>
struct is_rv< const rv<T> >
: public mvdetail::true_type
{};


template<class T>
struct has_move_emulation_enabled
  : mvdetail::is_convertible< T, rv<T>& >
{};

template<class T>
struct has_move_emulation_enabled<T&>
  : mvdetail::false_type
{};

template<class T>
struct has_move_emulation_enabled< rv<T> >
  : mvdetail::false_type
{};

template <class T>
struct has_move_emulation_enabled_aux
 : has_move_emulation_enabled<T> {};

template <class T>
struct has_nothrow_move
  : mvdetail::false_type
{};

template<class T> struct enable_move_utility_emulation 
: mvdetail::true_type {};


//
//                            move()
//

template <typename T>
inline typename
mvdetail::enable_if<!has_move_emulation_enabled_aux<T>::value, T&>::type 
move (T& x) {
	return x;
}

template <typename T>
inline typename
mvdetail::enable_if<has_move_emulation_enabled<T>::value, rv<T>&>::type 
move (T& x) {
	return *static_cast<rv<T>* >(mvdetail::addressof(x));
}

template <class T>
inline typename
mvdetail::enable_if<has_move_emulation_enabled<T>::value, rv<T>&>::type 
move (rv<T>& x) {
	return x;
}

//
//                            forward()
//

template <typename T> inline 
typename mvdetail::enable_if<
    enable_move_utility_emulation<T>::value && is_rv<T>::value, T &
>::type 
forward (const typename mvdetail::identity<T>::type &x) CXXO_NOEXCEPTNOTHROW {
    return const_cast<T&>(x);
}

template <typename T> inline
typename mvdetail::enable_if<
    enable_move_utility_emulation<T>::value && !is_rv<T>::value, T const&
>::type 
forward (const typename mvdetail::identity<T>::type &x) CXXO_NOEXCEPTNOTHROW {
    return x;
}

#undef noexcept

} //::cxxomfort::

Changes to cxxomfort/cxxomfort/base/nullptr.hpp.

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
..
69
70
71
72
73
74
75

76

77













78


















79
80
81
82
83
84
85
..
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
 * 
 * * nullptr_t (also in namespace std)
 * * nullptr (also in namespace std)
 */
#include "../config.hpp"


#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_nullptr==0)
    #define CXXOMFORT_USING_nullptr
#endif

#if (defined(CXXOMFORT_USING_nullptr) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_OW, < 1400))
    #include "../config/ow.hpp" // needs a simpler definition for nullptr
    #undef CXXOMFORT_USING_nullptr
#endif
#if (0 && !defined(CXXOMFORT_USING_nullptr) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_CLANG,>=300) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_CLANG,<302))
	#if (!defined(_LIBCPP))
		#define CXXOMFORT_USING_nullptr
	#endif
#endif

#if defined (CXXOMFORT_USING_nullptr)
    #if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
    #pragma message CXXO_NOTICE("enabled 'nullptr' backport.")
    #endif


/*
 * This is marked as a system header mostly because of 
 * bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48914
 * where it is not possible to omit "nullptr is reserved" warnings.
 */
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC \
    && CXXOMFORT_COMPILER_VERSION >= 406)
#pragma GCC system_header
#endif


namespace std {

// This is pretty much borrowed from the Standards recommendation verbatim.

/**
 * @class nullptr_t
................................................................................
    template<typename C, typename T> // or any type of null
    operator T C::*() const          // member pointer...
    { return 0; }
private:
    void operator&() const;          // whose address can't be taken
};


















} //~namespace std



















/**
 * @brief Null pointer literal (backport)
 * @ingroup cxx11-backports
 * @see http://stackoverflow.com/questions/8747005/backporting-nullptr-to-c-pre-c0x-programs
 * 
 * The null pointer literal @c nullptr allows for explicit comparison or 
................................................................................
int n = 0;    // valid
int q = nullptr; // invalid
int* ptrn = 0; // valid, but not recommended
int* ptrq = nullptr; // valid
if (ptrq != nullptr) { ... }
 * @endcode
 */
#if defined(CXXOFLAG_NO_INITIALIZERS)
const std::nullptr_t nullptr;
#else
const std::nullptr_t nullptr = {};
#endif



    #define CXXOMFORT_IMPLEMENTS_n1488 CXXO_IMPLSTATUS_BACKPORT()
#else
    #define CXXOMFORT_IMPLEMENTS_n1488 CXXO_IMPLSTATUS_NATIVE()

#endif // using emulation

#define CXXOMFORT_IMPLEMENTS_n1601 CXXOMFORT_IMPLEMENTS_n1488
#define CXXOMFORT_IMPLEMENTS_n2214 CXXOMFORT_IMPLEMENTS_n1601
#define CXXOMFORT_IMPLEMENTS_nullptr CXXOMFORT_IMPLEMENTS_n2214

#endif // file







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

<

|

<






|
|
|
|
>







 







>

>

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







 







<
<
<
<
<


<
<

<








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
..
62
63
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
101
102
103
104
105
106
107
108
109
110
111
...
116
117
118
119
120
121
122





123
124


125

126
127
128
129
130
131
132
133
 * 
 * * nullptr_t (also in namespace std)
 * * nullptr (also in namespace std)
 */
#include "../config.hpp"


#if (CXXOMFORT_CXX_STD >= 2011 || CXXO_COMPILER_SUPPORT_nullptr)
    #define CXXOMFORT_IMPLEMENTS_n1488 CXXO_IMPLSTATUS_NATIVE()


#elif (CXXOMFORT_CXX_STD >= 1997 && CXXO_COMPILER_SUPPORT_nullptr==0)

    #define CXXOMFORT_USING_nullptr



    #define CXXOMFORT_IMPLEMENTS_n1488 CXXO_IMPLSTATUS_BACKPORT()




    #if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
		#pragma message CXXO_NOTICE("enabled 'nullptr' backport.")
    #endif


/*
 * This is marked as a system header mostly because of 
 * bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48914
 * where it is not possible to omit "nullptr is reserved" warnings.
 */
	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC \
		&& CXXOMFORT_COMPILER_VERSION >= 406)
		#pragma GCC system_header
	#endif


namespace std {

// This is pretty much borrowed from the Standards recommendation verbatim.

/**
 * @class nullptr_t
................................................................................
    template<typename C, typename T> // or any type of null
    operator T C::*() const          // member pointer...
    { return 0; }
private:
    void operator&() const;          // whose address can't be taken
};

} //~namespace std

const std::nullptr_t nullptr = {};

#else
    #define CXXOMFORT_USING_nullptr
    #define CXXOMFORT_IMPLEMENTS_n1488 CXXO_IMPLSTATUS_EMULATION()

    #if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
		#pragma message CXXO_NOTICE("enabled 'nullptr' emulation.")
    #endif

	// some compilers don't have support for templates that would allow the 
	// templated conversion operator.
	// here, we use a simpler nullptr that converts at least 
	// to (void*)0-

namespace std {

class nullptr_t {
public:
	operator void* () const { return NULL; }

private:
    void operator&() const;          // whose address can't be taken
};

}

const std::nullptr_t nullptr;

#endif

#if defined (CXXOMFORT_USING_nullptr)



/**
 * @brief Null pointer literal (backport)
 * @ingroup cxx11-backports
 * @see http://stackoverflow.com/questions/8747005/backporting-nullptr-to-c-pre-c0x-programs
 * 
 * The null pointer literal @c nullptr allows for explicit comparison or 
................................................................................
int n = 0;    // valid
int q = nullptr; // invalid
int* ptrn = 0; // valid, but not recommended
int* ptrq = nullptr; // valid
if (ptrq != nullptr) { ... }
 * @endcode
 */









#else


#endif // using emulation

#define CXXOMFORT_IMPLEMENTS_n1601 CXXOMFORT_IMPLEMENTS_n1488
#define CXXOMFORT_IMPLEMENTS_n2214 CXXOMFORT_IMPLEMENTS_n1601
#define CXXOMFORT_IMPLEMENTS_nullptr CXXOMFORT_IMPLEMENTS_n2214

#endif // file

Changes to cxxomfort/cxxomfort/config.hpp.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
101
102
103
104
 * @ingroup cxxomfort-config
 *
 * This file contains configuration macros used by the cxxomfort library
 * and it is not intended to be directly used.
 */

//! Library version and release date as YYYYMMDD
#define CXXOMFORT_DATE 20200204UL
//! Defines the library version 
//! @warning to be deprecated
#define CXXOMFORT_VERSION CXXOMFORT_DATE

#include "config/_pre.hpp"
#include "config/_support.hpp"


/*
................................................................................


#define CXXO_INCLUDE_SYS(NAME) <NAME>


#define CXXO_COMPILERVERSION_COMPARE(com_,ver_) ((CXXOMFORT_COMPILER_ID == com_ && CXXOMFORT_COMPILER_VERSION ver_))

#define CXXO_NOTICE_IMPL_(msg) msg

//! Emits a notice at compilation time.
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_(  __FILE__ "(" CXXO_STRINGIZE1(__LINE__) ") : cxxomfort notice: " msg)
//! Emits a warning at compilation time.
#define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( __FILE__ "(" CXXO_STRINGIZE1(__LINE__) ") : cxxomfort warning: " msg)


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

/*
 * Detect compilers and apply specific configurations.
 */
#if 0
#elif defined(__clang__)
    #include "./config/clang.hpp"
#elif defined(__GNUC__)
    #include "./config/gcc.hpp"
#elif defined(__DJGPP__)
	#include "./config/djgpp.hpp"
#elif defined(_MSC_VER)
    #include "./config/msc.hpp"
#elif defined(__DMC__)
    #include "./config/dmc.hpp"
#elif defined(__WATCOMC__)
    #include "./config/ow.hpp"
#else







|

|







 







|







 







|
|
|
|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
101
102
103
104
 * @ingroup cxxomfort-config
 *
 * This file contains configuration macros used by the cxxomfort library
 * and it is not intended to be directly used.
 */

//! Library version and release date as YYYYMMDD
#define CXXOMFORT_DATE 20200227UL
//! Defines the library version 
//! @deprecated 
#define CXXOMFORT_VERSION CXXOMFORT_DATE

#include "config/_pre.hpp"
#include "config/_support.hpp"


/*
................................................................................


#define CXXO_INCLUDE_SYS(NAME) <NAME>


#define CXXO_COMPILERVERSION_COMPARE(com_,ver_) ((CXXOMFORT_COMPILER_ID == com_ && CXXOMFORT_COMPILER_VERSION ver_))

#define CXXO_NOTICE_IMPL_(msg) (msg)

//! Emits a notice at compilation time.
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_(  __FILE__ "(" CXXO_STRINGIZE1(__LINE__) ") : cxxomfort notice: " msg)
//! Emits a warning at compilation time.
#define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( __FILE__ "(" CXXO_STRINGIZE1(__LINE__) ") : cxxomfort warning: " msg)


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

/*
 * Detect compilers and apply specific configurations.
 */
#if 0
#elif defined(__clang__)
    #include "./config/clang.hpp"
#elif defined(__DJGPP__)
	#include "./config/djgpp.hpp"
#elif defined(__GNUC__)
    #include "./config/gcc.hpp"
#elif defined(_MSC_VER)
    #include "./config/msc.hpp"
#elif defined(__DMC__)
    #include "./config/dmc.hpp"
#elif defined(__WATCOMC__)
    #include "./config/ow.hpp"
#else

Changes to cxxomfort/cxxomfort/config/_support.hpp.

29
30
31
32
33
34
35

36
37
38
39
40
41
42
...
187
188
189
190
191
192
193





194
195
196
197
198
199
200
// 

#define CXXO_COMPILERID_GCC 101
#define CXXO_COMPILERID_MSC 102
#define CXXO_COMPILERID_CLANG 103
#define CXXO_COMPILERID_DMC 104
#define CXXO_COMPILERID_OW 105



// 
// per-standard version features
// 

// c++03 or other pre-C++11 stuff
................................................................................


// c++20 stuff

//! If compiler provides support for endianness tag (std::endian)
#define CXXO_CXXSTDHEADER_endian (CXXOMFORT_CXX_STD>=2020)








//------------------------------------------------
/*
 * List of C++ features for documentation
 * 
 * Good source: https://wg21.link/index.txt







>







 







>
>
>
>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// 

#define CXXO_COMPILERID_GCC 101
#define CXXO_COMPILERID_MSC 102
#define CXXO_COMPILERID_CLANG 103
#define CXXO_COMPILERID_DMC 104
#define CXXO_COMPILERID_OW 105
#define CXXO_COMPILERID_DJGPP 106


// 
// per-standard version features
// 

// c++03 or other pre-C++11 stuff
................................................................................


// c++20 stuff

//! If compiler provides support for endianness tag (std::endian)
#define CXXO_CXXSTDHEADER_endian (CXXOMFORT_CXX_STD>=2020)


// undefine or move to another file once implemented
#define CXXOMFORT_IMPLEMENTS_attribute 0
#define CXXOMFORT_IMPLEMENTS_stdhash_enum 0
//#define CXXOMFORT_IMPLEMENTS_timespec_get 0


//------------------------------------------------
/*
 * List of C++ features for documentation
 * 
 * Good source: https://wg21.link/index.txt

Changes to cxxomfort/cxxomfort/config/clang.hpp.

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
69
70
71
72
73
74
75
76








77
78
79
80
81
82
83
...
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
    #pragma message CXXO_NOTICE("Found the Clang C++ Compiler.")
#endif

#if defined(_LIBCPP)
	#pragma message CXXO_NOTICE("with libcxx")
#endif

#undef  CXXOFLAG_tr1
#define CXXOFLAG_tr1 0

//
// compatibility detail for older clang as shown in 
// http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
//
#ifndef __has_extension
	#define __has_extension __has_feature
#endif
................................................................................
#define CXXO_COMPILER_SUPPORT_typeof 1
#undef  CXXO_COMPILER_SUPPORT_va_args
#define CXXO_COMPILER_SUPPORT_va_args 1

// c++03

#if (CXXOMFORT_CXX_STD >= 1997 && CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_COMPILER_VERSION >= 300)









#endif

#undef  CXXO_COMPILER_SUPPORT_tr1_array
#define CXXO_COMPILER_SUPPORT_tr1_array (CXXOMFORT_CXX_STD < 2011)
#undef  CXXO_COMPILER_SUPPORT_tr1_tuple
#define CXXO_COMPILER_SUPPORT_tr1_tuple (CXXOMFORT_CXX_STD < 2011)
#undef  CXXO_COMPILER_SUPPORT_tr1_type_traits
................................................................................
#undef  CXXO_COMPILER_SUPPORT_attribute
#define CXXO_COMPILER_SUPPORT_attribute __has_feature(cxx_attributes)
#undef  CXXO_COMPILER_SUPPORT_auto
#define CXXO_COMPILER_SUPPORT_auto __has_feature(cxx_auto_type)
#undef  CXXO_COMPILER_SUPPORT_constexpr
#define CXXO_COMPILER_SUPPORT_constexpr __has_feature(cxx_constexpr)
#undef  CXXO_COMPILER_SUPPORT_decltype
#define CXXO_COMPILER_SUPPORT_decltype __has_extension(cxx_decltype_incomplete_return_types)
#undef  CXXO_COMPILER_SUPPORT_default_delete
#define CXXO_COMPILER_SUPPORT_default_delete (__has_extension(cxx_defaulted_functions) * __has_extension(cxx_deleted_functions))
#undef  CXXO_COMPILER_SUPPORT_enum_class
#define CXXO_COMPILER_SUPPORT_enum_class __has_feature(cxx_strong_enums)
#undef  CXXO_COMPILER_SUPPORT_explicit_operator
#define CXXO_COMPILER_SUPPORT_explicit_operator __has_feature(cxx_explicit_conversions)
#undef  CXXO_COMPILER_SUPPORT_foreach
#define CXXO_COMPILER_SUPPORT_foreach __has_extension(cxx_range_for)
#undef  CXXO_COMPILER_SUPPORT_initializer_list
#define CXXO_COMPILER_SUPPORT_initializer_list __has_extension(cxx_inheriting_constructors)
#undef  CXXO_COMPILER_SUPPORT_local_types
#define CXXO_COMPILER_SUPPORT_local_types __has_extension(cxx_local_type_template_args)
#undef  CXXO_COMPILER_SUPPORT_noexcept
#define CXXO_COMPILER_SUPPORT_noexcept __has_extension(cxx_noexcept)
#undef  CXXO_COMPILER_SUPPORT_nsdmi
#define CXXO_COMPILER_SUPPORT_nsdmi __has_extension(cxx_nonstatic_member_init)
#undef  CXXO_COMPILER_SUPPORT_nullptr
#define CXXO_COMPILER_SUPPORT_nullptr __has_extension(cxx_nullptr)
#undef  CXXO_COMPILER_SUPPORT_rvref
#define CXXO_COMPILER_SUPPORT_rvref (__has_extension(cxx_rvalue_references) * __has_extension(cxx_implicit_moves))
#undef  CXXO_COMPILER_SUPPORT_std_is_trivially
#define CXXO_COMPILER_SUPPORT_std_is_trivially (CXXOMFORT_CXX_STD >= 2011)
#undef  CXXO_COMPILER_SUPPORT_static_assert
#define CXXO_COMPILER_SUPPORT_static_assert __has_extension(cxx_static_assert)
#undef  CXXO_COMPILER_SUPPORT_trailing_returns
#define CXXO_COMPILER_SUPPORT_trailing_returns __has_extension(cxx_trailing_return)
#undef  CXXO_COMPILER_SUPPORT_unique_ptr
#define CXXO_COMPILER_SUPPORT_unique_ptr (CXXOMFORT_CXX_STD >= 2011)
#undef  CXXO_COMPILER_SUPPORT_variadic
#define CXXO_COMPILER_SUPPORT_variadic (__has_extension(cxx_variadic_templates))
#undef  CXXO_COMPILER_SUPPORT_va_args
#define CXXO_COMPILER_SUPPORT_va_args 1

// c++14

#undef  CXXO_COMPILER_SUPPORT_decltypeauto
#define CXXO_COMPILER_SUPPORT_decltypeauto __has_extension(cxx_decltype_auto)
#undef  CXXO_COMPILER_SUPPORT_constexpr_relaxed
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed __has_extension(cxx_relaxed_constexpr)



// -- TODO -- get my claws on clang >= 3.2
// -- NEW TODO -- get my claws on clang >= 5.0 (2019-01)

#if (CXXOMFORT_COMPILER_VERSION > 300 && CXXOMFORT_COMPILER_VERSION < 400)







<
<
<







 







<
>
>
>
>
>
>
>
>







 







|







|

|





|













|








|







45
46
47
48
49
50
51



52
53
54
55
56
57
58
..
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
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
    #pragma message CXXO_NOTICE("Found the Clang C++ Compiler.")
#endif

#if defined(_LIBCPP)
	#pragma message CXXO_NOTICE("with libcxx")
#endif




//
// compatibility detail for older clang as shown in 
// http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
//
#ifndef __has_extension
	#define __has_extension __has_feature
#endif
................................................................................
#define CXXO_COMPILER_SUPPORT_typeof 1
#undef  CXXO_COMPILER_SUPPORT_va_args
#define CXXO_COMPILER_SUPPORT_va_args 1

// c++03

#if (CXXOMFORT_CXX_STD >= 1997 && CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_COMPILER_VERSION >= 300)

	// here it should use the same paths as GCC in theory?
	// (pending check against libcpp mode however)
	#undef  CXXOFLAG_tr1
	#define CXXOFLAG_tr1 1
	#undef  CXXOFLAG_directory_tr1
	#define CXXOFLAG_directory_tr1 1
	#undef  CXXOFLAG_namespace_tr1
	#define CXXOFLAG_namespace_tr1 1
#endif

#undef  CXXO_COMPILER_SUPPORT_tr1_array
#define CXXO_COMPILER_SUPPORT_tr1_array (CXXOMFORT_CXX_STD < 2011)
#undef  CXXO_COMPILER_SUPPORT_tr1_tuple
#define CXXO_COMPILER_SUPPORT_tr1_tuple (CXXOMFORT_CXX_STD < 2011)
#undef  CXXO_COMPILER_SUPPORT_tr1_type_traits
................................................................................
#undef  CXXO_COMPILER_SUPPORT_attribute
#define CXXO_COMPILER_SUPPORT_attribute __has_feature(cxx_attributes)
#undef  CXXO_COMPILER_SUPPORT_auto
#define CXXO_COMPILER_SUPPORT_auto __has_feature(cxx_auto_type)
#undef  CXXO_COMPILER_SUPPORT_constexpr
#define CXXO_COMPILER_SUPPORT_constexpr __has_feature(cxx_constexpr)
#undef  CXXO_COMPILER_SUPPORT_decltype
#define CXXO_COMPILER_SUPPORT_decltype __has_feature(cxx_decltype_incomplete_return_types)
#undef  CXXO_COMPILER_SUPPORT_default_delete
#define CXXO_COMPILER_SUPPORT_default_delete (__has_extension(cxx_defaulted_functions) * __has_extension(cxx_deleted_functions))
#undef  CXXO_COMPILER_SUPPORT_enum_class
#define CXXO_COMPILER_SUPPORT_enum_class __has_feature(cxx_strong_enums)
#undef  CXXO_COMPILER_SUPPORT_explicit_operator
#define CXXO_COMPILER_SUPPORT_explicit_operator __has_feature(cxx_explicit_conversions)
#undef  CXXO_COMPILER_SUPPORT_foreach
#define CXXO_COMPILER_SUPPORT_foreach __has_feature(cxx_range_for)
#undef  CXXO_COMPILER_SUPPORT_initializer_list
#define CXXO_COMPILER_SUPPORT_initializer_list __has_feature(cxx_inheriting_constructors)
#undef  CXXO_COMPILER_SUPPORT_local_types
#define CXXO_COMPILER_SUPPORT_local_types __has_extension(cxx_local_type_template_args)
#undef  CXXO_COMPILER_SUPPORT_noexcept
#define CXXO_COMPILER_SUPPORT_noexcept __has_extension(cxx_noexcept)
#undef  CXXO_COMPILER_SUPPORT_nsdmi
#define CXXO_COMPILER_SUPPORT_nsdmi __has_feature(cxx_nonstatic_member_init)
#undef  CXXO_COMPILER_SUPPORT_nullptr
#define CXXO_COMPILER_SUPPORT_nullptr __has_extension(cxx_nullptr)
#undef  CXXO_COMPILER_SUPPORT_rvref
#define CXXO_COMPILER_SUPPORT_rvref (__has_extension(cxx_rvalue_references) * __has_extension(cxx_implicit_moves))
#undef  CXXO_COMPILER_SUPPORT_std_is_trivially
#define CXXO_COMPILER_SUPPORT_std_is_trivially (CXXOMFORT_CXX_STD >= 2011)
#undef  CXXO_COMPILER_SUPPORT_static_assert
#define CXXO_COMPILER_SUPPORT_static_assert __has_extension(cxx_static_assert)
#undef  CXXO_COMPILER_SUPPORT_trailing_returns
#define CXXO_COMPILER_SUPPORT_trailing_returns __has_extension(cxx_trailing_return)
#undef  CXXO_COMPILER_SUPPORT_unique_ptr
#define CXXO_COMPILER_SUPPORT_unique_ptr (CXXOMFORT_CXX_STD >= 2011)
#undef  CXXO_COMPILER_SUPPORT_variadic
#define CXXO_COMPILER_SUPPORT_variadic (__has_feature(cxx_variadic_templates))
#undef  CXXO_COMPILER_SUPPORT_va_args
#define CXXO_COMPILER_SUPPORT_va_args 1

// c++14

#undef  CXXO_COMPILER_SUPPORT_decltypeauto
#define CXXO_COMPILER_SUPPORT_decltypeauto __has_extension(cxx_decltype_auto)
#undef  CXXO_COMPILER_SUPPORT_constexpr_relaxed
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed __has_feature(cxx_relaxed_constexpr)



// -- TODO -- get my claws on clang >= 3.2
// -- NEW TODO -- get my claws on clang >= 5.0 (2019-01)

#if (CXXOMFORT_COMPILER_VERSION > 300 && CXXOMFORT_COMPILER_VERSION < 400)

Added cxxomfort/cxxomfort/config/djgpp.hpp.

















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef CXXOMFORT_CONFIG_HPP
    #error "This file must not be included directly (see cxxomfort/config.hpp)"
#endif
#ifndef CXXOMFORT_CONFIG_DJ_HPP
#define CXXOMFORT_CONFIG_DJ_HPP

/*
 * DJGPP version history:
 * -- https://www.gnu.org/software/gcc/releases.html
 * 
 * 
 *
 */

//
// setup identification information and pragmas
//

#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_DJGPP
#define CXXOMFORT_COMPILER_VERSION (__DJGPP__*100UL+__DJGPP_MINOR__)
#define CXXOMFORT_COMPILER_VERSION_FULL (__DJGPP__*100UL+__DJGPP_MINOR__)


#endif

Changes to cxxomfort/cxxomfort/config/gcc.hpp.

56
57
58
59
60
61
62



63
64
65
66
67
68
69
#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_GCC
#define CXXOMFORT_COMPILER_VERSION (__GNUC__*100UL+__GNUC_MINOR__)
#define CXXOMFORT_COMPILER_VERSION_FULL (__GNUC__*100000UL+__GNUC_MINOR__*1000UL+__GNUC_PATCHLEVEL__)

//#define CXXO_PRAGMA(x) _Pragma (#x)
//#define CXXO_NOTICE(msg) CXXO_PRAGMA( message (" cxxomfort warning -- " msg ) )




#if (CXXOMFORT_COMPILER_VERSION >= 408)
//    #define CXXO_NOTICE(msg) "cxxomfort: " msg
//    #define CXXO_WARNING(msg) "cxxomfort warning: " msg
#else
    #undef  CXXO_NOTICE_IMPL_ 
    #define CXXO_NOTICE_IMPL_(msg) msg
    #undef  CXXO_NOTICE







>
>
>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_GCC
#define CXXOMFORT_COMPILER_VERSION (__GNUC__*100UL+__GNUC_MINOR__)
#define CXXOMFORT_COMPILER_VERSION_FULL (__GNUC__*100000UL+__GNUC_MINOR__*1000UL+__GNUC_PATCHLEVEL__)

//#define CXXO_PRAGMA(x) _Pragma (#x)
//#define CXXO_NOTICE(msg) CXXO_PRAGMA( message (" cxxomfort warning -- " msg ) )

#undef  CXXO_COMPILER_SUPPORT_type_intrinsics
#define CXXO_COMPILER_SUPPORT_type_intrinsics 1

#if (CXXOMFORT_COMPILER_VERSION >= 408)
//    #define CXXO_NOTICE(msg) "cxxomfort: " msg
//    #define CXXO_WARNING(msg) "cxxomfort warning: " msg
#else
    #undef  CXXO_NOTICE_IMPL_ 
    #define CXXO_NOTICE_IMPL_(msg) msg
    #undef  CXXO_NOTICE

Changes to cxxomfort/cxxomfort/config/msc.hpp.

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	#undef  CXXOFLAG_tr1
	#define CXXOFLAG_tr1 0
    #undef  CXXO_COMPILER_SUPPORT_type_intrinsics
    #define CXXO_COMPILER_SUPPORT_type_intrinsics 1
#endif

#if (CXXOMFORT_COMPILER_VERSION >= 1500) // VC 2008 or higher
    #if (_MSC_FULL_VER == 150030729) // SP1
		#undef  CXXOMFORT_CXX_EMULATION
		#define CXXOMFORT_CXX_EMULATION 2007

		#undef  CXXO_CXXSTDHEADER_array
		#define CXXO_CXXSTDHEADER_array 1
		#undef  CXXO_CXXSTDHEADER_random
		#define CXXO_CXXSTDHEADER_random 1







|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	#undef  CXXOFLAG_tr1
	#define CXXOFLAG_tr1 0
    #undef  CXXO_COMPILER_SUPPORT_type_intrinsics
    #define CXXO_COMPILER_SUPPORT_type_intrinsics 1
#endif

#if (CXXOMFORT_COMPILER_VERSION >= 1500) // VC 2008 or higher
    #if (_MSC_FULL_VER == 150030729) // SP1 has TR1
		#undef  CXXOMFORT_CXX_EMULATION
		#define CXXOMFORT_CXX_EMULATION 2007

		#undef  CXXO_CXXSTDHEADER_array
		#define CXXO_CXXSTDHEADER_array 1
		#undef  CXXO_CXXSTDHEADER_random
		#define CXXO_CXXSTDHEADER_random 1

Changes to cxxomfort/cxxomfort/config/ow.hpp.

61
62
63
64
65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
#endif

// wait for OWC++ implementors to lower this bound
// for when we don't need fixes
#if (__WATCOMC__ < 9999) 

// nullptr requires special processing
    #define nullptr (0)
namespace std {
    struct nullptr_t {
        nullptr_t (unsigned) {}
        operator unsigned () const { return nullptr; }
    };
}


// static_assert seems to work OK?

// move uses move-00

// integer types are available in native cstdint








|
|
|
|
|
|
<
>







61
62
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
#endif

// wait for OWC++ implementors to lower this bound
// for when we don't need fixes
#if (__WATCOMC__ < 9999) 

// nullptr requires special processing
//    #define nullptr (0)
//namespace std {
//    struct nullptr_t {
//        nullptr_t (unsigned) {}
//        operator unsigned () const { return nullptr; }
//    };

//}

// static_assert seems to work OK?

// move uses move-00

// integer types are available in native cstdint

Changes to cxxomfort/cxxomfort/cstdint.hpp.

1
2
3
4
5
6

7
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
#ifndef CXXOMFORT_CSTDINT_HPP
#define CXXOMFORT_CSTDINT_HPP
/**
 * @file
 *
 */


#include <cxxomfort/base.hpp>
#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
#pragma message CXXO_NOTICE("enabled <cstdint> support.")
#endif
#if (CXXOMFORT_CXX_STD>=2011)
#include <cstdint>
#else
#include <cxxomfort/base/cstdint.hpp>
#endif




























/**
 * @page std0cstdint <cstdint>
 * @brief Features related to Standard header <code>\<cstdint\></code>.
 * 
 * The features declared here include mostly the special type names 
 * for the supported integer ("integral") types:
 * 
 * * Candidate size integer typedefs <code>[u]int_least<em>n</em>_t</code> such as @c int_least32_t .
 * * Exact size integer typedefs <code>[u]int<em>n</em>_t</code> such as @c int32_t .
 * * Fast arithmetic integer typedefs <code>uint_fast<em>n</em>_t</code> such as @c int_fast32_t .
 * * Maximum-size integer typedef @c intmax_t , @c uintmax_t .
 * * Pointer-sized integer typedefs @c intptr_t , @c uintptr_t .
 * 




 * For platforms without access to a Standard <code><stdint.h></code>, 
 * cxxomfort makes this possible by providing a copy of 
 * <em>pstdint.h the Portable stdint</em>.
 * 
 * @warning For the definition of these types, cxxomfort assumes that 
 * the native type <code>long long</code> is available, 
 * even in C++03 mode. Using a platform without such a native 






>











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













>
>
>
>







1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CXXOMFORT_CSTDINT_HPP
#define CXXOMFORT_CSTDINT_HPP
/**
 * @file
 *
 */


#include <cxxomfort/base.hpp>
#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
#pragma message CXXO_NOTICE("enabled <cstdint> support.")
#endif
#if (CXXOMFORT_CXX_STD>=2011)
#include <cstdint>
#else
#include <cxxomfort/base/cstdint.hpp>
#endif


// 
// tinyint
// (uint8_t as an actual, functional numeric type)
// 

namespace cxxomfort { namespace fix {

struct tinyint {
	public:
	CXXO_CONSTEXPR 
	explicit tinyint (uint8_t c= 0) CXXO_NOEXCEPTNOTHROW 
	: u(c) {}
	tinyint& operator= (uint8_t x) CXXO_NOEXCEPTNOTHROW {
		u= x; 
		return *this;
	}
	operator unsigned int () const { return u; }
	private:
	uint8_t u;
};
static_assert (sizeof(tinyint)==1, "tinyint check size");
static_assert (alignof(tinyint)==1, "tinyint check align");


} }  // cxxomfort::fix

/**
 * @page std0cstdint <cstdint>
 * @brief Features related to Standard header <code>\<cstdint\></code>.
 * 
 * The features declared here include mostly the special type names 
 * for the supported integer ("integral") types:
 * 
 * * Candidate size integer typedefs <code>[u]int_least<em>n</em>_t</code> such as @c int_least32_t .
 * * Exact size integer typedefs <code>[u]int<em>n</em>_t</code> such as @c int32_t .
 * * Fast arithmetic integer typedefs <code>uint_fast<em>n</em>_t</code> such as @c int_fast32_t .
 * * Maximum-size integer typedef @c intmax_t , @c uintmax_t .
 * * Pointer-sized integer typedefs @c intptr_t , @c uintptr_t .
 * 
 * The following non-backport interfaces are defined:
 * 
 * * @c cxxomfort::fix::uint8_t - a true numeric integral type with the semantics of @c u8int_t .
 * 
 * For platforms without access to a Standard <code><stdint.h></code>, 
 * cxxomfort makes this possible by providing a copy of 
 * <em>pstdint.h the Portable stdint</em>.
 * 
 * @warning For the definition of these types, cxxomfort assumes that 
 * the native type <code>long long</code> is available, 
 * even in C++03 mode. Using a platform without such a native 

Changes to cxxomfort/cxxomfort/ctime.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
46
47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
..
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
 */

#include "config.hpp"
#include "base.hpp"
#include CXXO_INCLUDE_SYS(ctime)

// 
// these elements are - in theory - only needed pre-C++17
// 

#if (CXXOMFORT_CXX_STD >= 2017)


#elif (CXXOMFORT_CXX_STD >= 1997)

	#include <time.h>
	// we look for CLOCK_REALTIME to use http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
	#if defined(__unix__)
		#include <unistd.h>
		#include <time.h>
	#elif defined(_WIN32)











		#include <winsock2.h>
		#include <MAPIWin.h>

	#else

	#endif
	

	#if !defined(TIME_UTC)
		#define TIME_UTC 0
	#endif

	
/*
 * if in POSIX, we can just use their functions
 * when on Windows, we sandwich
 * */
	#if defined(_POSIX_VERSION)


namespace cxxomfort { namespace cxxostd {
	using ::timespec;
	using ::timespec_get;
} }

	#elif defined(_WIN32)

namespace cxxomfort { namespace cxxostd {

	struct timespec {
		std::time_t tv_sec;
		long tv_nsec;
	};

	inline 
	int timespec_get ( struct timespec* ts, int base ) {
		(void)base;
		ts->tv_sec = time(0);
		SYSTEMTIME st;
		GetSystemTime(&st);
		ts->tv_nsec= st.wMilliseconds ; //static_cast<long>(st.wMilliseconds)*1000UL;
		return 0;
	}

} } // cxxomfort::cxxostd

	#else


namespace cxxomfort { namespace cxxostd {

	struct timespec {
		std::time_t tv_sec;
		long tv_nsec;
	};
................................................................................


namespace std {
	using ::cxxomfort::cxxostd::timespec;
	using ::cxxomfort::cxxostd::timespec_get;
}




#endif // cxx_std

#endif

























/**
 * @page std0ctime <ctime>
 * @brief Backports related to Standard header <tt><ctime></tt>
 * 
 * @code
 * #include <cxxomfort/ctime.hpp>
................................................................................
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined in this section:
 * 
 * * @c timespec_get() - obtain current time information for a system clock.
 * * @c timespec - information datatype for @c timespec_get .

 * 
 * Non-backport interfaces:
 * 
 * * (none)
 * 
 * @section also See Also
 * 
 * @see @cppref{header/ctime} (cppreference) 
 * 
 * */








|



>

|







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

>













>







>













|






>







 







>
>




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







 







>











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
57
58
59
60
61
62
63
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
...
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
 */

#include "config.hpp"
#include "base.hpp"
#include CXXO_INCLUDE_SYS(ctime)

// 
// timespec_get
// 

#if (CXXOMFORT_CXX_STD >= 2017)
	#define CXXOMFORT_IMPLEMENTS_timespec_get CXXO_IMPLSTATUS_NATIVE()

#elif (CXXOMFORT_CXX_STD >= 0)

	#include <time.h>
	// we look for CLOCK_REALTIME to use http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
	#if defined(__unix__)
		#include <unistd.h>
		#include <time.h>
	#elif defined(_WIN32)
		#if 1
			#include <windows.h>
		#else
			#include <basetsd.h>
			#include <excpt.h>
			#include <stdarg.h>
			#include <windef.h>
			#include <winbase.h>
			#include <wingdi.h>
			#include <winsock.h>
			#include <winuser.h>
			#include <winsock2.h>
			#include <MAPIWin.h>
		#endif
	#else
	
	#endif
	

	#if !defined(TIME_UTC)
		#define TIME_UTC 0
	#endif

	
/*
 * if in POSIX, we can just use their functions
 * when on Windows, we sandwich
 * */
	#if defined(_POSIX_VERSION)
		#define CXXOMFORT_IMPLEMENTS_timespec_get CXXO_IMPLSTATUS_BACKPORT()

namespace cxxomfort { namespace cxxostd {
	using ::timespec;
	using ::timespec_get;
} }

	#elif defined(_WIN32)
		#define CXXOMFORT_IMPLEMENTS_timespec_get CXXO_IMPLSTATUS_EMULATION()
namespace cxxomfort { namespace cxxostd {

	struct timespec {
		std::time_t tv_sec;
		long tv_nsec;
	};

	inline 
	int timespec_get ( struct timespec* ts, int base ) {
		(void)base;
		ts->tv_sec = time(0);
		SYSTEMTIME st;
		GetSystemTime(&st);
		ts->tv_nsec= st.wMilliseconds * 1000UL * 1000UL; //static_cast<long>(st.wMilliseconds)*1000UL;
		return 0;
	}

} } // cxxomfort::cxxostd

	#else
		#define CXXOMFORT_IMPLEMENTS_timespec_get CXXO_IMPLSTATUS_EMULATION()

namespace cxxomfort { namespace cxxostd {

	struct timespec {
		std::time_t tv_sec;
		long tv_nsec;
	};
................................................................................


namespace std {
	using ::cxxomfort::cxxostd::timespec;
	using ::cxxomfort::cxxostd::timespec_get;
}

#else 


#endif // cxx_std

#endif

#ifdef DOXYGEN_DOC
namespace cxxomfort { namespace cxxostd {

/**
 * @ingroup cxx17-backports
 * @{
 * */

	//! Struct that serves as the output of @c timespec_get() .
	struct timespec {
		std::time_t tv_sec;
		long tv_nsec;
	};

	//! Obtains time information from the system and stores it in a @c timespec object.
	int timespec_get ( struct timespec* ts, int base ) { return 0; }

/**
 * @}
 * */

}}
#endif

/**
 * @page std0ctime <ctime>
 * @brief Backports related to Standard header <tt><ctime></tt>
 * 
 * @code
 * #include <cxxomfort/ctime.hpp>
................................................................................
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined in this section:
 * 
 * * @c timespec_get() - obtain current time information for a system clock.
 * * @c timespec - information datatype for @c timespec_get .
 * * @c CXXOMFORT_IMPLEMENTS_timespec_get - implementation status for the above.
 * 
 * Non-backport interfaces:
 * 
 * * (none)
 * 
 * @section also See Also
 * 
 * @see @cppref{header/ctime} (cppreference) 
 * 
 * */

Changes to cxxomfort/cxxomfort/cuchar.hpp.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

39


40
#endif // support
#endif // STD

#endif

/**
 * @page std0cuchar <cuchar>
 * @brief Features related to Standard header <code>\<cuchar\></code>.
 * 
 * This section defines the @c char16_t and @c char32_t types in C++03 mode, 
 * besides the flag @c CXXO_charn_t_typedefs that tells whether the names are 
 * made available as typedefs or as their own separate types, depending on the compiler.
 * 
 * The types are made available for storage only; without intervening in the lexer 
 * (and thus in the compiler somehwow), it is not really possible to write 
 * extended char typed chaarcters in the source code, let alone literal strings of them.
 * 

 * 


 * */







|









>

>
>

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#endif // support
#endif // STD

#endif

/**
 * @page std0cuchar <cuchar>
 * @brief Features related to Standard header <tt><cuchar></tt>.
 * 
 * This section defines the @c char16_t and @c char32_t types in C++03 mode, 
 * besides the flag @c CXXO_charn_t_typedefs that tells whether the names are 
 * made available as typedefs or as their own separate types, depending on the compiler.
 * 
 * The types are made available for storage only; without intervening in the lexer 
 * (and thus in the compiler somehwow), it is not really possible to write 
 * extended char typed chaarcters in the source code, let alone literal strings of them.
 * 
 * Interfaces defined:
 * 
 * * @c char16_t , @c char32_t (C++11) in C++03 if they would be typedef.
 * 
 * */

Changes to cxxomfort/cxxomfort/cxxomfort.hpp.

36
37
38
39
40
41
42

43
44
45
46
47
48
49
 *  </tr><tr><td align="center">
 * @subpage std0cstddef "<cstddef>" - @subpage std0cstdint "<cstdint>" - <cstdio> - @subpage std0ctime "<ctime>" - @subpage std0cuchar "<cuchar>" 
 <br/> @subpage std0algorithm "<algorithm>" - @subpage std0functional "<functional>" -  @subpage std0iterator "<iterator>" - @subpage std0numeric "<numeric>" - @subpage std0string "<string>" - @subpage std0string_view "<string_view>" 
 <br/> @subpage std0ios "<ios>" - @subpage std0limits "<limits>" - @subpage std0memory "<memory>" - @subpage std0tuple "<tuple>" - @subpage std0utility "<utility>" 
 <br/> @subpage std0type_traits "<type_traits>" - @subpage std0typeindex "<typeindex>" 
 <br/> @subpage std0array "<array>" - @subpage std0forward_list "<forward_list>" 
 <br/> @subpage std0random "<random>" - @subpage std0system_error "<system_error>"

 * <br/>  @subpage transparent-headers "Transparent Headers" -- @subpage cxxomfort-fix "Fixes to implementation issues"
 * </td>
 *  </tr>
 * </tr><tr>
 *  <th rowspan="2">Supplements</th>
 * <td align="center">
 *  @subpage cxxo-sup "Library Supplements" -- @cxxowiki{Supplements,repo}</a> 







>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 *  </tr><tr><td align="center">
 * @subpage std0cstddef "<cstddef>" - @subpage std0cstdint "<cstdint>" - <cstdio> - @subpage std0ctime "<ctime>" - @subpage std0cuchar "<cuchar>" 
 <br/> @subpage std0algorithm "<algorithm>" - @subpage std0functional "<functional>" -  @subpage std0iterator "<iterator>" - @subpage std0numeric "<numeric>" - @subpage std0string "<string>" - @subpage std0string_view "<string_view>" 
 <br/> @subpage std0ios "<ios>" - @subpage std0limits "<limits>" - @subpage std0memory "<memory>" - @subpage std0tuple "<tuple>" - @subpage std0utility "<utility>" 
 <br/> @subpage std0type_traits "<type_traits>" - @subpage std0typeindex "<typeindex>" 
 <br/> @subpage std0array "<array>" - @subpage std0forward_list "<forward_list>" 
 <br/> @subpage std0random "<random>" - @subpage std0system_error "<system_error>"
 <br/> @subpage std0ostream "<ostream>" 
 * <br/>  @subpage transparent-headers "Transparent Headers" -- @subpage cxxomfort-fix "Fixes to implementation issues"
 * </td>
 *  </tr>
 * </tr><tr>
 *  <th rowspan="2">Supplements</th>
 * <td align="center">
 *  @subpage cxxo-sup "Library Supplements" -- @cxxowiki{Supplements,repo}</a> 

Changes to cxxomfort/cxxomfort/docgen/isr.hpp.

1
2
3
4
5
6
7
8

9
10


11
12
13
14
15
16
17
..
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
57
58
59
60
61
62
63
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
/**
 * @page cxx03-backports C++03 Backports
 * @brief Backports from C++03.
 * 
 * A listing of some of the features backported:
 * 
 * * From <tt><array></tt>: @ref array , etc.
 * * From <tt><functional></tt>: @ref bind1st , @ref reference_wrapper , etc.

 * 
*


 */

/**
 * @page cxx11-backports C++11 Backports
 * @brief Backports from C++11.
 * 
 * C++11 adds a large number of features such as variadic templates, @c constexpr , static asserts and much improved template support and metaprogramming.
................................................................................
 * * From @link std0memory <tt>\<memory\></tt> @endlink : @c addressof() , @c pointer_traits , @c allocator_traits , etc.
 * * From @link std0numeric <tt>\<numeric\></tt> @endlink : @c iota() .
 * * From @link std0random <tt>\<random\></tt> @endlink : @c shuffle_order_engine and @c knuth_b , <tt>#uniform_int_distribution</tt>, etc.
 * * From @link std0string <tt>\<string\></tt> @endlink : @c to_string() , @c stoul() and siblings, etc.
 * * From @link std0string_view <tt>\<string_view\></tt> @endlink : @c string_view , etc.
 * * From <tt>\<system_error\></tt>: <tt>@ref errc</tt> , @c system_error and others, etc.
 * * From <tt>\<type_traits\></tt>: @c #decay , @c #enable_if , @c #conditional , etc.
 * * From <tt>\<utility\></tt>: @c declval() , etc.
 * 
 * See also: @ref cxx03-backports @ref cxx14-backports @ref cxx17-backports .

 */

/**
 * @page cxx14-backports C++14 Backports
 * @brief Backports from C++14.
 * 
 * C++14 adds a number of features regarding algorithms and function object support.

 * 
 * A listing of some of the features backported:
 * 
 * * From @link std0algorithm <tt>\<algorithm\></tt> @endlink : @c equal() , @c mismatch() , etc.
 * * From <tt><functional></tt>: @link foo "Transparent Functors" @endlink .
 * * From @link std0memory <tt>\<memory\></tt> @endlink : @c make_unique() .
 * * From <tt><tuple></tt>: Tuple @ref gettuple by type.
 * * From @link std0utility <tt><utility></tt> @endlink : @c exchange() , @ref integer_sequence , etc.
 * 
 * See also: @ref cxx11-backports @ref cxx17-backports .

 */

/**
 * @page cxx17-backports C++17 Backports
 * @brief Backports from C++17.
 * 
 * A listing of some of the features backported:
 * 
 * * From the language proper: @link cxxomfort::cxxostd::byte @c std::byte @endlink (see also @c to_byte() )  . 
 * * From <tt><algorithm></tt>: @c clamp() .
 * * From <tt><cstddef></tt>: @c to_integral() .
 * * From <tt><functional></tt>: @c not_fn() .
 * * From @link std0iterator <tt><iterator></tt> @endlink : container data globals @c data() , @c size() , @c empty() . 
 * * From <tt><numeric></tt>: @c gcd() , @c lcm() .
 * * From <tt><tuple></tt>: @c make_from_tuple() , @c apply() .
 * * From <tt><type_traits></tt>: @c @ref make_void , @c @ref void_t , @c bool_constant , etc.
 * * From @link std0utility <tt><utility></tt> @endlink : @c as_const(), @c in_place_type , @c in_place_index etc.
 * 
 * See also: @ref cxx14-backports @ref cxx20-backports .
 * 
 */
................................................................................

/**
 * @page cxx20-backports
 * @brief Backports from C++20/2y/2z.
 * 
 * A listing of some of the features backported:
 * 

 * * From <tt>\<type_traits\></tt>: @c endian , @c remove_cvref .

 *
 * See also: @ref cxx17-backports .
 * 
 */


|





>

|
>
>







 







|


>







>







|


>











|
|
|







 







>
|
>




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
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
57
58
59
60
61
62
63
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
/**
 * @page cxx03-backports C++03 Backports
 * @brief Backports from C++03 and C++ TR1 (aka "2007").
 * 
 * A listing of some of the features backported:
 * 
 * * From <tt><array></tt>: @ref array , etc.
 * * From <tt><functional></tt>: @ref bind1st , @ref reference_wrapper , etc.
 * * A basic implementation of <tt>type_traits</tt> (not directly used).
 * 
 *
 * See also: @ref cxx11-backports  .
 * 
 */

/**
 * @page cxx11-backports C++11 Backports
 * @brief Backports from C++11.
 * 
 * C++11 adds a large number of features such as variadic templates, @c constexpr , static asserts and much improved template support and metaprogramming.
................................................................................
 * * From @link std0memory <tt>\<memory\></tt> @endlink : @c addressof() , @c pointer_traits , @c allocator_traits , etc.
 * * From @link std0numeric <tt>\<numeric\></tt> @endlink : @c iota() .
 * * From @link std0random <tt>\<random\></tt> @endlink : @c shuffle_order_engine and @c knuth_b , <tt>#uniform_int_distribution</tt>, etc.
 * * From @link std0string <tt>\<string\></tt> @endlink : @c to_string() , @c stoul() and siblings, etc.
 * * From @link std0string_view <tt>\<string_view\></tt> @endlink : @c string_view , etc.
 * * From <tt>\<system_error\></tt>: <tt>@ref errc</tt> , @c system_error and others, etc.
 * * From <tt>\<type_traits\></tt>: @c #decay , @c #enable_if , @c #conditional , etc.
 * * From <tt>\<utility\></tt>: @c declval() , @c move() , etc.
 * 
 * See also: @ref cxx03-backports @ref cxx14-backports @ref cxx17-backports .
 * 
 */

/**
 * @page cxx14-backports C++14 Backports
 * @brief Backports from C++14.
 * 
 * C++14 adds a number of features regarding algorithms and function object support.
 * In very general sense it is a "bugfix" upgrade to C++11.
 * 
 * A listing of some of the features backported:
 * 
 * * From @link std0algorithm <tt>\<algorithm\></tt> @endlink : @c equal() , @c mismatch() , etc.
 * * From <tt><functional></tt>: @link foo "Transparent Functors" @endlink .
 * * From @link std0memory <tt>\<memory\></tt> @endlink : @c make_unique() .
 * * From <tt><tuple></tt>: Tuple @ref gettuple by type.
 * * From @link std0utility <tt>\<utility\></tt> @endlink : @c exchange() , @ref integer_sequence , etc.
 * 
 * See also: @ref cxx11-backports @ref cxx17-backports .
 * 
 */

/**
 * @page cxx17-backports C++17 Backports
 * @brief Backports from C++17.
 * 
 * A listing of some of the features backported:
 * 
 * * From the language proper: @link cxxomfort::cxxostd::byte @c std::byte @endlink (see also @c to_byte() )  . 
 * * From <tt><algorithm></tt>: @c clamp() .
 * * From <tt><cstddef></tt>: @c to_integral() .
 * * From @link std0functional <tt>\<functional\></tt> @endlink : @c not_fn() , @c invoke() (down to C++11 only).
 * * From @link std0iterator <tt>\<iterator\></tt> @endlink : container data globals @c data() , @c size() , @c empty() . 
 * * From @link std0numeric <tt>\<numeric\></tt> @endlink : @c gcd() , @c lcm() .
 * * From <tt><tuple></tt>: @c make_from_tuple() , @c apply() .
 * * From <tt><type_traits></tt>: @c @ref make_void , @c @ref void_t , @c bool_constant , etc.
 * * From @link std0utility <tt><utility></tt> @endlink : @c as_const(), @c in_place_type , @c in_place_index etc.
 * 
 * See also: @ref cxx14-backports @ref cxx20-backports .
 * 
 */
................................................................................

/**
 * @page cxx20-backports
 * @brief Backports from C++20/2y/2z.
 * 
 * A listing of some of the features backported:
 * 
 * * From <tt><bit></tt> (mapped to <tt><type_traits></tt>): @c endian .
 * * From <tt>\<type_traits\></tt>: @c remove_cvref .
 * * From <tt>\<type_traits\></tt>: @c is_bounded_array , @c is_unbounded_array .
 *
 * See also: @ref cxx17-backports .
 * 
 */

Changes to cxxomfort/cxxomfort/extras.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef CXXOMFORT_EXTRAS_HPP
#define CXXOMFORT_EXTRAS_HPP

/**
 * @file
 * @brief This header file includes the available, finalized 
 * extras features.
 * (Non-finalized features have to be added explicitly)
 */

#include "base.hpp"

//#include "./extras/auto.hpp" // decltype(), auto emulation
//#include "./extras/dynarray.hpp" // dynarray aka fixed_vector implementation

#endif




|













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef CXXOMFORT_EXTRAS_HPP
#define CXXOMFORT_EXTRAS_HPP

/*
 * @file
 * @brief This header file includes the available, finalized 
 * extras features.
 * (Non-finalized features have to be added explicitly)
 */

#include "base.hpp"

//#include "./extras/auto.hpp" // decltype(), auto emulation
//#include "./extras/dynarray.hpp" // dynarray aka fixed_vector implementation

#endif

Changes to cxxomfort/cxxomfort/functional.hpp.

6
7
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
..
57
58
59
60
61
62
63
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

























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
 * @brief Implementations and backports tied to <code>\<functional\></code>.
 * @xrefitem std0functional "<functional>" "Header File"
 * 
 * */


#include <cxxomfort/base.hpp>
#include CXXO_INCLUDE_SYS(functional)

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

#if (CXXOMFORT_CXX_STD >= 2011)

#elif (CXXOMFORT_CXX_STD < 2011 && CXXOFLAG_tr1>0)


	// GCC has TR1 files under tr1/ and symbols under std::tr1::
	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)


		#include <tr1/functional>






namespace std {
    namespace placeholders { using namespace ::std::tr1::placeholders; };
    using tr1::reference_wrapper;
    using tr1::ref;
    using tr1::cref;
    using tr1::hash;
    using tr1::bind;
    using tr1::function;
    using tr1::bad_function_call;
    // using tr1::hash;
}

	#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1600) )
	// MSC 2010 and ahead don't have a tr1
	#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,<1600) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1500) )
	// MSC 2008 has tr1 under includepath, symbols under tr1::
namespace std {
	using tr1::reference_wrapper;
	using tr1::ref;
	using tr1::cref;
	using tr1::mem_fn;
................................................................................
	#endif // compiler
#else
	// before support for TR1
	#if defined(CXXOFLAG_USE_INTERNAL_TR1)
		#if (CXXOMFORT_NOTICES > 1)
			#pragma message CXXO_NOTICE("internal TR1: <functional>")
		#endif
		#include "./impl/07-reference_wrapper.hpp"
		#include "./impl/07-hash.hpp"
	#endif
#endif // c++ pre-11, tr1



namespace cxxomfort {
namespace cxxostd {








// 
// std::invoke (C++11-onward only)
//

#if (CXXOMFORT_CXX_STD >= 2017)
#elif (CXXOMFORT_CXX_STD >= 2011)
template<typename F, typename... Args>
auto invoke(F f, Args&&... args) 
-> decltype(std::ref(f)(std::forward<Args>(args)...))
{
    return std::ref(f)(std::forward<Args>(args)...);
}

#else

#endif

}} // cxxomfort::cxxostd



// The bit_and and sibling functors from <functional> are missing in MSVC 2008


#include "./impl/03-functional_bit.hpp"

#if (CXXOMFORT_CXX_STD >= 1997)


	#include "./impl/14-functional-transparent.hpp"
	#include "./impl/n4022-not_fn.hpp"
	// extra power for std::hash








	#include "./impl/hash.hpp"



















#endif


























//#include "./umpl/03-restore_binders.hpp"


#endif

/**
 * @page std0functional <functional>
 * @brief Backports related to <functional>
 * 





 * Interfaces defined in this section:
 * 
 * * Bit functoids @c bit_and , @c bit_or , @c bit_xor (C++03, only for some cases).
 * * @link impl/14-functional-transparent.hpp Transparent / Heterogegenous Functors @endlink (C++14).
 * * @link cxxomfort::cxxostd::reference_wrapper reference_wrapper @endlink (C++03) and its assisting functions.
 * * @c not_fn() (C++17) - generalically negate any functor.
 * * @c std::invoke (for C++11-onward only).
 * 








 * Non-backport interfaces:
 * 
 * * <code>cxxomfort::fix::hash</code> - Extra-power, specializable forwarder to @c std::hash .
 *





 * 
 * @section future "Planned for the future"
 * 
 * * Recovered function adaptors @c bind1st() , @c bind2nd() and @c ptr_fun (C++17/C++20).
 * 
 * @section also See Also
 * 
 * * @see @cppref{header/functional} 
 * * @see @ref cxxo-sup-functional (supplemental)
 * 
 */







<
<




|

|
>
>

<
>
>

>
>
>
>
>










|



|







 







|
|



<
>
|
|
>
>
>
>
>
>
>





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

>
>



>
>



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








|

>
>
>
>
>






|

>
>
>
>
>
>
>
>
|

|

>
>
>
>
>





|





6
7
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
..
63
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 * @brief Implementations and backports tied to <code>\<functional\></code>.
 * @xrefitem std0functional "<functional>" "Header File"
 * 
 * */


#include <cxxomfort/base.hpp>


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

// invoking header

#if (CXXOMFORT_CXX_STD >= 2011)
	// nothing to do, <functional> already in 
#elif (CXXOMFORT_CXX_STD >= 1997 && CXXOMFORT_CXX_STD < 2011 && CXXOFLAG_tr1>0)
	// GCC has TR1 files under tr1/ and symbols under std::tr1::

	#if (CXXOFLAG_directory_tr1)
		#include <functional>
		#include <tr1/functional>
	#else
		#include <functional>
	#endif
	
	#if (CXXOFLAG_namespace_tr1)

namespace std {
    namespace placeholders { using namespace ::std::tr1::placeholders; };
    using tr1::reference_wrapper;
    using tr1::ref;
    using tr1::cref;
    using tr1::hash;
    using tr1::bind;
    using tr1::function;
    using tr1::bad_function_call;
    using tr1::hash;
}

	#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1600) )
	// MSC 2010 and ahead don't have a namespace tr1
	#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,<1600) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1500) )
	// MSC 2008 has tr1 under includepath, symbols under tr1::
namespace std {
	using tr1::reference_wrapper;
	using tr1::ref;
	using tr1::cref;
	using tr1::mem_fn;
................................................................................
	#endif // compiler
#else
	// before support for TR1
	#if defined(CXXOFLAG_USE_INTERNAL_TR1)
		#if (CXXOMFORT_NOTICES > 1)
			#pragma message CXXO_NOTICE("internal TR1: <functional>")
		#endif
		#include "./impl/07-hash.hpp"
		#include "./impl/07-reference_wrapper.hpp"
	#endif
#endif // c++ pre-11, tr1


#if (CXXOMFORT_CXX_STD < 1997)
#endif
#if (CXXOMFORT_CXX_STD < 2011)
#endif
#if (CXXOMFORT_CXX_STD < 2014)
#endif
#if (CXXOMFORT_CXX_STD < 2017)
#endif
#if (CXXOMFORT_CXX_STD < 2020)
#endif

// 
// std::invoke (C++11-onward only)
//

#include "impl/17-invoke.hpp"














// 
// functoids
// The bit_and and sibling functors from <functional> are missing in MSVC 2008
// 

#include "./impl/03-functional_bit.hpp"

#if (CXXOMFORT_CXX_STD >= 1997)
	//#pragma message CXXO_NOTICE("functional backports")
	#include "./impl/hash.hpp"
	#include "./impl/14-functional-transparent.hpp"
	#include "./impl/n4022-not_fn.hpp"
	// extra power for std::hash
#endif

// 
// hash<> for unique_ptr (C++14)
//

#if (CXXOMFORT_CXX_STD>=2014)
#elif (CXXOMFORT_CXX_STD>=2011)
	#include <memory>
namespace std {

template <typename T>
struct hash< unique_ptr<T> > {
	typedef size_t result_type;
	typedef unique_ptr<T> argument_type;
	result_type operator() (argument_type const& a) const CXXO_NOEXCEPTNOTHROW {
		hash<T*> H;
		return H(a.get());
	}
	
};

}
#elif (CXXOMFORT_CXX_STD >= 1997)
	#include <cxxomfort/memory.hpp>
namespace std {
	#if CXXOFLAG_namespace_tr1
		namespace tr1 {
	#endif

template <typename T>
struct hash< std::unique_ptr<T> > {
	typedef size_t result_type;
	typedef std::unique_ptr<T> argument_type;
	result_type operator() (argument_type const& a) const CXXO_NOEXCEPTNOTHROW {
		hash<T*> H;
		return H(a.get());
	}
	
};


	#if CXXOFLAG_namespace_tr1
	}
	#endif

}

#endif

// 
// hash helper
// 


//#include "./umpl/03-restore_binders.hpp"


#endif

/**
 * @page std0functional <functional>
 * @brief Backports related to Standard header <tt><functional></tt> 
 * 
 * @code
 * #include <cxxomfort/functional.hpp>
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined in this section:
 * 
 * * Bit functoids @c bit_and , @c bit_or , @c bit_xor (C++03, only for some cases).
 * * @link impl/14-functional-transparent.hpp Transparent / Heterogegenous Functors @endlink (C++14).
 * * @link cxxomfort::cxxostd::reference_wrapper reference_wrapper @endlink (C++03) and its assisting functions.
 * * @c not_fn() (C++17) - generalically negate any functor.
 * * @c invoke() (for C++11-onward only).
 * 
 * Interfaces repointed in this section when in TR1:
 * 
 * * @c std::reference_wrapper , @c std::ref() , @c std::cref()
 * * @c std::bind()  and related utilities.
 * * <tt>std::placeholders::_*</tt>
 * * @c std::mem_fn() 
 * * @c std::function
 * 
 * Non-backport interfaces (<tt>cxxomfort::fix</tt>):
 * 
 * * @link cxxomfort::fix::hash <tt>hash</tt> @endlink - Extra-power, specializable forwarder to @c std::hash .
 *
 * @subsection Notes 
 * 
 * @note <b>Cxxomfort</b> expects an implementation of <tt>std::reference_wrapper</tt> and related utilities to exist and function in order, as part of the general TR1 requirement.
 * 
 * @note <b>Cxxomfort</b> expects an implementation of <tt>std::bind</tt> and related utilities to exist and function in order, as part of the general TR1 requirement.
 * 
 * @section future "Planned for the future"
 * 
 * * Recovered function adaptors @c bind1st() , @c bind2nd() and @c ptr_fun (C++17/C++20).
 * 
 * @subsection also See Also
 * 
 * * @see @cppref{header/functional} 
 * * @see @ref cxxo-sup-functional (supplemental)
 * 
 */

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

1
2
3
4
5
6
7
8
9
#ifndef CXXOMFORT_IMPL_03_STD_ARRAY_HPP
#define CXXOMFORT_IMPL_03_STD_ARRAY_HPP
/**
 * @file
 * 
 * This is an implementation of std::array 
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only when no TR1 has been found and 
|
|







1
2
3
4
5
6
7
8
9
#ifndef CXXOMFORT_IMPL_07_STD_ARRAY_HPP
#define CXXOMFORT_IMPL_07_STD_ARRAY_HPP
/**
 * @file
 * 
 * This is an implementation of std::array 
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only when no TR1 has been found and 

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

1
2
3
4
5
6
7
8
9
#ifndef CXXOMFORT_IMPL_03_HASH_HPP
#define CXXOMFORT_IMPL_03_HASH_HPP
/**
 * @file
 * 
 * This is an implementation of std::hash 
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only when no TR1 has been found and 
|
|







1
2
3
4
5
6
7
8
9
#ifndef CXXOMFORT_IMPL_07_HASH_HPP
#define CXXOMFORT_IMPL_07_HASH_HPP
/**
 * @file
 * 
 * This is an implementation of std::hash 
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only when no TR1 has been found and 

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

1
2
3
4
5
6
7
8
9
..
15
16
17
18
19
20
21




22
23
24
25
26
27
28
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef CXXOMFORT_IMPL_REFERENCE_WRAPPER_HPP
#define CXXOMFORT_IMPL_REFERENCE_WRAPPER_HPP
/**
 * @file
 * 
 * This is an implementation of std::reference_wrapper and allies 
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only when no TR1 has been found and 
................................................................................
#include "11-addressof.hpp"
#define CXXOMFORT_IMPLEMENTS_n1436 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n1453 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_reference_wrapper CXXOMFORT_IMPLEMENTS_n1453

namespace cxxomfort {
namespace cxxostd {





/**
 * @brief reference_wrapper from C++11.
 * @anchor reference_wrapper
 */
template <typename T>
struct reference_wrapper {
................................................................................
    }


    T& get () const CXXO_NOEXCEPTNOTHROW { return v; }
    operator T& () const CXXO_NOEXCEPTNOTHROW { return v; }

	#if (CXXO_COMPILER_SUPPORT_typeof)
    __typeof__( std::declval<T>()() ) 
    operator() () const {
        return get()();
    }
    template <typename T1>
    __typeof__( std::declval<T>()(std::declval<T1>()) )
    operator() (T1 const& a1) const {
        return get()(a1);
    }
    template <typename T1, typename T2>
    __typeof__( std::declval<T>()(std::declval<T1>(), std::declval<T2>() ) )
    operator() (T1 const& a1, T2 const& a2) const {
        return get()(a1,a2);
    }
    #endif
    
    private:
    T* v;
|
|







 







>
>
>
>







 







|




|




|







1
2
3
4
5
6
7
8
9
..
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CXXOMFORT_IMPL_07_REFERENCE_WRAPPER_HPP
#define CXXOMFORT_IMPL_07_REFERENCE_WRAPPER_HPP
/**
 * @file
 * 
 * This is an implementation of std::reference_wrapper and allies 
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only when no TR1 has been found and 
................................................................................
#include "11-addressof.hpp"
#define CXXOMFORT_IMPLEMENTS_n1436 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n1453 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_reference_wrapper CXXOMFORT_IMPLEMENTS_n1453

namespace cxxomfort {
namespace cxxostd {

namespace detail_ref {
	template <typename T> T& declval();
}

/**
 * @brief reference_wrapper from C++11.
 * @anchor reference_wrapper
 */
template <typename T>
struct reference_wrapper {
................................................................................
    }


    T& get () const CXXO_NOEXCEPTNOTHROW { return v; }
    operator T& () const CXXO_NOEXCEPTNOTHROW { return v; }

	#if (CXXO_COMPILER_SUPPORT_typeof)
    __typeof__( detail_ref::declval<T>()() ) 
    operator() () const {
        return get()();
    }
    template <typename T1>
    __typeof__( detail_ref::declval<T>()(detail_ref::declval<T1>()) )
    operator() (T1 const& a1) const {
        return get()(a1);
    }
    template <typename T1, typename T2>
    __typeof__( detail_ref::declval<T>()(detail_ref::declval<T1>(), detail_ref::declval<T2>() ) )
    operator() (T1 const& a1, T2 const& a2) const {
        return get()(a1,a2);
    }
    #endif
    
    private:
    T* v;

Added cxxomfort/cxxomfort/impl/07-type_traits.hpp.



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
#ifndef CXXOMFORT_IMPL_07_TYPE_TRAITS_HPP
#define CXXOMFORT_IMPL_07_TYPE_TRAITS_HPP
/**
 * @file
 * 
 * This is an implementation of type traits, starting with those 
 * made available in TR1 (:2007) and some cxxomfort additions,  
 * not directly used by cxxomfort but made available for TR1 compatibility layers.
 * 
 * This file should end up included only in one of two conditions:
 * * no TR1 has been found and the user has requested CXXO_USE_INTERNAL_TR1.
 * * when using certain cxxomfort utilities that rely on their own type traits, such as typesafe_enum
 * 
 */


#include <cxxomfort/config.hpp>
#include <cxxomfort/base/nullptr.hpp>
#include <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; };
    template <typename T> struct drop_cv<T volatile> { typedef T type; };
    template <typename T> struct drop_cv<T const volatile> { typedef T type; };


	template <size_t N, bool Signed=true> struct integral_of_size;
	
	// for this we can't use the native names (int, long, long long) because their 
	// sizeof matches could cause conflicts of template redefinition
	template <> struct integral_of_size<sizeof(char), false> { typedef unsigned char type; enum { value = sizeof(char) }; };
	template <> struct integral_of_size<sizeof(uint16_t), false> { typedef uint16_t type; enum { value = sizeof(short) }; };
	template <> struct integral_of_size<sizeof(uint32_t), false> { typedef uint32_t type; enum { value = sizeof(int) }; };
	template <> struct integral_of_size<sizeof(uint64_t), false> { typedef uint64_t type; enum { value = sizeof(long) }; };
	template <> struct integral_of_size<sizeof(char), true> { typedef signed char type; enum { value = sizeof(char) }; };
	template <> struct integral_of_size<sizeof(int16_t), true> { typedef int16_t type; enum { value = sizeof(short) }; };
	template <> struct integral_of_size<sizeof(int32_t), true> { typedef int32_t type; enum { value = sizeof(int) }; };
	template <> struct integral_of_size<sizeof(int64_t), true> { typedef int64_t type; enum { value = sizeof(long) }; };
	

} // helper

/**
 * type_identity
 * */
template <typename T> struct type_identity { typedef T type; };

/**
 * integral_constant
 */
template <typename Integral, Integral I> struct integral_constant {
    typedef Integral value_type;
    typedef integral_constant<Integral,I> type;
    static const Integral value= I;
    CXXO_CONSTEXPR operator value_type () const CXXO_NOEXCEPTNOTHROW { return value; }
    CXXO_CONSTEXPR value_type operator() () const CXXO_NOEXCEPTNOTHROW { return value; } // from C++14
};

//! bool_constant
template <bool B>
struct bool_constant : public integral_constant<bool, B> {};

//! true_type
struct false_type : integral_constant<bool,false> {};
//! false_type
struct true_type : integral_constant<bool,true> {};

#define TR1LITE_CVSPECIALIZE_TRUE(name,type) \
	template <> struct name : name##_impl< typename helper::drop_cv<type>::type >  {}
#define TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(name) \
	template <typename T> struct name : name##_impl < typename helper::drop_cv<T>::type> {}


// 
// is_same 
// 
template <typename TA, typename TB> struct is_same : false_type {};
template <typename T> struct is_same<T,T> : true_type {};

//
// is_const
//
template <typename T> struct is_const
: false_type {};
template <typename T> struct is_const<T const>
: true_type {};

//
// is_volatile
//
template <typename T> struct is_volatile
: false_type {};
template <typename T> struct is_volatile<T volatile>
: true_type {};

//! remove_const
template <typename T> struct remove_const {
    typedef T type;
};
template <typename T> struct remove_const<T const> {
    typedef T type;
};

//! remove_volatile
template <typename T> struct remove_volatile {
    typedef T type;
};
template <typename T> struct remove_volatile<T volatile> {
    typedef T type;
};

//! remove_cv
template <typename T> struct remove_cv : helper::drop_cv<T> {};

// 
// add_const
// 
template <typename T> struct add_const {
    typedef T const type;
};
template <typename T> struct add_const<T const> {
    typedef T const type;
};

//
// add_volatile
//
template <typename T> struct add_volatile {
    typedef T volatile type;
};
template <typename T> struct add_volatile<T volatile> {
    typedef T volatile type;
};

// 
// add_cv
// 
template <typename T> struct add_cv {
    typedef typename add_volatile< typename add_const<T>::type >::type type;
};

// 
// is_reference, is_lvalue_reference, is_rvalue_reference
// 
template <typename T> struct is_reference : false_type {};
template <typename T> struct is_reference<T&> : true_type {};
// is_lvalue_reference
template <typename T> struct is_lvalue_reference : false_type {};
template <typename T> struct is_lvalue_reference<T&> : true_type {};
// is_rvalue_reference
template <typename T> struct is_rvalue_reference : false_type {};
#if (CXXOMFORT_CXX_STD>=2011)
template <typename T> struct is_rvalue_reference<T&&> : true_type {};
#endif

// 
// is_pointer
// 
template <typename T> struct is_pointer : false_type {};
template <typename T> struct is_pointer<T*> : true_type {};

// 
// remove_reference
// 
template <typename T> struct remove_reference {
    typedef T type;
};
template <typename T> struct remove_reference<T&> {
    typedef T type;
};

// 
// remove_pointer
// 
template <typename T> struct remove_pointer {
    typedef T type;
};
template <typename T> struct remove_pointer<T*> {
    typedef T type;
};

// 
// add_reference
// 
template <typename T> struct add_reference {
    typedef T& type;
};
template <typename T> struct add_reference<T&> {
    typedef T& type;
};
template <> struct add_reference<void> {
    typedef void type;
};
template <> struct add_reference<void const> {
    typedef void const type;
};
template <> struct add_reference<void volatile> {
    typedef void volatile type;
};
template <> struct add_reference<void const volatile> {
    typedef void const volatile type;
};

// 
// add_lvalue_reference
// 
template <typename T> struct add_lvalue_reference : add_reference<T> {};
#if (CXXOMFORT_CXX_STD>=2011)
template <typename T> struct add_lvalue_reference<T&&> { typedef T& type; };
#endif

// 
// add_rvalue_reference
// 
#if (CXXOMFORT_CXX_STD>=2011)
template <typename T> struct add_rvalue_reference { typedef T&& type; };
template <typename T> struct add_rvalue_reference<T&> { typedef T& type; };
template <typename T> struct add_rvalue_reference<T&&> { typedef T&& type; };
#else
template <typename T> struct add_rvalue_reference { /* intentionally empty*/ };
#endif


// 
// add_pointer
// 
template <typename T> struct add_pointer {
    typedef T* type;
};

// 
// remove_cvref 
// 
template <typename T> struct remove_cvref {
	typedef typename remove_reference<T>::type t1;
	typedef typename remove_cv<t1>::type type;
};

//
// is_void
//
template <typename T> struct is_void_impl : false_type {};
template <> struct is_void_impl<void> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_void);

//
// is_integral
//
template <typename T> struct is_integral_impl : false_type {};
template <> struct is_integral_impl<signed short> : true_type {};
template <> struct is_integral_impl<unsigned short> : true_type {};
template <> struct is_integral_impl<signed int> : true_type {};
template <> struct is_integral_impl<unsigned int> : true_type {};
template <> struct is_integral_impl<signed long> : true_type {};
template <> struct is_integral_impl<unsigned long> : true_type {};
template <> struct is_integral_impl<signed long long> : true_type {};
template <> struct is_integral_impl<unsigned long long> : true_type {};
template <> struct is_integral_impl<signed char> : true_type {};
template <> struct is_integral_impl<unsigned char> : true_type {};
template <> struct is_integral_impl<wchar_t> : true_type {};
template <> struct is_integral_impl<bool> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_integral);

//
// is_floating_point
//
template <typename T> struct is_floating_point_impl : false_type {};
template <> struct is_floating_point_impl<float> : true_type {};
template <> struct is_floating_point_impl<double> : true_type {};
template <> struct is_floating_point_impl<long double> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_floating_point);

// 
// is_null_pointer
// 
template <typename T> struct is_null_pointer_impl : false_type {};
template <> struct is_null_pointer_impl<std::nullptr_t> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_null_pointer);

// 
// is_char_type
// 
template <typename T> struct is_char_type_impl : false_type {};
template <> struct is_char_type_impl<char> : true_type {};
template <> struct is_char_type_impl<unsigned char> : true_type {};
template <> struct is_char_type_impl<signed char> : true_type {};
template <> struct is_char_type_impl<wchar_t> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_char_type);


// 
// is_arithmetic
// 
template <typename T> struct is_arithmetic
: integral_constant<bool, is_integral<T>::value || is_floating_point<T>::value >
{};

// 
// is_fundamental
// 
template <typename T> struct is_fundamental
: integral_constant<bool,
    is_arithmetic<T>::value || is_void<T>::value || is_null_pointer<T>::value
>
{};

// 
// is_compound -- any type that is not fundamental
// 
template <typename T> struct is_compound
: integral_constant<bool, !is_fundamental<T>::value> {};

//
// is_signed
//
template <typename T> struct is_signed_impl : false_type {};
template <> struct is_signed_impl<signed short> : true_type {};
template <> struct is_signed_impl<signed int> : true_type {};
template <> struct is_signed_impl<signed long> : true_type {};
template <> struct is_signed_impl<signed long long> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_signed);

//
// is_unsigned
//
template <typename T> struct is_unsigned_impl : false_type {};
template <> struct is_unsigned_impl<unsigned short> : true_type {};
template <> struct is_unsigned_impl<unsigned int> : true_type {};
template <> struct is_unsigned_impl<unsigned long> : true_type {};
template <> struct is_unsigned_impl<unsigned long long> : true_type {};
TR1LITE_CVSPECIALIZE_TRUE_TEMPLATE(is_unsigned);

//
// make_signed, make_unsigned
//

namespace detail {
	
template <size_t S> struct get_signed {};
template <> struct get_signed< sizeof(signed char) > { typedef signed char type; };
template <> struct get_signed< sizeof(int16_t) > { typedef int16_t type; };
template <> struct get_signed< sizeof(int32_t) > { typedef int32_t type; };
template <> struct get_signed< sizeof(int64_t) > { typedef int64_t type; };

template <size_t S> struct get_unsigned {};
template <> struct get_unsigned< sizeof(unsigned char) > { typedef unsigned char type; };
template <> struct get_unsigned< sizeof(uint16_t) > { typedef uint16_t type; };
template <> struct get_unsigned< sizeof(uint32_t) > { typedef uint32_t type; };
template <> struct get_unsigned< sizeof(uint64_t) > { typedef uint64_t type; };


template <typename T> struct make_signed_impl : get_signed<sizeof(T)> {};
template <> struct make_signed_impl<bool> {};

template <typename T> struct make_signed_impl<T const> 
: add_const< typename make_signed_impl<T>::type > {};

template <typename T> struct make_signed_impl<T volatile> 
: add_volatile< typename make_signed_impl<T>::type > {};

template <typename T> struct make_signed_impl<T const volatile> 
: add_cv< typename make_signed_impl<T>::type > {};

template <typename T> struct make_unsigned_impl : get_unsigned<sizeof(T)> {};
template <> struct make_unsigned_impl<bool> {};

template <typename T> struct make_unsigned_impl<T const> 
: add_const< typename make_unsigned_impl<T>::type > {};

template <typename T> struct make_unsigned_impl<T volatile> 
: add_volatile< typename make_unsigned_impl<T>::type > {};

template <typename T> struct make_unsigned_impl<T const volatile> 
: add_cv< typename make_unsigned_impl<T>::type > {};

} // detail

template <typename T> struct make_signed 
: detail::make_signed_impl<T> { };

template <typename T> struct make_unsigned 
: detail::make_unsigned_impl<T> { };


// 
// is_array
// 
template <typename T> struct is_array_impl : false_type {};
template <typename T, size_t N> struct is_array_impl <T[N]> : true_type {};
template <typename T> struct is_array_impl <T[]> : true_type {};
template <typename T> struct is_array 
: is_array_impl< typename helper::drop_cv<T>::type > {};

// 
// is_bounded_array (C++20)
// 
template <typename T> struct is_bounded_array_impl : false_type {};
template <typename T, size_t N> struct is_bounded_array_impl <T[N]> : true_type {};
template <typename T> struct is_bounded_array 
: is_bounded_array_impl< typename helper::drop_cv<T>::type > {};

// 
// is_unbounded_array (C++20)
// 
template <typename T> struct is_unbounded_array_impl : false_type {};
template <typename T> struct is_unbounded_array_impl <T[]> : true_type {};
template <typename T> struct is_unbounded_array 
: is_unbounded_array_impl< typename helper::drop_cv<T>::type > {};

// 
// rank = number of dimensions
// 
template <typename T> struct rank : integral_constant< size_t, 0> {};
template <typename T> struct rank<T[]> : integral_constant< size_t, rank<T>::value + 1> {};
template <typename T, size_t N> struct rank<T[N]> : integral_constant< size_t, rank<T>::value + 1> {};

//
// extent = size of topmost dimension
//
template<typename T, size_t N=0> struct extent 
: integral_constant<size_t, 0> {};
template<typename T>                    struct extent<T[],0> 
: integral_constant<size_t, 0> {};
template<typename T, unsigned N>        struct extent<T[],N> 
: integral_constant<size_t, extent<T,N-1>::value> {};
template<typename T, size_t N>          struct extent<T[N],0> 
: integral_constant<size_t, N> {};
template<typename T, size_t I, unsigned N> struct extent<T[I],N> 
: integral_constant<size_t, extent<T,N-1>::value> {};

//
// remove extent
//
template <typename T>
struct remove_extent { typedef T type; };
template <typename T>
struct remove_extent<T[]> { typedef T type; };
template <typename T, std::size_t N>
struct remove_extent<T[N]> { typedef T type;};

//
// remove all extents
//
template <typename T>
struct remove_all_extents { typedef T type;};
template <typename T>
struct remove_all_extents<T[]> {
    typedef typename remove_all_extents<T>::type type;
};
template <typename T, std::size_t N>
struct remove_all_extents<T[N]> {
    typedef typename remove_all_extents<T>::type type;
};

// 
// is_function
// 
template <typename T> struct is_function : false_type {};
// we handle up to 5 arguments (1 to 9) then ellipsis
template <typename R> struct is_function <R()>
: true_type {};
template <typename R, typename T1>  struct is_function<R(T1)>
: true_type {};
template <typename R, typename T1, typename T2> struct is_function<R(T1,T2)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3> struct is_function<R(T1,T2,T3)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4> struct is_function<R(T1,T2,T3,T4)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5> struct is_function<R(T1,T2,T3,T4,T5)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5> struct is_function<R(T1,T2,T3,T4,T5,...)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> 
struct is_function<R(T1,T2,T3,T4,T5,T6)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> 
struct is_function<R(T1,T2,T3,T4,T5,T6,T7)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> 
struct is_function<R(T1,T2,T3,T4,T5,T6,T7,T8)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 
struct is_function<R(T1,T2,T3,T4,T5,T6,T7,T8,T9)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 
struct is_function<R(T1,T2,T3,T4,T5,T6,T7,T8,T9, ...)>
: true_type {};

// 
// is_member_pointer and associates
// 

namespace detail {
// this gets a little wieldly, we handle up to 5 arguments (A0 to A4)

    template <typename T> struct f_helper : false_type {};
    template <typename R, typename Class>
    struct f_helper< R(Class::*)()> : true_type {};
    template <typename R, typename Class, typename A1>
    struct f_helper< R(Class::*)(A1)> : true_type {};
    template <typename R, typename Class, typename A1>
    struct f_helper< R(Class::*)(A1,...)> : true_type {};

	template <typename T> struct m_helper : false_type {};
	template <typename T, typename Class>
	struct m_helper< T Class::* > : true_type {};

} // member function pointer helper


template <typename T>
struct is_member_function_pointer 
: detail::f_helper< typename helper::drop_cv<T>::type > {};

template <typename T>
struct is_member_pointer 
: detail::m_helper< typename helper::drop_cv<T>::type > {};

template <typename T>
struct is_member_object_pointer
: integral_constant< bool, is_member_pointer<T>::value == true && is_member_function_pointer<T>::value == false> {};


// 
// traits that require compiler support
// 

#if (CXXOMFORT_CXX_STD >= 2011)
	#define Trait2(name,intr) 
	// nothing to do
	using std::is_enum;
	using std::is_class;
	using std::is_union;
	using std::is_pod;
	
#elif (CXXOMFORT_CXX_STD>=1997 && CXXOMFORT_CXX_EMULATION>=2007)

	#define Trait2(name,intr) template <typename T> struct name : integral_constant<bool, intr(T) ? true : false> {}

Trait2(is_enum, __is_enum);
Trait2(is_empty, __is_empty);
Trait2(is_union, __is_union);
Trait2(is_class, __is_class);
Trait2(is_pod, __is_pod);

	#undef Trait2

#else

	#define Trait2(name) template <typename T> struct name : false_type {}

Trait2(is_enum);
Trait2(is_empty);
Trait2(is_union);
Trait2(is_class);

// quick & dirty
template <typename T> struct is_pod : is_arithmetic<T> {};

#endif
#undef Trait2


/*
 * Advanced type properties
 */

// given the above, it should be possible to 
// implement is_scalar.
template<class T>
struct is_scalar 
: integral_constant < bool,
    is_arithmetic<T>::value || is_pointer<T>::value ||
    is_member_pointer<T>::value || is_enum<T>::value ||
    is_null_pointer<T>::value
> {};

// as well as is_object
template <class T> 
struct is_object 
: helper::conditional< 
    !(is_function<T>::value 
     || is_reference<T>::value 
     || is_void<T>::value)
, true_type, false_type>::type     {};


} } // cxxomfort::traits

#endif

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

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

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

#include <cxxomfort/base.hpp>
#include <cxxomfort/cstddef.hpp> 
#include <cxxomfort/cuchar.hpp> // char16_t
#include <cxxomfort/util/type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)
namespace cxxomfort { namespace cxxostd {
} }

#if (CXXO_charn_t_typedefs==1)







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

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

#include <cxxomfort/base.hpp>
#include <cxxomfort/cstddef.hpp> 
#include <cxxomfort/cuchar.hpp> // char16_t
#include <cxxomfort/impl/07-type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)
namespace cxxomfort { namespace cxxostd {
} }

#if (CXXO_charn_t_typedefs==1)

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

4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
22
 * @file
 * */

#if (defined(CXXOMFORT_NOTICES) && CXXOMFORT_NOTICES>2)
    #pragma message CXXO_NOTICE("common_type trait specifics")
#endif


#include "../util/type_traits.hpp"
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // std::declval
#include "11-decay.hpp"
#include "17-void_t.hpp"
#include <ciso646>

namespace cxxomfort { namespace cxxostd {

    /*
     * MSVC 2010 ships with a broken implementation of common_type that, 
     * among other things, takes only 2 parameters. So we need to 







>
|


|
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 * @file
 * */

#if (defined(CXXOMFORT_NOTICES) && CXXOMFORT_NOTICES>2)
    #pragma message CXXO_NOTICE("common_type trait specifics")
#endif

#include <cxxomfort/config.hpp>
#include "../impl/07-type_traits.hpp"
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // std::declval
#include "../impl/11-decay.hpp"
#include "../impl/17-void_t.hpp"
#include <ciso646>

namespace cxxomfort { namespace cxxostd {

    /*
     * MSVC 2010 ships with a broken implementation of common_type that, 
     * among other things, takes only 2 parameters. So we need to 

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

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define CXXOMFORT_IMPL_IS_CONSTRUCTIBLE_HPP

#if (0) // UNTESTED

// This solution mostly extracted from 
// https://stackoverflow.com/questions/38181357/how-is-stdis-constructiblet-args-implemented?noredirect=1&lq=1

#include <cxxomfort/util/type_traits.hpp>
#include "17-void_t.hpp"

namespace cxxomfort {
namespace cxxostd {

// In theory all STD C++11 compilers support is_constructible, nothing to do here








|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define CXXOMFORT_IMPL_IS_CONSTRUCTIBLE_HPP

#if (0) // UNTESTED

// This solution mostly extracted from 
// https://stackoverflow.com/questions/38181357/how-is-stdis-constructiblet-args-implemented?noredirect=1&lq=1

#include <cxxomfort/impl/07-type_traits.hpp>
#include "17-void_t.hpp"

namespace cxxomfort {
namespace cxxostd {

// In theory all STD C++11 compilers support is_constructible, nothing to do here

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

1
2
3
4
5
6
7





8










9
10
11
12

13
14
15
16
17
18
19
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

81
82
83
84

85
86
#ifndef CXXOMFORT_IMPL_IS_OF_HPP
#define CXXOMFORT_IMPL_IS_OF_HPP
/**
 * @file cxxomfort/algorithm.hpp
 */

#include <cxxomfort/config.hpp>





#define CXXOMFORT_IMPLEMENTS_n2569 CXXO_IMPLSTATUS_BACKPORT()










#define CXXOMFORT_IMPLEMENTS_is_all_of CXXOMFORT_IMPLEMENTS_n2569

namespace cxxomfort {
namespace cxxostd {


/**
 * @ingroup algorithm
 * @ingroup cxx11-backports
 * @sa https://wg21.link/n2569
 * @{
 */
................................................................................
    return true;
}

/**
 * @}
 */

} // cxxomfort::algorithm
} // cxxomfort


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
#if (CXXOMFORT_CXX_STD < 2011)
    namespace std {
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_COMPILER_VERSION >=404 && CXXOMFORT_COMPILER_VERSION <= 406 && CXXOMFORT_CXX_EMULATION==2011 )
        // GCC already has defined these in 4.4-4.6 c++0x mode
    #else
        using ::cxxomfort::cxxostd::all_of;
        using ::cxxomfort::cxxostd::any_of;
        using ::cxxomfort::cxxostd::none_of;
    #endif


}
#endif // c++11
#endif // no-using



#endif







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



>







 







<
|

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

>


1
2
3
4
5
6
7
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
..
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
#ifndef CXXOMFORT_IMPL_IS_OF_HPP
#define CXXOMFORT_IMPL_IS_OF_HPP
/**
 * @file cxxomfort/algorithm.hpp
 */

#include <cxxomfort/config.hpp>
#include <algorithm>

#if (CXXOMFORT_CXX_STD >= 2011 || \
	(CXXOMFORT_CXX_STD >= 1997 && CXXOMFORT_CXX_EMULATION == 2011))

	#define CXXOMFORT_IMPLEMENTS_n2569 CXXO_IMPLSTATUS_NATIVE()

	// nothing to do
namespace cxxomfort { namespace cxxostd {
	using std::all_of;
	using std::any_of;
	using std::none_of;
} } 

#else

	#define CXXOMFORT_IMPLEMENTS_n2569 CXXO_IMPLSTATUS_BACKPORT()

namespace cxxomfort {
namespace cxxostd {


/**
 * @ingroup algorithm
 * @ingroup cxx11-backports
 * @sa https://wg21.link/n2569
 * @{
 */
................................................................................
    return true;
}

/**
 * @}
 */


} }  // cxxomfort::cxxostd


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

namespace std {
		#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_COMPILER_VERSION >=404 && CXXOMFORT_COMPILER_VERSION <= 406 && CXXOMFORT_CXX_EMULATION==2011 )
			// GCC already has defined these in 4.4-4.6 c++0x mode
		#else
	using ::cxxomfort::cxxostd::all_of;
	using ::cxxomfort::cxxostd::any_of;
	using ::cxxomfort::cxxostd::none_of;
		#endif
}
	#endif

#endif


#define CXXOMFORT_IMPLEMENTS_is_all_of CXXOMFORT_IMPLEMENTS_n2569

#endif

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

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 * @brief Implementation for std::to_string and allies 
 * @xrefitem std0string "<string>"
 *
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/cstdint.hpp>
#include <cxxomfort/util/type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h> // for MSVC?
#include <stdexcept>
#include <limits>
#include <vector>







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 * @brief Implementation for std::to_string and allies 
 * @xrefitem std0string "<string>"
 *
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/cstdint.hpp>
#include <cxxomfort/impl/07-type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h> // for MSVC?
#include <stdexcept>
#include <limits>
#include <vector>

Changes to cxxomfort/cxxomfort/impl/11-to_string.pre97.hpp.

5
6
7
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
57
58
59
60
61
62
63
64
65
66
67
 * @brief Implementation for std::to_string and allies 
 * @xrefitem std0string "<string>"
 *
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/cstdint.hpp>
#include <cxxomfort/util/type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h> // for MSVC?
#include <stdexcept>
#include <limits>
#include <vector>
#include <cerrno>

namespace cxxomfort { namespace cxxostd {










static std::string to_string (int u) {
	using namespace std;
	char buff[20]= {0};








	sprintf(buff,"%d",u);
	return std::string(buff);
}


static std::string to_string (unsigned int u) {
	using namespace std;
	char buff[20]= {0};
	sprintf(buff,"%u",u);
	return std::string(buff);
}


static std::string to_string (long int l) {
	using namespace std;
	char buff[30]= {0};
	sprintf(buff,"%ld",l);
	return std::string(buff);
}


static std::string to_string (long unsigned l) {
	using namespace std;
	char buff[30]= {0};
	sprintf(buff,"%lu",l);
	return std::string(buff);
}



static std::string to_string (double f) {
	using namespace std;
	char buff[64]= {0};
	sprintf(buff,"%f",f);
	return std::string(buff);
}


} }

namespace std {
	using cxxomfort::cxxostd::to_string;
}

#endif







<


<

<
<
<
<



>
>
>
>
>
>
>
>
>
|

|
>
>
>
>
>
>
>
>




>
|

|




>
|






>
|







>
|

|












5
6
7
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 * @brief Implementation for std::to_string and allies 
 * @xrefitem std0string "<string>"
 *
 */

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

#include <string>
#include <cstdio>

#include <stdlib.h> // for MSVC?





namespace cxxomfort { namespace cxxostd {

static inline 
std::string to_string (unsigned short u) {
	using namespace std;
	char buff[8]= {0};
	sprintf(buff,"%u",u);
	return std::string(buff);
}

static inline 
std::string to_string (signed short u) {
	using namespace std;
	char buff[8]= {0};
	sprintf(buff,"%d",u);
	return std::string(buff);
}

static inline 
std::string to_string (signed int u) {
	using namespace std;
	char buff[30]= {0};
	sprintf(buff,"%d",u);
	return std::string(buff);
}

static inline 
std::string to_string (unsigned int u) {
	using namespace std;
	char buff[30]= {0};
	sprintf(buff,"%u",u);
	return std::string(buff);
}

static inline 
std::string to_string (signed long int l) {
	using namespace std;
	char buff[30]= {0};
	sprintf(buff,"%ld",l);
	return std::string(buff);
}

static inline 
std::string to_string (unsigned long int l) {
	using namespace std;
	char buff[30]= {0};
	sprintf(buff,"%lu",l);
	return std::string(buff);
}


static inline 
std::string to_string (double f) {
	using namespace std;
	char buff[128]= {0};
	sprintf(buff,"%f",f);
	return std::string(buff);
}


} }

namespace std {
	using cxxomfort::cxxostd::to_string;
}

#endif

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP
#define CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP

/**
 * @file
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/util/type_traits.hpp> // make_signed
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp> // make_signed
#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)
................................................................................
    #if (CXXOMFORT_CXX_STD < 2011)
namespace {
    using cxxomfort::traits::make_signed;
    using cxxomfort::traits::make_unsigned;
}
    #endif

    namespace std {
    

    template< typename TpEnum >
    struct underlying_type {
        typedef typename ::cxxomfort::impl::integral_of_size<sizeof(TpEnum)>::type tsize_t;
        private:
        typedef typename make_signed< tsize_t >::type S;
        typedef typename make_unsigned< tsize_t >::type U;
        public:
        typedef typename std::conditional<
            (TpEnum( -1 ) < TpEnum( 0 )), S, U
            >::type type;
    };

    }

#else // At this point there should be full C++11 support for underlying_type
#endif // underlying_type


#endif








|
|
|
|







 







|




|









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP
#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)
................................................................................
    #if (CXXOMFORT_CXX_STD < 2011)
namespace {
    using cxxomfort::traits::make_signed;
    using cxxomfort::traits::make_unsigned;
}
    #endif

namespace std {
    

    template< typename TpEnum >
    struct underlying_type {
        typedef typename ::cxxomfort::traits::integral_of_size<sizeof(TpEnum)>::type tsize_t;
        private:
        typedef typename make_signed< tsize_t >::type S;
        typedef typename make_unsigned< tsize_t >::type U;
        public:
        typedef typename std::conditional<
            (TpEnum( -1 ) < TpEnum( 0 )), S, U
            >::type type;
    };

}

#else // At this point there should be full C++11 support for underlying_type
#endif // underlying_type


#endif

Changes to cxxomfort/cxxomfort/impl/14-functional-transparent.hpp.

1
2
3
4

5


6
7
8
9
10
11
12
13
14
#ifndef CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
#define CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
/**
 * @file

 *


 *
 * This header should be included @b after <functional> has been included.
 *
 * Interfaces exported in this header:
 *
 * * @c std::less<void>
 * * @c std::greater<void>
 * * @c std::less_equal<void>
 * * @c std::greater_equal<void>




>

>
>
|
<







1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
#ifndef CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
#define CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
/**
 * @file
 * @brief Implementation of C++14's transparent functors.
 *
 * This header is part of cxxomfort and should be included as part of including 
 * <tt><cxxomfort/functional.hpp></tt>. It should not need to be #included explicitly.
 * 

 *
 * Interfaces exported in this header:
 *
 * * @c std::less<void>
 * * @c std::greater<void>
 * * @c std::less_equal<void>
 * * @c std::greater_equal<void>

Changes to cxxomfort/cxxomfort/impl/14-integer_sequence.hpp.

2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
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
#define CXXOMFORT_IMPL_14_INTEGER_SEQUENCE_HPP
#include <cxxomfort/config.hpp>
/**
 * @file
 */

// room here for a possible c++03 implementation? I wish.

#if (CXXOMFORT_CXX_STD < 2011)
    #define CXXOMFORT_IMPLEMENTS_n3658 0










#elif (CXXOMFORT_CXX_STD >= 2011 || (CXXOMFORT_CXX_EMULATION==2011 && CXXO_COMPILER_SUPPORT_variadic))
    #define CXXOMFORT_IMPLEMENTS_n3658 CXXO_IMPLSTATUS_BACKPORT()
    #define CXXOMFORT_IMPLEMENTS_integer_sequence CXXOMFORT_IMPLEMENTS_n3658

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup cxx14-backports
 * @{
 */
template <typename T, T... Elems>
struct integer_sequence {
    typedef T type;
    static constexpr size_t size () { return sizeof...(Elems); }
}; 

template <typename T, size_t N, size_t ...Is>
struct make_integer_sequence 
: make_integer_sequence<T, N-1, N-1, Is...> {};

template <typename T, size_t ...Is>
struct make_integer_sequence<T, 0, Is...>
: integer_sequence<T, Is...> {};

template <std::size_t... N>
using index_sequence = integer_sequence<std::size_t, N...>;

template <std::size_t... N>
using make_index_sequence = make_integer_sequence<std::size_t, N...>;




template<class... T>
using index_sequence_for = make_index_sequence<sizeof...(T)>;


# if 0
// https://gist.github.com/sahchandler/8d13f0935a0511af8d1d/520903a0b187a87be66cf99977126cc4db4e431a

/**
 * @struct integer_sequence
 * @brief A type that packs a sequence of integers.
 * */
template <typename T, T... I> 

struct integer_sequence {
    template <T N> struct append : integer_sequence<T, I..., N> {};
    static CXXO_CONSTEXPR std::size_t size () { return sizeof...(I); }
    static const size_t _size;
    typedef append<_size> next;
    typedef T type;
}; 

template <typename T, T... I>
const size_t integer_sequence<T,I...>::_size= sizeof...(I);

template <typename T, T Index, size_t N>
struct sequence_generator {
    struct type : sequence_generator<T, Index - 1, N - 1>::type::next {};
}; 


template <class T, T Index>
struct sequence_generator<T, Index, 0ul> { 
    struct type : integer_sequence<T> {}; 
};  

template <std::size_t... I>
struct index_sequence : integer_sequence<std::size_t, I...> {};

 
template <class T, T N>
struct make_integer_sequence : sequence_generator<T, N, N>::type {};
 
template <std::size_t N>
struct make_index_sequence : make_integer_sequence<std::size_t, N> {}; 


#endif

/**
 * @}
 */

} // utility::
} // cxxomfort::


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#elif (CXXO_COMPILER_SUPPORT_integer_sequence==0)

namespace std {
    //! Brings @c integer_sequence to std.
    using cxxomfort::cxxostd::integer_sequence;
    using cxxomfort::cxxostd::index_sequence;
    using cxxomfort::cxxostd::make_integer_sequence;
    using cxxomfort::cxxostd::make_index_sequence;

} // namespace std
#endif // std using





#endif // c++11



#ifdef DOXYGEN_DOC
namespace cxxomfort { namespace cxxostd {






/**
 * @struct integer_sequence
 * @brief C++14 integer_sequence utility
 * @anchor std_integer_sequence




 * */
template <typename T, T... I> 
struct integer_sequence {
    template <T N> struct append : integer_sequence<T, I..., N> {};
    static CXXO_CONSTEXPR std::size_t size () { return sizeof...(I); }
    static const size_t _size; //< The size (length) of the sequence.
    typedef append<_size> next; //< The next subyacent sequence.
    typedef T type;
}; 














}
}

#endif

#endif









>
|
|

>

>
>
>
>
>
>
>
|



|
<











<
<
<
<
<
<
<
<



<
<

>
>
|
<
<
>

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

<
<

|
<
<
<
>

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

<





<
<
>

|
<
>






>

|

>
>
>
>
|
>





>
>
>
>
>




>
>
>
>









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









2
3
4
5
6
7
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

57
58


59
60

61
62

63
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
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
#define CXXOMFORT_IMPL_14_INTEGER_SEQUENCE_HPP
#include <cxxomfort/config.hpp>
/**
 * @file
 */

// room here for a possible c++03 implementation? I wish.

#if (CXXOMFORT_CXX_STD>= 2014 || CXXO_COMPILER_SUPPORT_integer_sequence>0)
    #define CXXOMFORT_IMPLEMENTS_n3658 CXXO_IMPLSTATUS_NATIVE()

namespace cxxomfort { namespace cxxostd {

	using std::integer_sequence;
	using std::make_integer_sequence;
	using std::index_sequence;
	using std::make_index_sequence;
	using std::index_sequence_for;
} }

#elif (CXXOMFORT_CXX_STD >= 2011)
    #define CXXOMFORT_IMPLEMENTS_n3658 CXXO_IMPLSTATUS_BACKPORT()
    #define CXXOMFORT_IMPLEMENTS_integer_sequence CXXOMFORT_IMPLEMENTS_n3658

namespace cxxomfort { namespace cxxostd {


/**
 * @ingroup cxx14-backports
 * @{
 */
template <typename T, T... Elems>
struct integer_sequence {
    typedef T type;
    static constexpr size_t size () { return sizeof...(Elems); }
}; 









template <std::size_t... N>
using index_sequence = integer_sequence<std::size_t, N...>;




template <typename I, size_t N, size_t... Next>
struct ISHelper : public ISHelper<I, N-1U, N-1U, Next...>
{ 


};








template <typename I, size_t... Next>
struct ISHelper<I, 0U, Next...> { 
	using type= integer_sequence<I, Next...>;





};




template <typename I, std::size_t N>



using make_integer_sequence = typename ISHelper<I, N>::type;






template <std::size_t N>

using make_index_sequence = typename ISHelper<std::size_t, N>::type;




template <typename... T>

using index_sequence_for = make_index_sequence<sizeof...(T)>;



/**
 * @}
 */



} }

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

	#else
namespace std {
    //! Brings @c integer_sequence to std.
    using cxxomfort::cxxostd::integer_sequence;
    using cxxomfort::cxxostd::index_sequence;
    using cxxomfort::cxxostd::make_integer_sequence;
    using cxxomfort::cxxostd::make_index_sequence;
    using cxxomfort::cxxostd::index_sequence_for;
} // namespace std
	#endif // std using

#else
	// nothing to do
    #define CXXOMFORT_IMPLEMENTS_n3658 0

#endif



#ifdef DOXYGEN_DOC
namespace cxxomfort { namespace cxxostd {

/**
 * @{
 * @ingrpup cxx14-backports
 * */

/**
 * @struct integer_sequence
 * @brief C++14 integer_sequence utility
 * @anchor std_integer_sequence
 * 
 * Given <tt>integer_sequence<type, N></tt>, it generates the 
 * object with parameter pack <tt><type, 0, 1, ..., N-1></tt>.
 * 
 * */
template <typename T, T... I> 
struct integer_sequence {
    template <T N> struct append : integer_sequence<T, I..., N> {};
    static CXXO_CONSTEXPR std::size_t size () { return sizeof...(I); }
    static const size_t _size; //< The size (length) of the sequence.
    typedef append<_size> next; //< The next subyacent sequence.
    typedef T type;
}; 

//! Helper for @c integer_sequence
template <typename T, size_t N> struct make_integer_sequence {};

//! Integer sequence of <tt>size_t</tt>.
template <size_t N> struct index_sequence : integer_sequence<size_t, N> {};

//! Helper for @c index_sequence
template <typename T, size_t N> struct make_index_sequence {};

/**
 * @}
 * */

}
}

#endif

#endif


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

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


#define CXXOMFORT_IMPLEMENTS_n4380 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_as_const CXXOMFORT_IMPLEMENTS_n4380

#include "../config.hpp"
#include <utility>
#include "../util/type_traits.hpp" // add_const

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief returns a @c const  view of object @p t . A @ref cxx17-backports .
 * @return A reference to its argument with @c const qualifier added.







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


#define CXXOMFORT_IMPLEMENTS_n4380 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_as_const CXXOMFORT_IMPLEMENTS_n4380

#include "../config.hpp"
#include <utility>
#include "../impl/07-type_traits.hpp" // add_const

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief returns a @c const  view of object @p t . A @ref cxx17-backports .
 * @return A reference to its argument with @c const qualifier added.

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

27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
 * byte |, &, ^ byte
 * byte << integer, byte >> integer
 * 
 * byte byte(char) <-- explicit
 * 
 */


#include <cxxomfort/base.hpp>
#include <cxxomfort/util/type_traits.hpp>
#include <cstring>

#if (CXXOMFORT_CXX_STD>=2017 || CXXO_COMPILER_SUPPORT_std_byte)

	#define CXXOMFORT_IMPLEMENTS_p0298r3 CXXO_IMPLSTATUS_NATIVE()

namespace cxxomfort { namespace cxxostd { 
................................................................................

namespace cxxomfort { namespace cxxostd {

#pragma pack(push,1)
struct byte {
	public:
	
	CXXO_EXPLICIT_OPERATOR(unsigned char) () const CXXO_NOEXCEPTNOTHROW {
		return v;
	}

	private:
	unsigned char v;
};
#pragma pack(pop)
................................................................................
// 
// internal checks 
// 

namespace cxxomfort { namespace cxxostd {

static_assert(sizeof(byte) == sizeof(char), "byte: sizeof check");
static_assert (cxxomfort::traits::is_integral<byte>::value==false, "byte: separate-type check");

} }

// 
// operators
// 








>

|







 







|







 







|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
 * byte |, &, ^ byte
 * byte << integer, byte >> integer
 * 
 * byte byte(char) <-- explicit
 * 
 */

#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include "../impl/07-type_traits.hpp"
#include <cstring>

#if (CXXOMFORT_CXX_STD>=2017 || CXXO_COMPILER_SUPPORT_std_byte)

	#define CXXOMFORT_IMPLEMENTS_p0298r3 CXXO_IMPLSTATUS_NATIVE()

namespace cxxomfort { namespace cxxostd { 
................................................................................

namespace cxxomfort { namespace cxxostd {

#pragma pack(push,1)
struct byte {
	public:
	
	CXXO_EXPLICIT_OPERATOR(unsigned char) () const CXXO_NOEXCEPT {
		return v;
	}

	private:
	unsigned char v;
};
#pragma pack(pop)
................................................................................
// 
// internal checks 
// 

namespace cxxomfort { namespace cxxostd {

static_assert(sizeof(byte) == sizeof(char), "byte: sizeof check");
static_assert (::cxxomfort::traits::is_integral<byte>::value==false, "byte: separate-type check");

} }

// 
// operators
// 

Added cxxomfort/cxxomfort/impl/17-invoke.hpp.

























































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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
#ifndef CXXOMFORT_IMPL_INVOKE_HPP
#define CXXOMFORT_IMPL_INVOKE_HPP
/**
 * @file cxxomfort/impl/invoke.hpp
 * @brief Implementation of std::invoke
 *
 */


#include "../config.hpp"
#include <cxxomfort/base.hpp>
#include <cxxomfort/functional.hpp>

#ifdef DOXYGEN_DOC

namespace cxxomfort {
namespace cxxostd {

/**
 * @fn invoke
 * @brief Generically invoke a function with the given arguments
 * @xrefitem std0functional "<functional> backports" "Invocation"
 *
 * 
 * */
template <typename F, typename... Args>
auto invoke(F f, Args&&... args) 
-> decltype(std::ref(f)(std::forward<Args>(args)...));

} }

#endif

#if (CXXOMFORT_CXX_STD >= 2017)
#elif (CXXOMFORT_CXX_STD >= 2011)

	#include <functional>
namespace cxxomfort {
namespace cxxostd {

template <typename F, typename... Args>
auto invoke(F f, Args&&... args) 
-> decltype(std::ref(f)(std::forward<Args>(args)...))
{
    return std::ref(f)(std::forward<Args>(args)...);
}

} } // cxxomfort::cxxostd

namespace std {
	using ::cxxomfort::cxxostd::invoke;
}

#elif (CXXO_COMPILER_SUPPORT_typeof)

/*
 * invoke (f, t1, t2, ..., tN) is, more or less:
 * 
 * * if f is function member pointer:
 *   (t1.*f)(t2, ...)
 * 
 * * elif f is data member pointer and N==1
 *   (t1.*f)
 * 
 * * else
 *   f(t1,t2, ...)
 * 
 * 
 * */
	#include <cxxomfort/utility.hpp> // declval
	#include <cxxomfort/impl/11-conditional.hpp> // conditional
	#include <cxxomfort/type_traits.hpp> 

namespace cxxomfort {
namespace cxxostd {

// invoke of something without arguments calls as a nullary

template <typename F>
CXXO_TYPEOF( std::declval<F>() () ) 
invoke (F f) {
	return std::ref(f)();
}

/*
 * invoke f with n>1 args is:
 * * (a1.f)(a2, ...) if f is a mfp
 * * (a1.*f)(a2, ...) if f is a mop
 * * f(a1, a2, ...) otherwise
 * 
 * */




template <typename F, typename A1, bool M= std::is_member_pointer<F>::value >
struct result_of_invoke1 {
	enum { mfp = std::is_member_function_pointer<F>::value , dfp = std::is_member_object_pointer<F>::value };
	typedef CXXO_TYPEOF( std::declval<F>()( std::declval<A1>() ) )
	result_type;
	
	static result_type	
	call (F f, A1 a1) {
		return f(a1);
	};
	
};

// dispatches depending on if F is a member function or member object pointer

template <typename F, typename A1, bool MF = std::is_member_function_pointer<F>::value >
struct mp_helper1 {
	typedef typename std::tr1::result_of<F(A1)>::type result_type;

	static result_type
	call (F f, A1 a1) {
		return (a1.*f)();
	}
};

template <typename F2, typename A1>
struct mp_helper1<F2,A1,false> /* object pointer*/ {
	typedef typename std::tr1::result_of<F2(A1)>::type result_type;

	static result_type
	call (F2 f, A1 a1) {
		return (a1.*f);
	}
};


template <typename F, typename A1>
struct result_of_invoke1<F,A1,true> /* member pointe */ {
	enum { mfp = std::is_member_function_pointer<F>::value , dfp = std::is_member_object_pointer<F>::value };
	typedef typename std::tr1::result_of<F(A1)>::type result_type;
	
	static result_type 
	call (F f, A1 a1) {
		return mp_helper1<F,A1>::call(f,a1);
	};
	
};


template <typename F, typename A1>
typename result_of_invoke1<F,A1>::result_type
invoke (F f, A1 a1) {
	return result_of_invoke1<F,A1>::call(f,a1);
}

// invoke (2 args)

template <typename F, typename A1, typename A2, bool M= std::is_member_pointer<F>::value>
struct result_of_invoke2 {
	enum { mfp = std::is_member_function_pointer<F>::value , dfp = std::is_member_object_pointer<F>::value };
	typedef CXXO_TYPEOF( std::declval<F>() ( std::declval<A1>() , std::declval<A2>() ) ) 
	result_type;

	static result_type	
	call (F f, A1 a1, A2 a2) {
		return f(a1,a2);
	};

};

// dispatches depending on if F is a member function or member object pointer

template <typename F, typename A1, typename A2, bool MF = std::is_member_function_pointer<F>::value >
struct mp_helper2 {
	typedef typename std::tr1::result_of<F(A1,A2)>::type result_type;

	static result_type
	call (F f, A1 a1, A2 a2) {
		return (a1.*f)(a2);
	}
};

template <typename F2, typename A1, typename A2>
struct mp_helper2<F2,A1,A2,false> /* object pointer*/ {
	typedef typename std::tr1::result_of<F2(A1,A2)>::type result_type;

	static result_type
	call (F2 f, A1 a1, A2 a2) {
		return (a1.*f)(a2);
	}
};

template <typename F, typename A1, typename A2>
struct result_of_invoke2<F,A1,A2,true> /* member pointe */ {
	enum { mfp = std::is_member_function_pointer<F>::value , dfp = std::is_member_object_pointer<F>::value };
	typedef typename std::tr1::result_of<F(A1,A2)>::type result_type;
	
	static result_type 
	call (F f, A1 a1, A2 a2) {
		return mp_helper2<F,A1,A2>::call(f,a1,a2);
	};
	
};

template <typename F, typename A1, typename A2>
typename result_of_invoke2<F,A1,A2>::result_type
invoke (F f, A1 a1, A2 a2) {
	return result_of_invoke2<F,A1,A2>::call(f,a1,a2);
}


// invoke (3 args)

template <typename F, typename A1, typename A2, typename A3, bool M= std::is_member_pointer<F>::value>
struct result_of_invoke3 {
	typedef CXXO_TYPEOF( std::declval<F>() ( std::declval<A1>() , std::declval<A2>(), std::declval<A3>() ) ) 
	result_type;

	static result_type	
	call (F f, A1 a1, A2 a2, A3 a3) {
		return f(a1,a2,a3);
	};

};

template <typename F, typename A1, typename A2, typename A3>
struct result_of_invoke3<F,A1,A2,A3,true> /* member pointe */ {
	enum { mfp = std::is_member_function_pointer<F>::value , dfp = std::is_member_object_pointer<F>::value };
	typedef typename std::tr1::result_of<F(A1,A2,A3)>::type result_type;
	
	static result_type 
	call (F f, A1 a1, A2 a2, A3 a3) {
		return (a1.*f)(a2,a3);
	};
	
};


template <typename F, typename A1, typename A2, typename A3>
typename result_of_invoke3<F,A1,A2,A3>::result_type
invoke (F f, A1 a1, A2 a2, A3 a3) {
	return result_of_invoke3<F,A1,A2,A3>::call(f,a1,a2,a3);
}


} } // cxxomfort::cxxostd

namespace std {
	using ::cxxomfort::cxxostd::invoke;
}

#else // not even typeof support - nothing to do

#endif


#endif

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

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 * @brief Implementation of std::make_from_tuple
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/tuple.hpp> // index_sequence

#if (CXXOMFORT_CXX_STD >= 2017)
#define CXXOMFORT_IMPLEMENTS_p0209 CXXO_IMPLSTATUS_NATIVE()
#elf (CXXOMFORT_CXX_STD >= 2011)
#define CXXOMFORT_IMPLEMENTS_p0209 CXXO_IMPLSTATUS_BACKPORT()
#else
#define CXXOMFORT_IMPLEMENTS_p0209 CXXO_IMPLSTATUS_EMULATION()
#endif

#define CXXOMFORT_IMPLEMENTS_make_from_tuple CXXOMFORT_IMPLEMENTS_p0209 

namespace cxxomfort {
namespace cxxostd {








|

|

|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 * @brief Implementation of std::make_from_tuple
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/tuple.hpp> // index_sequence

#if (CXXOMFORT_CXX_STD >= 2017)
	#define CXXOMFORT_IMPLEMENTS_p0209 CXXO_IMPLSTATUS_NATIVE()
#elf (CXXOMFORT_CXX_STD >= 2011)
	#define CXXOMFORT_IMPLEMENTS_p0209 CXXO_IMPLSTATUS_BACKPORT()
#else
	#define CXXOMFORT_IMPLEMENTS_p0209 CXXO_IMPLSTATUS_EMULATION()
#endif

#define CXXOMFORT_IMPLEMENTS_make_from_tuple CXXOMFORT_IMPLEMENTS_p0209 

namespace cxxomfort {
namespace cxxostd {

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

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
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
 *
 */

#include <cstring>
#include <stdexcept>
#include <algorithm>
#include <cxxomfort/impl/n3334-array_ref.hpp>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/relationals.hpp>
#include <ostream>

#define CXXOMFORT_IMPLEMENTS_n3605 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n3685 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n3762 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_string_view CXXOMFORT_IMPLEMENTS_n3685


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


//! Name for a strng view of @c char .
typedef basic_string_view<char, std::char_traits<char> > string_view;
//! Name for a string view of @c wchar_t .
typedef basic_string_view<wchar_t, std::char_traits<wchar_t> > wstring_view;
#if (CXXOMFORT_CXX_STD >= 2011)

typedef basic_string_view<char16_t> u16string_view;

typedef basic_string_view<char32_t> u32string_view;
#endif

} }


/**
 * Outputs the given string to a C++ output stream.
 * */
#if (CXXOMFORT_CXX_STD>=1997)

namespace cxxomfort { namespace cxxostd {

template <typename Ch, typename ChTraits>
std::basic_ostream<Ch, ChTraits>&
operator<<  
(std::basic_ostream<Ch, ChTraits>& os

, basic_string_view<Ch, ChTraits> const v) {
    using namespace std;
    //size_t const n= max(static_cast<size_t>(os.width()), v.size());
    //os.rdbuf()->sputn(v.data(), n);
    for (size_t i= 0; i < v.size(); ++i) { os<< v[i]; }
    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 // 1997 for operator<<


#endif







|

<







 







>

>


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

<
>


6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
...
251
252
253
254
255
256
257
258
259
260
261
262







263







264
265






266
267





268





269
270

271
272
273
 *
 */

#include <cstring>
#include <stdexcept>
#include <algorithm>
#include <cxxomfort/impl/n3334-array_ref.hpp>
#include <cxxomfort/impl/07-type_traits.hpp>
#include <cxxomfort/impl/relationals.hpp>


#define CXXOMFORT_IMPLEMENTS_n3605 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n3685 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n3762 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_string_view CXXOMFORT_IMPLEMENTS_n3685


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


//! Name for a strng view of @c char .
typedef basic_string_view<char, std::char_traits<char> > string_view;
//! Name for a string view of @c wchar_t .
typedef basic_string_view<wchar_t, std::char_traits<wchar_t> > wstring_view;
#if (CXXOMFORT_CXX_STD >= 2011)
//! Name for a string view of @c char16_t .
typedef basic_string_view<char16_t> u16string_view;
//! Name for a string view of @c char32_t .
typedef basic_string_view<char32_t> u32string_view;
#endif







#if (CXXOMFORT_CXX_STD >= 2020)







//! Name for a string view of @c char8_t .
typedef basic_string_view<char8_t> u8string_view;






#endif






} } // cxxomfort::cxxostd








// ostream operators are in ostream.hpp.

#endif

Changes to cxxomfort/cxxomfort/impl/20-endian.hpp.

1
2
3
4
5
6
7
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
57
58
59
..
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
#ifndef CXXOMFORT_IMPL_20_ENDIAN_HPP
#define CXXOMFORT_IMPL_20_ENDIAN_HPP
/**
 * @file 
 * @brief Implementation of std::endian
 * */
#include <cxxomfort/config.hpp>
#include <cxxomfort/impl/typesafe_enum-core.hpp>
























#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
#include <endian.h>
#endif
























#define CXXOMFORT_IMPLEMENTS_p0463r1 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_endian CXXOMFORT_IMPLEMENTS_p0463r1

namespace cxxomfort { namespace cxxostd { 
namespace type_traits {



namespace detail {







union endian_tester {
    uint32_t   n;
    uint8_t    p[4];
};





const endian_tester sample = {0x01020304}; // this initializes .n


struct endian_finally {
    enum { 
        little = 0x00000001, 
        big    = 0x01000000,
        other  = 0x00000000 


    };
};



} // detail



#if 0 && (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC || defined(_WIN32))
    #define CXXO_endian_members() little = 0,  big = 1,  native = little


#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, < 406))
    #define CXXO_endian_members() little = __LITTLE_ENDIAN, big = __BIG_ENDIAN, native = __BYTE_ORDER


#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, >= 406))
    #define CXXO_endian_members()    little = __ORDER_LITTLE_ENDIAN__, big    = __ORDER_BIG_ENDIAN__,  native = __BYTE_ORDER__



#else
    #define CXXO_endian_members()  little = detail::endian_finally::little, big = detail::endian_finally::big , native = 0xffffffffUL & 0x1UL






#endif



/**
 * @brief Endianness enumeration for C++.
 * @ingroup cxx17-backports
................................................................................
 * for a system's endianness. The enumeration has three values: @c little , 
 * @c big and @c native . @c native will equal one of the other two 
 * when the system has that endianness, or will equal none of them 
 * in a system with a different (non-little, non-big) endianness.
 * 
 * */

#if (CXXOMFORT_CXX_STD>=2011)
enum class endian { CXXO_endian_members() };
#else

struct endian {
	enum type { CXXO_endian_members() };
};


#endif
#undef CXXO_endian_members

} // type_traits
}} // cxxomfort::std

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

    #if (CXXO_COMPILER_SUPPORT_cstd_endian>0)
    #else
    namespace std { 
        //! Using in namespace std;
        using cxxomfort::cxxostd::type_traits::endian;
    }
    #endif
#endif // no std using


#endif







<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




>
>
>

>
>

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

|
<
>
>

<
>
>
>
>
>
>

<
<
<
<
>
>
>
>

<
>

<
<
<
<
<
>
>
|
<

>

<
>


<
<
>

<
<
>

<
<

>
>
|
<
>
>
>
>
>
>







 







<
<
<

<
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
1
2
3
4
5
6
7

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
57
58
59

60
61

62
63
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
101
102
103
104
105
106
107
108
...
114
115
116
117
118
119
120



121





122



















#ifndef CXXOMFORT_IMPL_20_ENDIAN_HPP
#define CXXOMFORT_IMPL_20_ENDIAN_HPP
/**
 * @file 
 * @brief Implementation of std::endian
 * */
#include <cxxomfort/config.hpp>



namespace cxxomfort { namespace cxxostd {
namespace detail {

	union endian_tester {
		uint32_t   n;
		uint8_t    p[4];
	};

	const endian_tester sample = {0x01020304}; // this initializes .n

	struct endian_finally {
		enum { 
			little = 0x00000001, 
			big    = 0x01000000,
			other  = 0x00000000 
		};
	};


} // detail
} } 

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
#include <endian.h>
#endif

// 
// values that describe endianness
// 

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && defined(_WIN32))
    #define CXXO_endian_members() little = 0,  big = 1,  native = little

#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, < 406))
    #define CXXO_endian_members() little = __LITTLE_ENDIAN, big = __BIG_ENDIAN, native = __BYTE_ORDER

#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, >= 406))
    #define CXXO_endian_members()    little = __ORDER_LITTLE_ENDIAN__, big    = __ORDER_BIG_ENDIAN__,  native = __BYTE_ORDER__

#else
    #define CXXO_endian_members()  little = detail::endian_finally::little, big = detail::endian_finally::big , native = 0xffffffffUL & 0x1UL
#endif

// 
// endian
// 

#if (CXXOMFORT_CXX_STD >= 2020 || CXXOMFORT_CXX_EMULATION >= 2020 || CXXO_COMPILER_SUPPORT_cstd_endian)
	// nothing to do
	#define CXXOMFORT_IMPLEMENTS_p0463r1 CXXO_IMPLSTATUS_NATIVE()


namespace cxxomfort { namespace cxxostd {

	using std::endian;
} }


#elif (CXXOMFORT_CXX_STD >= 2011)
	#define CXXOMFORT_IMPLEMENTS_p0463r1 CXXO_IMPLSTATUS_BACKPORT()
	#define CXXOMFORT_USING_endian 1
namespace cxxomfort { namespace cxxostd {
	enum class endian { CXXO_endian_members() };
} }





#else
	#define CXXOMFORT_IMPLEMENTS_p0463r1 CXXO_IMPLSTATUS_EMULATION()
	#define CXXOMFORT_USING_endian 1
	#include <cxxomfort/impl/typesafe_enum-core.hpp>


namespace cxxomfort { namespace cxxostd {






struct myendian {
	enum type { CXXO_endian_members() };
};


typedef cxxomfort::impl::typesafe_enum<myendian> endian;


} }




#endif



#define CXXOMFORT_IMPLEMENTS_endian CXXOMFORT_IMPLEMENTS_p0463r1




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

namespace std { 
	//! Using in namespace std;
	using cxxomfort::cxxostd::endian;
}
	#endif // no std using

#endif



/**
 * @brief Endianness enumeration for C++.
 * @ingroup cxx17-backports
................................................................................
 * for a system's endianness. The enumeration has three values: @c little , 
 * @c big and @c native . @c native will equal one of the other two 
 * when the system has that endianness, or will equal none of them 
 * in a system with a different (non-little, non-big) endianness.
 * 
 * */










#endif



















Changes to cxxomfort/cxxomfort/impl/character.hpp.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 * @file
 * @brief Meta information for character types.
 * 
 * Utility file similar to @c functionmeta.hpp .
 * 
 * */
#include <cstddef>
#include <cxxomfort/util/type_traits.hpp>
//#include <cxxomfort/type_traits.hpp>

namespace cxxomfort{ namespace impl{ namespace type_traits {

namespace ct = cxxomfort::traits;

//! Check if a type T is one of C++'s native character types.







|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 * @file
 * @brief Meta information for character types.
 * 
 * Utility file similar to @c functionmeta.hpp .
 * 
 * */
#include <cstddef>
#include <cxxomfort/impl/07-type_traits.hpp>
//#include <cxxomfort/type_traits.hpp>

namespace cxxomfort{ namespace impl{ namespace type_traits {

namespace ct = cxxomfort::traits;

//! Check if a type T is one of C++'s native character types.

Changes to cxxomfort/cxxomfort/impl/foreach_gcc.hpp.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

//#include <functional>
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/util/meta.hpp>
//#include <cxxomfort/using.hpp>
//#include <cxxomfort/memory.hpp> // alignof, aligned_storage

namespace cxxomfort {
namespace impl {








|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

//#include <functional>
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/impl/07-type_traits.hpp>
#include <cxxomfort/util/meta.hpp>
//#include <cxxomfort/using.hpp>
//#include <cxxomfort/memory.hpp> // alignof, aligned_storage

namespace cxxomfort {
namespace impl {

Changes to cxxomfort/cxxomfort/impl/hash.hpp.

1
2
3
4
5
6

7

8
9
10
11
12
13
14
..
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
57
#ifndef CXXOMFORT_IMPL_HASH_HPP
#define CXXOMFORT_IMPL_HASH_HPP

#include <cxxomfort/config.hpp>
#include CXXO_INCLUDE_SYS(functional)
#include <cxxomfort/functional.hpp>

#include <cxxomfort/util/type_traits.hpp> // is_enum


/**
 * @file
 * @brief cxxomfort "fix" helper for <tt>std::hash</tt>.
 * 
 * */

................................................................................
 * @xrefitem std0functional "<functional>" "Non-backport Assists"
 * @see 
 * * Documentation for C++ @c std::hash .
 * 
 */
template <typename T, typename = void >
struct hash
: public CXXO_STDTR1_NAME()::hash<T> {
    enum { uses_std = true };
};

/**
 * @brief Specialization of @c std::hash for @c enum types, as per C++ 14.
 * @note Since pre-C++17 @c hash is not specializable generically, this 
 * is implemented through another facility ( cxxomfort::fix::hash ).
 * 
 * */
template <typename E>
struct hash<E , typename std::enable_if< std::is_enum<E>::value>::type >
: public hash< typename ::std::underlying_type<E>::type> {
    enum { uses_std = false };
};


} }

#endif

#endif







>
|
>







 







|











|










1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
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
57
58
59
#ifndef CXXOMFORT_IMPL_HASH_HPP
#define CXXOMFORT_IMPL_HASH_HPP

#include <cxxomfort/config.hpp>
#include CXXO_INCLUDE_SYS(functional)
#include <cxxomfort/functional.hpp>
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/impl/07-type_traits.hpp> // is_enum
#include <cxxomfort/impl/11-underlying_type.hpp>

/**
 * @file
 * @brief cxxomfort "fix" helper for <tt>std::hash</tt>.
 * 
 * */

................................................................................
 * @xrefitem std0functional "<functional>" "Non-backport Assists"
 * @see 
 * * Documentation for C++ @c std::hash .
 * 
 */
template <typename T, typename = void >
struct hash
: public std::hash<T> {
    enum { uses_std = true };
};

/**
 * @brief Specialization of @c std::hash for @c enum types, as per C++ 14.
 * @note Since pre-C++17 @c hash is not specializable generically, this 
 * is implemented through another facility ( cxxomfort::fix::hash ).
 * 
 * */
template <typename E>
struct hash<E , typename std::enable_if< std::is_enum<E>::value>::type >
: public hash< typename std::underlying_type<E>::type> {
    enum { uses_std = false };
};


} }

#endif

#endif

Changes to cxxomfort/cxxomfort/impl/metaprogramming.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_IMPL_METAPROGRAMMING_HPP
#define CXXOMFORT_IMPL_METAPROGRAMMING_HPP

#include <cxxomfort/base.hpp>
#include <cxxomfort/util/type_traits.hpp>
//#include <type_traits>
#include <cxxomfort/type_traits.hpp>
#if (CXXOMFORT_CXX_STD>=1997)

namespace cxxomfort {
namespace traits {





|







1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_IMPL_METAPROGRAMMING_HPP
#define CXXOMFORT_IMPL_METAPROGRAMMING_HPP

#include <cxxomfort/base.hpp>
#include <cxxomfort/impl/07-type_traits.hpp>
//#include <type_traits>
#include <cxxomfort/type_traits.hpp>
#if (CXXOMFORT_CXX_STD>=1997)

namespace cxxomfort {
namespace traits {

Changes to cxxomfort/cxxomfort/impl/n3334-array_ref.hpp.

118
119
120
121
122
123
124
125
126


127
128
129
130
131
132
133
	constexpr array_ref () noexcept = default; //!< trivial, empty array_ref.
	constexpr array_ref (array_ref const&) noexcept = default; // //!< trivial copy-ctor.
	constexpr array_ref& operator= (array_ref const&) noexcept = default; //!< trivial assignment operator
#endif
#if (CXXOMFORT_CXX_STD>=2011)
    constexpr array_ref () noexcept = default;
    constexpr array_ref (array_ref const&) noexcept = default;
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_COMPILER_VERSION < 700)
    array_ref& operator= (array_ref const&) noexcept = default;


    #else
    constexpr array_ref& operator= (array_ref const&) noexcept = default;    
    #endif
#else // pre-c++11 constructors
    array_ref () CXXO_NOEXCEPTNOTHROW 
    : ptr_(nullptr), len_(0) 
    {}







|

>
>







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
	constexpr array_ref () noexcept = default; //!< trivial, empty array_ref.
	constexpr array_ref (array_ref const&) noexcept = default; // //!< trivial copy-ctor.
	constexpr array_ref& operator= (array_ref const&) noexcept = default; //!< trivial assignment operator
#endif
#if (CXXOMFORT_CXX_STD>=2011)
    constexpr array_ref () noexcept = default;
    constexpr array_ref (array_ref const&) noexcept = default;
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_COMPILER_VERSION < 700) 
    array_ref& operator= (array_ref const&) noexcept = default;
    #elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG && CXXOMFORT_COMPILER_VERSION < 500)
	array_ref& operator= (array_ref const&) = default;
    #else
    constexpr array_ref& operator= (array_ref const&) noexcept = default;    
    #endif
#else // pre-c++11 constructors
    array_ref () CXXO_NOEXCEPTNOTHROW 
    : ptr_(nullptr), len_(0) 
    {}

Changes to cxxomfort/cxxomfort/impl/p0792r0-function_ref.hpp.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#define CXXOMFORT_IMPLEMENTS_p0792 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_function_ref CXXOMFORT_IMPLEMENTS_p0792


#include <functional> // std::reference_wrapper, etc
#include <utility> // forward, move, etc
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp>

namespace cxxomfort { namespace impl {

template <typename Signature> class function_ref;









|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#define CXXOMFORT_IMPLEMENTS_p0792 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_function_ref CXXOMFORT_IMPLEMENTS_p0792


#include <functional> // std::reference_wrapper, etc
#include <utility> // forward, move, etc
#include <cxxomfort/impl/07-type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp>

namespace cxxomfort { namespace impl {

template <typename Signature> class function_ref;


Deleted cxxomfort/cxxomfort/impl/pstdint.h.

1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
/*  A portable stdint.h
 ****************************************************************************
 *  BSD License:
 ****************************************************************************
 *
 *  Copyright (c) 2005-2016 Paul Hsieh
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. The name of the author may not be used to endorse or promote products
 *     derived from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************
 *
 *  Version 0.1.15.4
 *
 *  The ANSI C standard committee, for the C99 standard, specified the
 *  inclusion of a new standard include file called stdint.h.  This is
 *  a very useful and long desired include file which contains several
 *  very precise definitions for integer scalar types that is
 *  critically important for making portable several classes of
 *  applications including cryptography, hashing, variable length
 *  integer libraries and so on.  But for most developers its likely
 *  useful just for programming sanity.
 *
 *  The problem is that some compiler vendors chose to ignore the C99
 *  standard and some older compilers have no opportunity to be updated.
 *  Because of this situation, simply including stdint.h in your code
 *  makes it unportable.
 *
 *  So that's what this file is all about.  Its an attempt to build a
 *  single universal include file that works on as many platforms as
 *  possible to deliver what stdint.h is supposed to.  Even compilers
 *  that already come with stdint.h can use this file instead without
 *  any loss of functionality.  A few things that should be noted about
 *  this file:
 *
 *    1) It is not guaranteed to be portable and/or present an identical
 *       interface on all platforms.  The extreme variability of the
 *       ANSI C standard makes this an impossibility right from the
 *       very get go. Its really only meant to be useful for the vast
 *       majority of platforms that possess the capability of
 *       implementing usefully and precisely defined, standard sized
 *       integer scalars.  Systems which are not intrinsically 2s
 *       complement may produce invalid constants.
 *
 *    2) There is an unavoidable use of non-reserved symbols.
 *
 *    3) Other standard include files are invoked.
 *
 *    4) This file may come in conflict with future platforms that do
 *       include stdint.h.  The hope is that one or the other can be
 *       used with no real difference.
 *
 *    5) In the current version, if your platform can't represent
 *       int32_t, int16_t and int8_t, it just dumps out with a compiler
 *       error.
 *
 *    6) 64 bit integers may or may not be defined.  Test for their
 *       presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
 *       Note that this is different from the C99 specification which
 *       requires the existence of 64 bit support in the compiler.  If
 *       this is not defined for your platform, yet it is capable of
 *       dealing with 64 bits then it is because this file has not yet
 *       been extended to cover all of your system's capabilities.
 *
 *    7) (u)intptr_t may or may not be defined.  Test for its presence
 *       with the test: #ifdef PTRDIFF_MAX.  If this is not defined
 *       for your platform, then it is because this file has not yet
 *       been extended to cover all of your system's capabilities, not
 *       because its optional.
 *
 *    8) The following might not been defined even if your platform is
 *       capable of defining it:
 *
 *       WCHAR_MIN
 *       WCHAR_MAX
 *       (u)int64_t
 *       PTRDIFF_MIN
 *       PTRDIFF_MAX
 *       (u)intptr_t
 *
 *    9) The following have not been defined:
 *
 *       WINT_MIN
 *       WINT_MAX
 *
 *   10) The criteria for defining (u)int_least(*)_t isn't clear,
 *       except for systems which don't have a type that precisely
 *       defined 8, 16, or 32 bit types (which this include file does
 *       not support anyways). Default definitions have been given.
 *
 *   11) The criteria for defining (u)int_fast(*)_t isn't something I
 *       would trust to any particular compiler vendor or the ANSI C
 *       committee.  It is well known that "compatible systems" are
 *       commonly created that have very different performance
 *       characteristics from the systems they are compatible with,
 *       especially those whose vendors make both the compiler and the
 *       system.  Default definitions have been given, but its strongly
 *       recommended that users never use these definitions for any
 *       reason (they do *NOT* deliver any serious guarantee of
 *       improved performance -- not in this file, nor any vendor's
 *       stdint.h).
 *
 *   12) The following macros:
 *
 *       PRINTF_INTMAX_MODIFIER
 *       PRINTF_INT64_MODIFIER
 *       PRINTF_INT32_MODIFIER
 *       PRINTF_INT16_MODIFIER
 *       PRINTF_LEAST64_MODIFIER
 *       PRINTF_LEAST32_MODIFIER
 *       PRINTF_LEAST16_MODIFIER
 *       PRINTF_INTPTR_MODIFIER
 *
 *       are strings which have been defined as the modifiers required
 *       for the "d", "u" and "x" printf formats to correctly output
 *       (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
 *       (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
 *       PRINTF_INTPTR_MODIFIER is not defined for some systems which
 *       provide their own stdint.h.  PRINTF_INT64_MODIFIER is not
 *       defined if INT64_MAX is not defined.  These are an extension
 *       beyond what C99 specifies must be in stdint.h.
 *
 *       In addition, the following macros are defined:
 *
 *       PRINTF_INTMAX_HEX_WIDTH
 *       PRINTF_INT64_HEX_WIDTH
 *       PRINTF_INT32_HEX_WIDTH
 *       PRINTF_INT16_HEX_WIDTH
 *       PRINTF_INT8_HEX_WIDTH
 *       PRINTF_INTMAX_DEC_WIDTH
 *       PRINTF_INT64_DEC_WIDTH
 *       PRINTF_INT32_DEC_WIDTH
 *       PRINTF_INT16_DEC_WIDTH
 *       PRINTF_UINT8_DEC_WIDTH
 *       PRINTF_UINTMAX_DEC_WIDTH
 *       PRINTF_UINT64_DEC_WIDTH
 *       PRINTF_UINT32_DEC_WIDTH
 *       PRINTF_UINT16_DEC_WIDTH
 *       PRINTF_UINT8_DEC_WIDTH
 *
 *       Which specifies the maximum number of characters required to
 *       print the number of that type in either hexadecimal or decimal.
 *       These are an extension beyond what C99 specifies must be in
 *       stdint.h.
 *
 *  Compilers tested (all with 0 warnings at their highest respective
 *  settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
 *  bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
 *  .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
 *
 *  This file should be considered a work in progress.  Suggestions for
 *  improvements, especially those which increase coverage are strongly
 *  encouraged.
 *
 *  Acknowledgements
 *
 *  The following people have made significant contributions to the
 *  development and testing of this file:
 *
 *  Chris Howie
 *  John Steele Scott
 *  Dave Thorup
 *  John Dill
 *  Florian Wobbe
 *  Christopher Sean Morrison
 *  Mikkel Fahnoe Jorgensen
 *
 */

#include <stddef.h>
#include <limits.h>
#include <signal.h>

/*
 *  For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
 *  do nothing else.  On the Mac OS X version of gcc this is _STDINT_H_.
 */

#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
#include <stdint.h>
#define _PSTDINT_H_INCLUDED
# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "l"
#  endif
#  ifndef PRINTF_INT32_MODIFIER
#   define PRINTF_INT32_MODIFIER ""
#  endif
# else
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
#  ifndef PRINTF_INT32_MODIFIER
#   if (UINT_MAX == UINT32_MAX)
#    define PRINTF_INT32_MODIFIER ""
#   else
#    define PRINTF_INT32_MODIFIER "l"
#   endif
#  endif
# endif
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER "h"
# endif
# ifndef PRINTF_INTMAX_MODIFIER
#  define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INT64_HEX_WIDTH
#  define PRINTF_INT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_UINT64_HEX_WIDTH
#  define PRINTF_UINT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_INT32_HEX_WIDTH
#  define PRINTF_INT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_UINT32_HEX_WIDTH
#  define PRINTF_UINT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_INT16_HEX_WIDTH
#  define PRINTF_INT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_UINT16_HEX_WIDTH
#  define PRINTF_UINT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_INT8_HEX_WIDTH
#  define PRINTF_INT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_UINT8_HEX_WIDTH
#  define PRINTF_UINT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_INT64_DEC_WIDTH
#  define PRINTF_INT64_DEC_WIDTH "19"
# endif
# ifndef PRINTF_UINT64_DEC_WIDTH
#  define PRINTF_UINT64_DEC_WIDTH "20"
# endif
# ifndef PRINTF_INT32_DEC_WIDTH
#  define PRINTF_INT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_UINT32_DEC_WIDTH
#  define PRINTF_UINT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_INT16_DEC_WIDTH
#  define PRINTF_INT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_UINT16_DEC_WIDTH
#  define PRINTF_UINT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_INT8_DEC_WIDTH
#  define PRINTF_INT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_UINT8_DEC_WIDTH
#  define PRINTF_UINT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_UINTMAX_HEX_WIDTH
#  define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif
# ifndef PRINTF_UINTMAX_DEC_WIDTH
#  define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif

/*
 *  Something really weird is going on with Open Watcom.  Just pull some of
 *  these duplicated definitions from Open Watcom's stdint.h file for now.
 */

# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
#  if !defined (INT64_C)
#   define INT64_C(x)   (x + (INT64_MAX - INT64_MAX))
#  endif
#  if !defined (UINT64_C)
#   define UINT64_C(x)  (x + (UINT64_MAX - UINT64_MAX))
#  endif
#  if !defined (INT32_C)
#   define INT32_C(x)   (x + (INT32_MAX - INT32_MAX))
#  endif
#  if !defined (UINT32_C)
#   define UINT32_C(x)  (x + (UINT32_MAX - UINT32_MAX))
#  endif
#  if !defined (INT16_C)
#   define INT16_C(x)   (x)
#  endif
#  if !defined (UINT16_C)
#   define UINT16_C(x)  (x)
#  endif
#  if !defined (INT8_C)
#   define INT8_C(x)   (x)
#  endif
#  if !defined (UINT8_C)
#   define UINT8_C(x)  (x)
#  endif
#  if !defined (UINT64_MAX)
#   define UINT64_MAX  18446744073709551615ULL
#  endif
#  if !defined (INT64_MAX)
#   define INT64_MAX  9223372036854775807LL
#  endif
#  if !defined (UINT32_MAX)
#   define UINT32_MAX  4294967295UL
#  endif
#  if !defined (INT32_MAX)
#   define INT32_MAX  2147483647L
#  endif
#  if !defined (INTMAX_MAX)
#   define INTMAX_MAX INT64_MAX
#  endif
#  if !defined (INTMAX_MIN)
#   define INTMAX_MIN INT64_MIN
#  endif
# endif
#endif

/*
 *  I have no idea what is the truly correct thing to do on older Solaris.
 *  From some online discussions, this seems to be what is being
 *  recommended.  For people who actually are developing on older Solaris,
 *  what I would like to know is, does this define all of the relevant
 *  macros of a complete stdint.h?  Remember, in pstdint.h 64 bit is
 *  considered optional.
 */

#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
#include <sys/inttypes.h>
#define _PSTDINT_H_INCLUDED
#endif

#ifndef _PSTDINT_H_INCLUDED
#define _PSTDINT_H_INCLUDED

#ifndef SIZE_MAX
# define SIZE_MAX (~(size_t)0)
#endif

/*
 *  Deduce the type assignments from limits.h under the assumption that
 *  integer sizes in bits are powers of 2, and follow the ANSI
 *  definitions.
 */

#ifndef UINT8_MAX
# define UINT8_MAX 0xff
#endif
#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
    typedef unsigned char uint8_t;
#   define UINT8_C(v) ((uint8_t) v)
# else
#   error "Platform not supported"
# endif
#endif

#ifndef INT8_MAX
# define INT8_MAX 0x7f
#endif
#ifndef INT8_MIN
# define INT8_MIN INT8_C(0x80)
#endif
#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
    typedef signed char int8_t;
#   define INT8_C(v) ((int8_t) v)
# else
#   error "Platform not supported"
# endif
#endif

#ifndef UINT16_MAX
# define UINT16_MAX 0xffff
#endif
#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
  typedef unsigned int uint16_t;
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER ""
# endif
# define UINT16_C(v) ((uint16_t) (v))
#elif (USHRT_MAX == UINT16_MAX)
  typedef unsigned short uint16_t;
# define UINT16_C(v) ((uint16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif

#ifndef INT16_MAX
# define INT16_MAX 0x7fff
#endif
#ifndef INT16_MIN
# define INT16_MIN INT16_C(0x8000)
#endif
#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
  typedef signed int int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER ""
# endif
#elif (SHRT_MAX == INT16_MAX)
  typedef signed short int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif

#ifndef UINT32_MAX
# define UINT32_MAX (0xffffffffUL)
#endif
#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
  typedef unsigned long uint32_t;
# define UINT32_C(v) v ## UL
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER "l"
# endif
#elif (UINT_MAX == UINT32_MAX)
  typedef unsigned int uint32_t;
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
# define UINT32_C(v) v ## U
#elif (USHRT_MAX == UINT32_MAX)
  typedef unsigned short uint32_t;
# define UINT32_C(v) ((unsigned short) (v))
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif

#ifndef INT32_MAX
# define INT32_MAX (0x7fffffffL)
#endif
#ifndef INT32_MIN
# define INT32_MIN INT32_C(0x80000000)
#endif
#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
  typedef signed long int32_t;
# define INT32_C(v) v ## L
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER "l"
# endif
#elif (INT_MAX == INT32_MAX)
  typedef signed int int32_t;
# define INT32_C(v) v
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
#elif (SHRT_MAX == INT32_MAX)
  typedef signed short int32_t;
# define INT32_C(v) ((short) (v))
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif

/*
 *  The macro stdint_int64_defined is temporarily used to record
 *  whether or not 64 integer support is available.  It must be
 *  defined for any 64 integer extensions for new platforms that are
 *  added.
 */

#undef stdint_int64_defined
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
#  define stdint_int64_defined
   typedef long long int64_t;
   typedef unsigned long long uint64_t;
#  define UINT64_C(v) v ## ULL
#  define  INT64_C(v) v ## LL
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
# endif
#endif

#if !defined (stdint_int64_defined)
# if defined(__GNUC__) && !defined(vxWorks)
#  define stdint_int64_defined
   __extension__ typedef long long int64_t;
   __extension__ typedef unsigned long long uint64_t;
#  define UINT64_C(v) v ## ULL
#  define  INT64_C(v) v ## LL
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
#  define stdint_int64_defined
   typedef long long int64_t;
   typedef unsigned long long uint64_t;
#  define UINT64_C(v) v ## ULL
#  define  INT64_C(v) v ## LL
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
#  define stdint_int64_defined
   typedef __int64 int64_t;
   typedef unsigned __int64 uint64_t;
#  define UINT64_C(v) v ## UI64
#  define  INT64_C(v) v ## I64
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "I64"
#  endif
# endif
#endif

#if !defined (LONG_LONG_MAX) && defined (INT64_C)
# define LONG_LONG_MAX INT64_C (9223372036854775807)
#endif
#ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
#endif

#if !defined (INT64_MAX) && defined (INT64_C)
# define INT64_MAX INT64_C (9223372036854775807)
#endif
#if !defined (INT64_MIN) && defined (INT64_C)
# define INT64_MIN INT64_C (-9223372036854775808)
#endif
#if !defined (UINT64_MAX) && defined (INT64_C)
# define UINT64_MAX UINT64_C (18446744073709551615)
#endif

/*
 *  Width of hexadecimal for number field.
 */

#ifndef PRINTF_INT64_HEX_WIDTH
# define PRINTF_INT64_HEX_WIDTH "16"
#endif
#ifndef PRINTF_INT32_HEX_WIDTH
# define PRINTF_INT32_HEX_WIDTH "8"
#endif
#ifndef PRINTF_INT16_HEX_WIDTH
# define PRINTF_INT16_HEX_WIDTH "4"
#endif
#ifndef PRINTF_INT8_HEX_WIDTH
# define PRINTF_INT8_HEX_WIDTH "2"
#endif
#ifndef PRINTF_INT64_DEC_WIDTH
# define PRINTF_INT64_DEC_WIDTH "19"
#endif
#ifndef PRINTF_INT32_DEC_WIDTH
# define PRINTF_INT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_INT16_DEC_WIDTH
# define PRINTF_INT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_INT8_DEC_WIDTH
# define PRINTF_INT8_DEC_WIDTH "3"
#endif
#ifndef PRINTF_UINT64_DEC_WIDTH
# define PRINTF_UINT64_DEC_WIDTH "20"
#endif
#ifndef PRINTF_UINT32_DEC_WIDTH
# define PRINTF_UINT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_UINT16_DEC_WIDTH
# define PRINTF_UINT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_UINT8_DEC_WIDTH
# define PRINTF_UINT8_DEC_WIDTH "3"
#endif

/*
 *  Ok, lets not worry about 128 bit integers for now.  Moore's law says
 *  we don't need to worry about that until about 2040 at which point
 *  we'll have bigger things to worry about.
 */

#ifdef stdint_int64_defined
  typedef int64_t intmax_t;
  typedef uint64_t uintmax_t;
# define  INTMAX_MAX   INT64_MAX
# define  INTMAX_MIN   INT64_MIN
# define UINTMAX_MAX  UINT64_MAX
# define UINTMAX_C(v) UINT64_C(v)
# define  INTMAX_C(v)  INT64_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
#   define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
# endif
#else
  typedef int32_t intmax_t;
  typedef uint32_t uintmax_t;
# define  INTMAX_MAX   INT32_MAX
# define UINTMAX_MAX  UINT32_MAX
# define UINTMAX_C(v) UINT32_C(v)
# define  INTMAX_C(v)  INT32_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
#   define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
# endif
#endif

/*
 *  Because this file currently only supports platforms which have
 *  precise powers of 2 as bit sizes for the default integers, the
 *  least definitions are all trivial.  Its possible that a future
 *  version of this file could have different definitions.
 */

#ifndef stdint_least_defined
  typedef   int8_t   int_least8_t;
  typedef  uint8_t  uint_least8_t;
  typedef  int16_t  int_least16_t;
  typedef uint16_t uint_least16_t;
  typedef  int32_t  int_least32_t;
  typedef uint32_t uint_least32_t;
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
# define  UINT_LEAST8_MAX  UINT8_MAX
# define   INT_LEAST8_MAX   INT8_MAX
# define UINT_LEAST16_MAX UINT16_MAX
# define  INT_LEAST16_MAX  INT16_MAX
# define UINT_LEAST32_MAX UINT32_MAX
# define  INT_LEAST32_MAX  INT32_MAX
# define   INT_LEAST8_MIN   INT8_MIN
# define  INT_LEAST16_MIN  INT16_MIN
# define  INT_LEAST32_MIN  INT32_MIN
# ifdef stdint_int64_defined
    typedef  int64_t  int_least64_t;
    typedef uint64_t uint_least64_t;
#   define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
#   define UINT_LEAST64_MAX UINT64_MAX
#   define  INT_LEAST64_MAX  INT64_MAX
#   define  INT_LEAST64_MIN  INT64_MIN
# endif
#endif
#undef stdint_least_defined

/*
 *  The ANSI C committee pretending to know or specify anything about
 *  performance is the epitome of misguided arrogance.  The mandate of
 *  this file is to *ONLY* ever support that absolute minimum
 *  definition of the fast integer types, for compatibility purposes.
 *  No extensions, and no attempt to suggest what may or may not be a
 *  faster integer type will ever be made in this file.  Developers are
 *  warned to stay away from these types when using this or any other
 *  stdint.h.
 */

typedef   int_least8_t   int_fast8_t;
typedef  uint_least8_t  uint_fast8_t;
typedef  int_least16_t  int_fast16_t;
typedef uint_least16_t uint_fast16_t;
typedef  int_least32_t  int_fast32_t;
typedef uint_least32_t uint_fast32_t;
#define  UINT_FAST8_MAX  UINT_LEAST8_MAX
#define   INT_FAST8_MAX   INT_LEAST8_MAX
#define UINT_FAST16_MAX UINT_LEAST16_MAX
#define  INT_FAST16_MAX  INT_LEAST16_MAX
#define UINT_FAST32_MAX UINT_LEAST32_MAX
#define  INT_FAST32_MAX  INT_LEAST32_MAX
#define   INT_FAST8_MIN   INT_LEAST8_MIN
#define  INT_FAST16_MIN  INT_LEAST16_MIN
#define  INT_FAST32_MIN  INT_LEAST32_MIN
#ifdef stdint_int64_defined
  typedef  int_least64_t  int_fast64_t;
  typedef uint_least64_t uint_fast64_t;
# define UINT_FAST64_MAX UINT_LEAST64_MAX
# define  INT_FAST64_MAX  INT_LEAST64_MAX
# define  INT_FAST64_MIN  INT_LEAST64_MIN
#endif

#undef stdint_int64_defined

/*
 *  Whatever piecemeal, per compiler thing we can do about the wchar_t
 *  type limits.
 */

#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
# include <wchar.h>
# ifndef WCHAR_MIN
#  define WCHAR_MIN 0
# endif
# ifndef WCHAR_MAX
#  define WCHAR_MAX ((wchar_t)-1)
# endif
#endif

/*
 *  Whatever piecemeal, per compiler/platform thing we can do about the
 *  (u)intptr_t types and limits.
 */

#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
# define STDINT_H_UINTPTR_T_DEFINED
#endif

#ifndef STDINT_H_UINTPTR_T_DEFINED
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
#  define stdint_intptr_bits 64
# elif defined (__WATCOMC__) || defined (__TURBOC__)
#  if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
#    define stdint_intptr_bits 16
#  else
#    define stdint_intptr_bits 32
#  endif
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
#  define stdint_intptr_bits 32
# elif defined (__INTEL_COMPILER)
/* TODO -- what did Intel do about x86-64? */
# else
/* #error "This platform might not be supported yet" */
# endif

# ifdef stdint_intptr_bits
#  define stdint_intptr_glue3_i(a,b,c)  a##b##c
#  define stdint_intptr_glue3(a,b,c)    stdint_intptr_glue3_i(a,b,c)
#  ifndef PRINTF_INTPTR_MODIFIER
#    define PRINTF_INTPTR_MODIFIER      stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
#  endif
#  ifndef PTRDIFF_MAX
#    define PTRDIFF_MAX                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
#  endif
#  ifndef PTRDIFF_MIN
#    define PTRDIFF_MIN                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
#  endif
#  ifndef UINTPTR_MAX
#    define UINTPTR_MAX                 stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
#  endif
#  ifndef INTPTR_MAX
#    define INTPTR_MAX                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
#  endif
#  ifndef INTPTR_MIN
#    define INTPTR_MIN                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
#  endif
#  ifndef INTPTR_C
#    define INTPTR_C(x)                 stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
#  endif
#  ifndef UINTPTR_C
#    define UINTPTR_C(x)                stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
#  endif
  typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
  typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t)  intptr_t;
# else
/* TODO -- This following is likely wrong for some platforms, and does
   nothing for the definition of uintptr_t. */
  typedef ptrdiff_t intptr_t;
# endif
# define STDINT_H_UINTPTR_T_DEFINED
#endif

/*
 *  Assumes sig_atomic_t is signed and we have a 2s complement machine.
 */

#ifndef SIG_ATOMIC_MAX
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
#endif

#endif

#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)

/*
 *  Please compile with the maximum warning settings to make sure macros are
 *  not defined more than once.
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define glue3_aux(x,y,z) x ## y ## z
#define glue3(x,y,z) glue3_aux(x,y,z)

#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);

#define DECL(us,bits) glue3(DECL,us,) (bits)

#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)

#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }

int main () {
	int err_n = 0;
	int err_first = 0;
	DECL(I,8)
	DECL(U,8)
	DECL(I,16)
	DECL(U,16)
	DECL(I,32)
	DECL(U,32)
#ifdef INT64_MAX
	DECL(I,64)
	DECL(U,64)
#endif
	intmax_t imax = INTMAX_C(0);
	uintmax_t umax = UINTMAX_C(0);
	char str0[256], str1[256];

	sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
	if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
	if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
	sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
	if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
	if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
#ifdef INT64_MAX
	sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
	if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
	if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
	sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
	if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
	if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
#endif

	sprintf (str0, "%d %x\n", 0, ~0);

	sprintf (str1, "%d %x\n",  i8, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
	sprintf (str1, "%u %x\n",  u8, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
	sprintf (str1, "%d %x\n",  i16, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
	sprintf (str1, "%u %x\n",  u16, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
	sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n",  i32, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
	sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n",  u32, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
#ifdef INT64_MAX
	sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n",  i64, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
#endif
	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n",  imax, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n",  umax, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));

	TESTUMAX(8);
	TESTUMAX(16);
	TESTUMAX(32);
#ifdef INT64_MAX
	TESTUMAX(64);
#endif

#define STR(v) #v
#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
	if (err_n) {
		printf ("pstdint.h is not correct.  Please use sizes below to correct it:\n");
	}

	Q(int)
	Q(unsigned)
	Q(long int)
	Q(short int)
	Q(int8_t)
	Q(int16_t)
	Q(int32_t)
#ifdef INT64_MAX
	Q(int64_t)
#endif

	return EXIT_SUCCESS;
}

#endif
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































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

1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_IMPL_TO_SIGNED_HPP
#define CXXOMFORT_IMPL_TO_SIGNED_HPP
#include <numeric>
#include <cstddef>
#include <cxxomfort/util/type_traits.hpp>

namespace cxxomfort { namespace impl { namespace numeric {


namespace {
    template <typename T>
    struct to_signed_impl {};




|







1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_IMPL_TO_SIGNED_HPP
#define CXXOMFORT_IMPL_TO_SIGNED_HPP
#include <numeric>
#include <cstddef>
#include <cxxomfort/impl/07-type_traits.hpp>

namespace cxxomfort { namespace impl { namespace numeric {


namespace {
    template <typename T>
    struct to_signed_impl {};

Changes to cxxomfort/cxxomfort/impl/tuplemeta.hpp.

4
5
6
7
8
9
10

11
12
13



14
15
16
17
18
19
20
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
209
210
211
212
213
214
215
216
























































































































































































































































































































































































































217
218
219
/**
 * Helper utilities to work with tuples.
 * 
 * Interfaces defined here:
 * 
 *  * * @c is_tuple
 *  * * @c tuple_index

 * 
 * */




#include <cxxomfort/type_traits.hpp>
#include "using_tr1_type_traits.hpp"

namespace cxxomfort { namespace impl {


/**
................................................................................
template <typename T1, typename T2, typename T3, typename T4> 
struct is_tuple <std::tuple<T1,T2,T3,T4> >
: traits::true_type {};
template <typename T1, typename T2, typename T3, typename T4, typename T5> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5> >
: traits::true_type {};

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && _VARIADIC_MAX < 9)
#else

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6> >
: traits::true_type {};
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6,T7> >
: traits::true_type {};
................................................................................
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6,T7,T8> >
: traits::true_type {};
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> >
: traits::true_type {};

#endif

// if compiler supports variadics, we can extend this
#if (CXXO_COMPILER_SUPPORT_variadic)
template <typename T0, typename T1, typename T2, typename T3, typename T4
        , typename T5, typename T6, typename T7, typename T8, typename T9, typename... TArgs> 
struct is_tuple <std::tr1::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TArgs...> >
: traits::true_type {};
#endif // variadic

#endif // c++ standard



/*
 * Check if an element of type T is already in Tuple, 
................................................................................
    typedef typename std::conditional< (va>0) , bool, void>::type Sentinel_t;
    enum { 
        //! The value of this trait.
        value = detail::tuple_element2index_helper<C,0UL,std::tuple_size<T>::value,T>::value 
    };
};


























































































































































































































































































































































































































}} // cxxomfort::impl

#endif







>



>
>
>







 







|
|







 







|
<
<
<
<
<
<
<
<







 








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



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
64
65
66
67
68
69
70
71








72
73
74
75
76
77
78
...
205
206
207
208
209
210
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
/**
 * Helper utilities to work with tuples.
 * 
 * Interfaces defined here:
 * 
 *  * * @c is_tuple
 *  * * @c tuple_index
 *  * * @c tuple_unshift_type , @c tuple_unshift
 * 
 * */

#include <cxxomfort/base.hpp>
#include <cxxomfort/tuple.hpp>
#include <cxxomfort/utility.hpp> // make_index_sequence in C++11
#include <cxxomfort/type_traits.hpp>
#include "using_tr1_type_traits.hpp"

namespace cxxomfort { namespace impl {


/**
................................................................................
template <typename T1, typename T2, typename T3, typename T4> 
struct is_tuple <std::tuple<T1,T2,T3,T4> >
: traits::true_type {};
template <typename T1, typename T2, typename T3, typename T4, typename T5> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5> >
: traits::true_type {};

	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && _VARIADIC_MAX < 9)
	#else

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6> >
: traits::true_type {};
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6,T7> >
: traits::true_type {};
................................................................................
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6,T7,T8> >
: traits::true_type {};
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 
struct is_tuple <std::tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> >
: traits::true_type {};

	#endif









#endif // c++ standard



/*
 * Check if an element of type T is already in Tuple, 
................................................................................
    typedef typename std::conditional< (va>0) , bool, void>::type Sentinel_t;
    enum { 
        //! The value of this trait.
        value = detail::tuple_element2index_helper<C,0UL,std::tuple_size<T>::value,T>::value 
    };
};


// 
// tuple_unshift_t, tuple_unshift
// adds an element to the beginning of a tuple
// 


template <typename T, typename Tuple>
struct tuple_unshift_t;

#if (CXXOMFORT_CXX_STD>=2011)

/*
template <typename T, typename... TArgs>
std::tuple<T, TArgs...> tuple_unshift 
( T const& v, std::tuple<TArgs...> const& tu) {
	return std::tuple_cat ( std::make_tuple(v), tu);
}

*/

template <typename T, typename... Args>
struct tuple_unshift_t<T, std::tuple<Args...> > {
	typedef std::tuple<Args...> t2;
	typedef std::tuple<T, Args...> type;
	
	static type call (T const& t0, t2 const& tu) {
		using namespace std;
		make_index_sequence< sizeof...(Args)> IS;
		return tuple_cat( make_tuple(t0), tu);
	}
};

#else

template <typename T>
struct tuple_unshift_t<T, std::tuple<> > {
	typedef std::tuple<T> type;
	typedef std::tuple<> argument_type;
	static type call (T const& t, argument_type const&) {
		return std::make_tuple(t);
	}
};


template <typename T, typename T0>
struct tuple_unshift_t<T, std::tuple<T0> > {
	typedef std::tuple<T,T0> type;
	typedef std::tuple<T0> argument_type;
	static type call (T const& tt, argument_type const& t) {
		return type(tt, std::get<0>(t));//  std::tuple_cat (std::make_tuple(t), tt);
	}
};

template <typename T, typename T0, typename T1>
struct tuple_unshift_t<T, std::tuple<T0,T1> > {
	typedef std::tuple<T,T0,T1> type;
	static type call (T const& tt, std::tuple<T0,T1> const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t));
	}
};

template <typename T, typename T0, typename T1, typename T2>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2> > {
	typedef std::tuple<T0,T1,T2> argument_type;
	typedef std::tuple<T,T0,T1,T2> type;
	static type call (T const& tt, argument_type const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t));
	}
};

template <typename T, typename T0, typename T1, typename T2, typename T3>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3> > {
	typedef std::tuple<T0,T1,T2,T3> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3> type;
	static type call (T const& tt, argument_type const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t), get<3>(t));
	}
};

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3,T4> > {
	typedef std::tuple<T0,T1,T2,T3,T4> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3,T4> type;
	static type call (T const& tt, argument_type const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t));
	}
};

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3,T4,T5> > {
	typedef std::tuple<T0,T1,T2,T3,T4,T5> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3,T4,T5> type;
	static type call (T const& tt, argument_type const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
	}
};

#if defined(_VARIADIC_MAX) && (VARIADIC_MAX < 7)
#else

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3,T4,T5,T6> > {
	typedef std::tuple<T0,T1,T2,T3,T4,T5,T6> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3,T4,T5,T6> type;
	static type call (T const& tt, argument_type const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t), get<6>(t) );
	}
};
#endif

#if defined(_VARIADIC_MAX) && (VARIADIC_MAX < 8)
#else

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3,T4,T5,T6,T7> > {
	typedef std::tuple<T0,T1,T2,T3,T4,T5,T6,T7> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3,T4,T5,T6,T7> type;
	static type call (T const& tt, argument_type const& t) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t), get<6>(t), get<7>(t) );
	}
};
#endif

#if defined(_VARIADIC_MAX) && (VARIADIC_MAX < 9)
#else

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8> > {
	typedef std::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3,T4,T5,T6,T7,T8> type;
	static type call (T const& t, argument_type const& tt) {
		using std::get;
		return type(tt, get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t), get<6>(t), get<7>(t), get<8>(t) );
	}
};
#endif


#endif

// 
// tuple_push_t, tuple_push
// adds an element to the end of a tuple
// 

template <typename T, typename Tuple>
struct tuple_push_t;

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename T, typename... Args>
struct tuple_push_t<T, std::tuple<Args...> > {
	typedef std::tuple<Args...> t2;
	typedef std::tuple<Args..., T> type;
	static type call (T const& tx, t2 const& tu) {
		using namespace std;
		return tuple_cat(tu, make_tuple(tx));
	}
};

#else

template <typename T>
struct tuple_push_t<T, std::tuple<> > {
	typedef std::tuple<T> type;
	typedef std::tuple<> argument_type;
	static type call (T const& t, argument_type const&) {
		return std::make_tuple(t);
	}
};

template <typename T, typename T0>
struct tuple_push_t<T, std::tuple<T0> > {
	typedef std::tuple<T0, T> type;
	typedef std::tuple<T0> argument_type;
	static type call (T const& t, argument_type const& tu) {
		return type(std::get<0>(tu), t);
	}
};

template <typename T, typename T0, typename T1>
struct tuple_push_t<T, std::tuple<T0,T1> > {
	typedef std::tuple<T0,T1, T> type;
	typedef std::tuple<T0,T1> argument_type;
	static type call (T const& t, argument_type const& tu) {
		using std::get;
		return type(get<0>(tu), get<1>(tu),  t);
	}
};

template <typename T, typename T0, typename T1, typename T2>
struct tuple_push_t<T, std::tuple<T0,T1,T2> > {
	typedef std::tuple<T0,T1,T2, T> type;
	typedef std::tuple<T0,T1,T2> argument_type;
	static type call (T const& t, argument_type const& tu) {
		using std::get;
		return type(get<0>(tu), get<1>(tu), get<2>(tu)
		,  t);
	}
};

template <typename T, typename T0, typename T1, typename T2, typename T3>
struct tuple_push_t<T, std::tuple<T0,T1,T2,T3> > {
	typedef std::tuple<T0,T1,T2,T3, T> type;
	typedef std::tuple<T0,T1,T2,T3> argument_type;
	static type call (T const& t, argument_type const& tu) {
		using std::get;
		return type(get<0>(tu), get<1>(tu), get<2>(tu), get<3>(tu)
		,  t);
	}
};

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4>
struct tuple_push_t<T, std::tuple<T0,T1,T2,T3,T4> > {
	typedef std::tuple<T0,T1,T2,T3,T4, T> type;
	typedef std::tuple<T0,T1,T2,T3,T4> argument_type;
	static type call (T const& t, argument_type const& tu) {
		using std::get;
		return type(get<0>(tu), get<1>(tu), get<2>(tu), get<3>(tu), get<4>(tu)
		,  t);
	}
};

	#if defined(_VARIADIC_MAX) && (VARIADIC_MAX < 6)
		#pragma message CXXO_WARNING("_VARIADIC_MAX set too low - C++ TR1 indicates at least = 10")
	#else

template <typename T, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
struct tuple_push_t<T, std::tuple<T0,T1,T2,T3,T4,T5> > {
	typedef std::tuple<T0,T1,T2,T3,T4,T5, T> type;
	typedef std::tuple<T0,T1,T2,T3,T4,T5> argument_type;
	static type call (T const& t, argument_type const& tu) {
		using std::get;
		return type(get<0>(tu), get<1>(tu), get<2>(tu), get<3>(tu), get<4>(tu), get<5>(tu)
		,  t);
	}
};

	#endif

#endif

// 
// tuple_shift_t, tuple_shift
// removes element from the beginning of a tuple
// 


template <typename Tuple>
struct tuple_shift_t;

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename T, typename... TArgs>
struct tuple_shift_t< std::tuple<T, TArgs...> > {
	typedef std::tuple<TArgs...> type;
};

#else

template <typename T, typename T1>
struct tuple_shift_t< std::tuple<T, T1> > {
	typedef std::tuple<T1> type;
	typedef std::tuple<T, T1> argument_type;
	static type call ( argument_type const& tu) {
		using std::get;
		return type( get<1>(tu) );
	}
};

template <typename T, typename T1, typename T2>
struct tuple_shift_t< std::tuple<T, T1,T2> > {
	typedef std::tuple<T1,T2> type;
	typedef std::tuple<T, T1,T2> argument_type;
	static type call ( argument_type const& tu) {
		using std::get;
		return type( get<1>(tu), get<2>(tu) );
	}
};

template <typename T, typename T1, typename T2, typename T3>
struct tuple_shift_t< std::tuple<T, T1,T2,T3> > {
	typedef std::tuple<T1,T2,T3> type;
};

template <typename T, typename T1, typename T2, typename T3, typename T4>
struct tuple_shift_t< std::tuple<T, T1,T2,T3,T4> > {
	typedef std::tuple<T1,T2,T3,T4> type;
};

	#if defined(_VARIADIC_MAX) && (VARIADIC_MAX < 6)
		#pragma message CXXO_WARNING("_VARIADIC_MAX set too low - C++ TR1 indicates at least = 10")
	#else

template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
struct tuple_shift_t< std::tuple<T, T1,T2,T3,T4,T5> > {
	typedef std::tuple<T1,T2,T3,T4,T5> type;
};

template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
struct tuple_shift_t< std::tuple<T, T1,T2,T3,T4,T5,T6> > {
	typedef std::tuple<T1,T2,T3,T4,T5,T6> type;
};

template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
struct tuple_shift_t< std::tuple<T, T1,T2,T3,T4,T5,T6,T7> > {
	typedef std::tuple<T1,T2,T3,T4,T5,T6,T7> type;
};

template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
struct tuple_shift_t< std::tuple<T, T1,T2,T3,T4,T5,T6,T7,T8> > {
	typedef std::tuple<T1,T2,T3,T4,T5,T6,T7,T8> type;
};

template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
struct tuple_shift_t< std::tuple<T, T1,T2,T3,T4,T5,T6,T7,T8,T9> > {
	typedef std::tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> type;
};

	#endif

#endif

// 
// tuple_pop_t, tuple_pop
// removes element from the beginning of a tuple
// 

template <typename Tuple>
struct tuple_pop_t;

#if (CXXOMFORT_CXX_STD >= 2011)

namespace pop_{
template <typename S, typename... Ts> struct impl_;
template <size_t... I, typename... Ts>
struct impl_ < std::index_sequence<I...>, Ts...> {
	typedef std::index_sequence<I...> IS;
	typedef std::tuple< typename std::tuple_element<I, std::tuple<Ts...> > ::type... > type;
};

} // pop_

template <typename... TArgs>
struct tuple_pop_t< std::tuple<TArgs...> > {
	typedef std::make_index_sequence< sizeof...(TArgs)-1 > IS;
	typedef typename pop_::impl_<IS , TArgs...>::type type;
	typedef std::tuple<TArgs...> argument_type;
	template <size_t... I>
	static type call ( argument_type const& tu, IS = IS{} ) {
		using namespace std;
		return type ( get<I>(tu)... );
	}
	
};

#else

template <typename T, typename T1>
struct tuple_pop_t< std::tuple<T1,  T> > {
	typedef std::tuple<T1> type;
	typedef std::tuple<T1,  T> argument_type;
	static type call ( argument_type const& tu) {
		using std::get;
		return type( get<0>(tu) );
	}
};

template <typename T, typename T1, typename T2>
struct tuple_pop_t< std::tuple<T1,T2,  T> > {
	typedef std::tuple<T1,T2> type;
	typedef std::tuple<T1,T2,  T> argument_type;
	static type call ( argument_type const& tu) {
		using std::get;
		return type( get<0>(tu), get<1>(tu) );
	}
};

template <typename T, typename T1, typename T2, typename T3>
struct tuple_pop_t< std::tuple<T1,T2,T3,  T> > {
	typedef std::tuple<T1,T2,T3> type;
	typedef std::tuple<T1,T2,T3,  T> argument_type;
	static type call ( argument_type const& tu) {
		using std::get;
		return type( get<0>(tu), get<1>(tu), get<2>(tu) );
	}
};

template <typename T, typename T1, typename T2, typename T3, typename T4>
struct tuple_pop_t< std::tuple<T1,T2,T3,T4,  T> > {
	typedef std::tuple<T1,T2,T3,T4> type;
	typedef std::tuple<T1,T2,T3,T4,  T> argument_type;
	static type call ( argument_type const& tu) {
		using std::get;
		return type( get<0>(tu), get<1>(tu), get<2>(tu), get<3>(tu) );
	}
};

#endif


}} // cxxomfort::impl

#endif

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

3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
/**
 @file
 @author Luis Machuca Bezzaza
 @see http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 @see http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using/11856721#11856721
**/
#include <cxxomfort/base.hpp>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/using_tr1_type_traits.hpp>

#include <cxxomfort/impl/11-underlying_type.hpp>
//#include <cxxomfort/using.hpp>

/*
 * Usage is as follows:
 */
#if 0 







|

>







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
 @file
 @author Luis Machuca Bezzaza
 @see http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 @see http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using/11856721#11856721
**/
#include <cxxomfort/base.hpp>
#include <cxxomfort/impl/07-type_traits.hpp>
#include <cxxomfort/impl/using_tr1_type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp>
#include <cxxomfort/impl/11-underlying_type.hpp>
//#include <cxxomfort/using.hpp>

/*
 * Usage is as follows:
 */
#if 0 

Changes to cxxomfort/cxxomfort/impl/unique_ptr-poor.hpp.

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

#include "../config.hpp"

#define CXXOMFORT_USING_unique_ptr
#define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_EMULATION()

#include "../base.hpp" // nullptr, static_assert, move, forward
#include "../util/meta.hpp"
#include "../util/type_traits.hpp"
#include CXXO_INCLUDE_SYS(cstddef) 
#include CXXO_INCLUDE_SYS(memory) 
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled unique_ptr POOR emulation")
#endif

/*







|
|







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

#include "../config.hpp"

#define CXXOMFORT_USING_unique_ptr
#define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_EMULATION()

#include "../base.hpp" // nullptr, static_assert, move, forward
//#include "../util/meta.hpp"
#include "../impl/07-type_traits.hpp"
#include CXXO_INCLUDE_SYS(cstddef) 
#include CXXO_INCLUDE_SYS(memory) 
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled unique_ptr POOR emulation")
#endif

/*

Changes to cxxomfort/cxxomfort/impl/unique_ptr.hpp.

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#endif

#if (defined (CXXOMFORT_USING_unique_ptr))
    #define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_BACKPORT()

#include "../base.hpp" // nullptr, static_assert, move, forward
#include "../util/meta.hpp"
#include "../util/type_traits.hpp"
#include CXXO_INCLUDE_SYS(cstddef) 
#include CXXO_INCLUDE_SYS(memory) 
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled unique_ptr emulation")
#endif

/*







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#endif

#if (defined (CXXOMFORT_USING_unique_ptr))
    #define CXXOMFORT_IMPLEMENTS_unique_ptr CXXO_IMPLSTATUS_BACKPORT()

#include "../base.hpp" // nullptr, static_assert, move, forward
#include "../util/meta.hpp"
#include "../impl/07-type_traits.hpp"
#include CXXO_INCLUDE_SYS(cstddef) 
#include CXXO_INCLUDE_SYS(memory) 
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled unique_ptr emulation")
#endif

/*

Changes to cxxomfort/cxxomfort/impl/valcomp.hpp.

4
5
6
7
8
9
10








11
12
13
14
15




16

17
18
19
20
21
22
23
/**
 * @file
 * @brief Implements a generic strcmp-like (three-way) comparator.
 * 
 * */
namespace cxxomfort { namespace impl {









template <typename T, typename Comp>
int valcmp (T const& v1, T const& v2, Comp comp) CXXO_NOEXCEPTNOTHROW {
    return comp(v1,v2);
}





template <typename T>

int valcmp (T const& v1, T const& v2) CXXO_NOEXCEPTNOTHROW {
    return v1==v2 ? 0 : (v1<v2 ? -1 : +1);
}

}}

#endif







>
>
>
>
>
>
>
>
|
|



>
>
>
>

>







4
5
6
7
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
/**
 * @file
 * @brief Implements a generic strcmp-like (three-way) comparator.
 * 
 * */
namespace cxxomfort { namespace impl {

/**
 * @brief Compares two objects and returns a 3-state comparison result the way @c memcmp , @c strcmp do.
 * @returns @c 0 if both arguments compare equal; otherwise a negative or a positive number if the first object compares "less" than the second or viceversa, respectively.
 * @throws Nothing. This function assumes comparators don't throw.
 * 
 * @ingroup cxxo-sup-algorithm
 * 
 * */
template <typename T, typename Less>
int valcmp (T const& v1, T const& v2, Less comp) CXXO_NOEXCEPTNOTHROW {
    return comp(v1,v2);
}

/**
 * @overload valcmp
 * 
 * */
template <typename T>
inline 
int valcmp (T const& v1, T const& v2) CXXO_NOEXCEPTNOTHROW {
    return v1==v2 ? 0 : (v1<v2 ? -1 : +1);
}

}}

#endif

Deleted cxxomfort/cxxomfort/impl/zzzvarious.hpp.

1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CXXOMFORT_CXXO_ZZZVARIOUS_HPP
#define CXXOMFORT_CXXO_ZZZVARIOUS_HPP

namespace cxxomfort { namespace impl {

// numeric sequence tag

template <size_t S>
struct index_tag 
: index_tag<S-1> {
    enum { value = S };
    typedef index_tag<S-1> previous;
};

template<> struct index_tag<0> {
    enum { value = 0 };
    typedef void previous;
};


// raw pointer tag

template <typename T>
struct pointer {
    CXXO_CONSTEXPR14 pointer (T* v) CXXO_NOEXCEPTNOTHROW 
    : value (v) {}

    T* value;
};

// force non-null pointer, from GSL

template <typename T>
class non_null {
};

// force_rvo checker from https://stackoverflow.com/questions/35736568/is-there-a-way-to-check-if-rvo-was-applied

//
// integral_of_size
//

template <size_t S> struct integral_of_size { 
    static const bool value = false; 
    typedef void type; 
};

// sizeof(char)==1 is guaranteed by the Standard

template <> struct integral_of_size<sizeof(int8_t)> { 
    static const bool value= true;
    typedef int8_t type; 
};
template <> struct integral_of_size<sizeof(int16_t)> { 
    static const bool value= true;
    typedef int16_t type; 
};
template <> struct integral_of_size<sizeof(int32_t)> { 
    static const bool value= true;
    typedef int32_t type; 
};
template <> struct integral_of_size<sizeof(int64_t)> { 
    static const bool value= true;
    typedef int64_t type; 
};

} }

#endif
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































Changes to cxxomfort/cxxomfort/ios.hpp.

57
58
59
60
61
62
63



64





















65
ios& right (ios& s) { s.setf(ios::right); return s; };


} // std

#endif


























#endif







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

57
58
59
60
61
62
63
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
ios& right (ios& s) { s.setf(ios::right); return s; };


} // std

#endif

/**
 * @page std0ios <ios>
 * @brief Backports related to Standard header <tt><ios></tt> 
 * 
 * C++03 and onwards don't usually need anything to be done for 
 * <tt><ios></tt>; however for some older compilers that are missing out 
 * on the full ios interface this header provides some
 * fixes and missing std names.
 * 
 * Interfaces defined in this section:
 * 
 * * @c io_errc (C++11).
 * * <tt>is_error_code_enum<io_errc></tt> (C++11).
 * * @c left , @c right (C++98) for Open Watcom.
 * 
 * Non-backport interfaces:
 * 
 * * (none)
 * 
 * @section also See Also
 * 
 * * @see @cppref{header/ios} (cppreference)
 * 
 * */

#endif

Changes to cxxomfort/cxxomfort/iterator.hpp.

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
64
65
66
67
68
69
70

71
72
73
74
75
76
77
..
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
CXXO_CONSTEXPR 
std::reverse_iterator<It> make_reverse_iterator (It i) {
    return std::reverse_iterator<It>(i);
}

} }
#if (defined( CXXOFLAG_NO_STD_USING ) && CXXOFLAG_NO_STD_USING>0)
#else
namespace std {
	using ::cxxomfort::cxxostd::make_reverse_iterator;
}
#endif



................................................................................
#include "impl/17-iterator_access.hpp" // size, data, empty


// 
// contiguous_access, contiguous_access_iterator
// 


namespace cxxomfort { namespace fix { 

/**
 * @brief Tags an iterator as a contiguous access type iterator.
 * 
 * Given an iterator type I, indicates whether the type either: 
 * 
................................................................................
template <typename T>
struct is_contiguous_access_iterator<T*> {
	enum { value= 1, specialized= 2 };
};


} }


#endif

/**
 * @page std0iterator <iterator>
 * @brief Backports related to Standard header <tt><iterator></tt> 
 * 
 * @code
 * #include <cxxomfort/iterator.hpp>







|







 







>







 







>

|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
CXXO_CONSTEXPR 
std::reverse_iterator<It> make_reverse_iterator (It i) {
    return std::reverse_iterator<It>(i);
}

} }
#if (defined( CXXOFLAG_NO_STD_USING ) && CXXOFLAG_NO_STD_USING>0)
#elif (CXXOMFORT_CXX_STD < 2014)
namespace std {
	using ::cxxomfort::cxxostd::make_reverse_iterator;
}
#endif



................................................................................
#include "impl/17-iterator_access.hpp" // size, data, empty


// 
// contiguous_access, contiguous_access_iterator
// 

#if (CXXOMFORT_CXX_STD >= 1997)
namespace cxxomfort { namespace fix { 

/**
 * @brief Tags an iterator as a contiguous access type iterator.
 * 
 * Given an iterator type I, indicates whether the type either: 
 * 
................................................................................
template <typename T>
struct is_contiguous_access_iterator<T*> {
	enum { value= 1, specialized= 2 };
};


} }
#endif

#endif // file

/**
 * @page std0iterator <iterator>
 * @brief Backports related to Standard header <tt><iterator></tt> 
 * 
 * @code
 * #include <cxxomfort/iterator.hpp>

Changes to cxxomfort/cxxomfort/library/algorithm.hpp.

20
21
22
23
24
25
26
27
28
29






































































































30

31
32
33
34
35
36
37
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
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
...
454
455
456
457
458
459
460


461
462
463
464
465
466
467
namespace algorithm {

/**
 * @ingroup cxxo-sup-algorithm
 * @{
 */

	using cxxomfort::impl::valcmp;
	







































































































// copy_leftmost_n is simply copy_n


/**
 * @brief Copy like @c copy_if with inverted predicate (for symmetry with @c find_if_not ).
 * @xrefitem cxxo-sup-algorithm "cxxo-sup-algorithm" "Copying"
 * 
 * This is provided for homology with: 
 * <tt>std::find_if_not</tt>, <tt>std::copy_if</tt>.
................................................................................
 * For example, for the following example @c find_inversion will return an iterator pointing to the element 6:
 * 
 * @code

vector<int> elems = { -17, 3, 6, -2, -3, -4 };
//                            ^  sorting order is broken in this pair
vector<int>::iterator br = find_inversion( begin(elems), end(elems) );

 * @endcode
 * 
 * See also: @c fix_inversion().
 * 
**/
template <typename Iter, typename Less> inline
Iter find_inversion (Iter ini, Iter fin, Less lt) {
................................................................................
    return ret;
}



/**
 * @brief Transform elements in the range in-place via the transformation @a tf .

 * @param tf A transformation of the form <code>TF(value_type) → value_type</code>.
 * @return The @e end iterator of the sequence.
 * @xrefitem cxxo-sup-algorithm "" "Transforms"
 */
template <typename FIter, typename TF>
FIter transform_inplace (FIter ini, FIter fin, TF tf) {
    for (; ini != fin; ++ini) {
................................................................................
        *ini= tf(*ini);
    }
    return ini;
}

/**
 * @brief Transform elements in the range conditionally.

 * @param tf A transformation of the form <code>TF(*FIter) -> *FIter</code>.
 * @param p a predicate to decide if the elements need transformation.
 * @return The @e end iterator of the sequence.
 * @xrefitem cxxo-sup-algorithm "" "Transforms"
 * 
 * This is provided for homology with: 
 * <tt>std::copy_if</tt>
................................................................................
 * algorithms present in <code><algorithm></code> that are 
 * specific to cxxomfort, as well as functions that complete the 
 * family of <code>_n</code> functions such as <code>transform_n</code>.
 * 
 * Interfaces defined here:
 * 
 * * @c valcmp() - compares two values the way eg.: @c memcmp does.


 * * @c copy_leftmost_n() , @c copy_rightmost_n () - copies from either end of a sequence.
 * * @c copy_if_not() - complementary to @c find_if_not .
 * * @c count_while() - counts elements in a sequence.
 * * @c any_on(), @c all_on(), @c none_on() - check a number of predicates on a given value.
 * * @c find_not() , @c find_if_not() - complements to @c find() , from p1223.
 * * binary predicate form @c find() , from lwg127.
 * * @c find_inversion() - finds elements out of place in a sequence.







|
|

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

>







 







|







 







>







 







>







 







>
>







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
57
58
59
60
61
62
63
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
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
...
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
...
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
...
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
namespace algorithm {

/**
 * @ingroup cxxo-sup-algorithm
 * @{
 */

using cxxomfort::impl::valcmp;


// 
// is_clamped (p1440)
// 

/**
 * @brief Checks if a value is clamped
 * @param less A relational predicate with semantics similar to those of <tt>std::less</tt> or <tt>operator<()</tt>
 * @returns a bool.
 * @xrefitem cxxo-sup-algorithm "cxxo-sup-algorithm" "Modifying"
 * @see @wg21{p1440} @cppref{algorithm/clamp}
 * 
 * This is an implementation of p1440 "is_clamped": a complement to <tt>clamp()</tt> 
 * in the same way <tt>is_sorted()</tt> is a complement to <tt>sort()</tt>.
 * 
 * Given the general concept of calls to <tt>clamp()</tt>, the following assertion should hold:
 * 
 * @code
 * (is_clamped(x, lo, hi)) if and only if (x == clamp(x,lo,hi))
 * @endcode
 * 
 * @note Unlike the @e p1440 proposal, <tt>is_clamped()</tt> here is marked @c noexcept ; 
 * I consider there is no good scenario where relational comparison operators, or 
 * anything that mimics them, would be throwing.
 * 
 * */
template <typename T, typename Compare>
CXXO_CONSTEXPR 
bool is_clamped (T const& value, T const& lo, T const& hi, Compare less) CXXO_NOEXCEPTNOTHROW {
	return !less(value, lo) && !less(hi, value);
}

//! @overload is_clamped()
template <typename T>
CXXO_CONSTEXPR 
bool is_clamped (T const& value, T const& lo, T const& hi, Compare less) CXXO_NOEXCEPTNOTHROW {
	return !(value < lo) && !(hi < value);
}

#define CXXOMFORT_IMPLEMENTS_p1440 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_is_clamped CXXOMFORT_IMPLEMENTS_p1440


// 
// half-open range clamp variants
// 

/**
 * @brief Clamps a value within a half-open range.
 * @param less A relational predicate with semantics similar to those of <tt>std::less</tt> or <tt>operator<()</tt>
 * @return An altered value from @a val to fit into the half-open interval <tt>[@a lo , @a hi )</tt>.
 * @xrefitem cxxo-sup-algorithm "cxxo-sup-algorithm" "Modifying"
 * @see @cppref{algorithm/clamp}
 */
template<class T, class Compare>
CXXO_CONSTEXPR
T const& clamp_halfopen ( T const& val, T const& lo, T const& hi, Compare less) {
    return assert( !less(hi, lo) ),
        comp(val, lo) ? lo : comp(val, hi) ? val : hi;
}

//! @overload clamp_halfopen()
template<class T>
CXXO_CONSTEXPR
T const& clamp_halfopen ( T const& val, T const& lo, T const& hi) {
    return assert( !(hi< lo) ),
        (val< lo) ? lo : (val< hi) ? val : hi;
}

/**
 * @brief Checks if a value is clamped in a half-open interval as per <tt>clamp_halfopen()</tt>
 * @returns a bool.
 * 
 * This is a supplement to p1440 "is_clamped" in that it checks if the value 
 * is clamped in a @e half-open interval.
 * 
 * Given the general concept of calls to <tt>clamp()</tt>, the following assertion should hold:
 * 
 * @code
 * (is_clamped_halfopen(x, lo, hi)) if and only if (x == clamp_halfopen(x,lo,hi))
 * @endcode
 * 
 * @note <tt>is_clamped_halfopen()</tt> here is marked @c noexcept ; 
 * I consider there is no good scenario where relational comparison operators, or 
 * anything that mimics them, would be throwing.
 * 
 * */
template <typename T, typename Compare>
CXXO_CONSTEXPR 
bool is_clamped_halfopen (T const& value, T const& lo, T const& hi, Compare less) CXXO_NOEXCEPTNOTHROW {
	return !less(value, lo) && less(value, hi);
}

//! @overload is_clamped_halfopen()
template <typename T>
CXXO_CONSTEXPR 
bool is_clamped_halfopen (T const& value, T const& lo, T const& hi) CXXO_NOEXCEPTNOTHROW {
	return !(value < lo) && (value < hi);
}



// 
// copy_leftmost_n is simply copy_n
// 

/**
 * @brief Copy like @c copy_if with inverted predicate (for symmetry with @c find_if_not ).
 * @xrefitem cxxo-sup-algorithm "cxxo-sup-algorithm" "Copying"
 * 
 * This is provided for homology with: 
 * <tt>std::find_if_not</tt>, <tt>std::copy_if</tt>.
................................................................................
 * For example, for the following example @c find_inversion will return an iterator pointing to the element 6:
 * 
 * @code

vector<int> elems = { -17, 3, 6, -2, -3, -4 };
//                            ^  sorting order is broken in this pair
vector<int>::iterator br = find_inversion( begin(elems), end(elems) );
// at this point, br points to index 2 (element 6).
 * @endcode
 * 
 * See also: @c fix_inversion().
 * 
**/
template <typename Iter, typename Less> inline
Iter find_inversion (Iter ini, Iter fin, Less lt) {
................................................................................
    return ret;
}



/**
 * @brief Transform elements in the range in-place via the transformation @a tf .
 * @param ini,fin Iterators marking a @e writable sequence.
 * @param tf A transformation of the form <code>TF(value_type) → value_type</code>.
 * @return The @e end iterator of the sequence.
 * @xrefitem cxxo-sup-algorithm "" "Transforms"
 */
template <typename FIter, typename TF>
FIter transform_inplace (FIter ini, FIter fin, TF tf) {
    for (; ini != fin; ++ini) {
................................................................................
        *ini= tf(*ini);
    }
    return ini;
}

/**
 * @brief Transform elements in the range conditionally.
 * @param ini,fin Iterators marking a @e writable sequence.
 * @param tf A transformation of the form <code>TF(*FIter) -> *FIter</code>.
 * @param p a predicate to decide if the elements need transformation.
 * @return The @e end iterator of the sequence.
 * @xrefitem cxxo-sup-algorithm "" "Transforms"
 * 
 * This is provided for homology with: 
 * <tt>std::copy_if</tt>
................................................................................
 * algorithms present in <code><algorithm></code> that are 
 * specific to cxxomfort, as well as functions that complete the 
 * family of <code>_n</code> functions such as <code>transform_n</code>.
 * 
 * Interfaces defined here:
 * 
 * * @c valcmp() - compares two values the way eg.: @c memcmp does.
 * * @c is_clamped() - complement to <tt>clamp()</tt> from p1440.
 * * @c clamp_halfopen() , @c is_clamped_halfopen() - half-open intervals complements to @c clamp() .
 * * @c copy_leftmost_n() , @c copy_rightmost_n () - copies from either end of a sequence.
 * * @c copy_if_not() - complementary to @c find_if_not .
 * * @c count_while() - counts elements in a sequence.
 * * @c any_on(), @c all_on(), @c none_on() - check a number of predicates on a given value.
 * * @c find_not() , @c find_if_not() - complements to @c find() , from p1223.
 * * binary predicate form @c find() , from lwg127.
 * * @c find_inversion() - finds elements out of place in a sequence.

Changes to cxxomfort/cxxomfort/library/array_ref.hpp.

1
2
3
4
5
6

7
8
9
10
11
12
13
#ifndef CXXOMFORT_LIBRARY_ARRAY_REF_HPP
#define CXXOMFORT_LIBRARY_ARRAY_REF_HPP

#include <cxxomfort/impl/n3334-array_ref.hpp>
#include <cxxomfort/string.hpp>
#include <vector>


namespace cxxomfort { namespace library { 

    using ::cxxomfort::impl::array_ref::array_ref;
    using ::cxxomfort::impl::array_ref::arrayref;
    using ::cxxomfort::impl::array_ref::carrayref;







>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef CXXOMFORT_LIBRARY_ARRAY_REF_HPP
#define CXXOMFORT_LIBRARY_ARRAY_REF_HPP

#include <cxxomfort/impl/n3334-array_ref.hpp>
#include <cxxomfort/string.hpp>
#include <vector>
#include <cxxomfort/library/fixed_vector.hpp>

namespace cxxomfort { namespace library { 

    using ::cxxomfort::impl::array_ref::array_ref;
    using ::cxxomfort::impl::array_ref::arrayref;
    using ::cxxomfort::impl::array_ref::carrayref;

Changes to cxxomfort/cxxomfort/library/functional.hpp.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <utility>
/**
 * @file 
 * @ingroup cxxo-sup-functional
 * 
 * */

#if (CXXOMFORT_CXX_STD>=1997)

// information about function types:
// their arguments, arity, return types, etc.

	#include "../impl/functionmeta.hpp"









|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <utility>
/**
 * @file 
 * @ingroup cxxo-sup-functional
 * 
 * */

#if (CXXOMFORT_CXX_STD>=1997 || defined(DOXYGEN_DOC))

// information about function types:
// their arguments, arity, return types, etc.

	#include "../impl/functionmeta.hpp"


Changes to cxxomfort/cxxomfort/library/localfn.hpp.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

114
115
116
117
118
119
120
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
...
258
259
260
261
262
263
264
265

266
267
268
269
270
271
272
273
274
275
...
283
284
285
286
287
288
289
290



291



















































































































292
293
294
295
296
297
298
...
337
338
339
340
341
342
343
344






















345
    // do something and return a bool
} CXXO_LOCALFN_NAME (mi_fn);
find_if (begin(Lista), end(Lista), mi_fn);

Salida es equivalente al siguiente código:

vector<int> Lista;
struct implementation_defined : public ::cxxomfort::extras::fn_wrapper< bool(int) >::o_iface {
    typename (...)::o_iface::result_type operator () (int x0) {
    // do something and return a bool
    }
} LF_mi_fnXob; 
implementation_defined::base_type mi_fn (LF_mi_fnXob);
find_if (begin(Lista), end(Lista), mi_fn);

................................................................................
    #if (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled local functor helpers" )
    #endif
#endif



namespace cxxomfort {
namespace extras {

/*
 * Virtual Function Method
 */

struct localfn_base {};
struct no_type {};


template <typename T>
struct fn_wrapper ;


template <typename R>
struct fn_wrapper<R()> : public localfn_base {
................................................................................

//
// C++03 local function, stateless, type can be "anonymous"
// this can not be used in MSVC, even with typeof hack
//

#define CXXO_LOCALFN0(localsig) \
struct : public ::cxxomfort::extras::fn_wrapper< localsig >::o_iface { \
  typedef ::cxxomfort::extras::fn_wrapper< localsig > fn_type;        \
  fn_type::result_type operator ()
// la firma de la funcion debe ser completada, causa 1 repetición

#define CXXO_LOCALFN0_NAME(VDecl) \
} LF_##VDecl##Xob; \
typedef CXXO_DECLTYPE(LF_##VDecl##Xob) VDecl##_t;  \
/*::cxxomfort::extras::fn_wrapper< localsig >*/ VDecl##_t::base_type VDecl (LF_##VDecl##Xob)
................................................................................
#pragma warning( push )
#pragma warning( disable:4003 ) // insufficient args to macro
#endif

#define CXXO_LOCALFN_BIND(...) LF_EXP(FOR_EACH(LF_INIT,__VA_ARGS__)) _reserved(0) {}

#define CXXO_LOCALFN_(x,localsig,...) \
struct x : public ::cxxomfort::extras::fn_wrapper< localsig >::o_iface {   \

 FOR_EACH(CXXO_LF_MEMBER/*LF_BINDER*/,__VA_ARGS__)                              \
 void* _reserved;  \
 typedef ::cxxomfort::extras::fn_wrapper< localsig > fn_type;              \
 fn_type::result_type operator ()
// la firma de la funcion debe ser completada, causa 1 repetición

#define CXXO_LOCALFN(x,localsig,...) LF_EXP(CXXO_LOCALFN_(x,localsig,__VA_ARGS__))

// gives an argument list to initialize the function object
#define CXXO_LOCALFN_INIT(x,VDecl,...) \
................................................................................
x::base_type VDecl (LF_##x##Xob)


#if defined(_MSC_VER)
#pragma warning( pop ) // insufficient args to macro
#endif

} //~extras



}





















































































































#else 
//
// CXX11 localfn: this is just an anonymous struct
//

................................................................................
//#undef CONCATENATE1
//#undef CONCATENATE2

#undef LF_JOIN_IMPL2
#undef LF_JOIN_IMPL
#undef LF_JOIN
























#endif // CXXOMFORT_EXTRAS_LOCALFN_HPP







|







 







|
<







>







 







|
|







 







|
>


|







 







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







 








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

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
...
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
...
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
    // do something and return a bool
} CXXO_LOCALFN_NAME (mi_fn);
find_if (begin(Lista), end(Lista), mi_fn);

Salida es equivalente al siguiente código:

vector<int> Lista;
struct implementation_defined : public ::cxxomfort::library::fn_wrapper< bool(int) >::o_iface {
    typename (...)::o_iface::result_type operator () (int x0) {
    // do something and return a bool
    }
} LF_mi_fnXob; 
implementation_defined::base_type mi_fn (LF_mi_fnXob);
find_if (begin(Lista), end(Lista), mi_fn);

................................................................................
    #if (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled local functor helpers" )
    #endif
#endif



namespace cxxomfort { namespace library {


/*
 * Virtual Function Method
 */

struct localfn_base {};
struct no_type {};


template <typename T>
struct fn_wrapper ;


template <typename R>
struct fn_wrapper<R()> : public localfn_base {
................................................................................

//
// C++03 local function, stateless, type can be "anonymous"
// this can not be used in MSVC, even with typeof hack
//

#define CXXO_LOCALFN0(localsig) \
struct : public ::cxxomfort::library::fn_wrapper< localsig >::o_iface { \
  typedef ::cxxomfort::library::fn_wrapper< localsig > fn_type;        \
  fn_type::result_type operator ()
// la firma de la funcion debe ser completada, causa 1 repetición

#define CXXO_LOCALFN0_NAME(VDecl) \
} LF_##VDecl##Xob; \
typedef CXXO_DECLTYPE(LF_##VDecl##Xob) VDecl##_t;  \
/*::cxxomfort::extras::fn_wrapper< localsig >*/ VDecl##_t::base_type VDecl (LF_##VDecl##Xob)
................................................................................
#pragma warning( push )
#pragma warning( disable:4003 ) // insufficient args to macro
#endif

#define CXXO_LOCALFN_BIND(...) LF_EXP(FOR_EACH(LF_INIT,__VA_ARGS__)) _reserved(0) {}

#define CXXO_LOCALFN_(x,localsig,...) \
struct x : public ::cxxomfort::library::fn_wrapper< localsig >::o_iface {   \
	\
 FOR_EACH(CXXO_LF_MEMBER/*LF_BINDER*/,__VA_ARGS__)                              \
 void* _reserved;  \
 typedef ::cxxomfort::library::fn_wrapper< localsig > fn_type;              \
 fn_type::result_type operator ()
// la firma de la funcion debe ser completada, causa 1 repetición

#define CXXO_LOCALFN(x,localsig,...) LF_EXP(CXXO_LOCALFN_(x,localsig,__VA_ARGS__))

// gives an argument list to initialize the function object
#define CXXO_LOCALFN_INIT(x,VDecl,...) \
................................................................................
x::base_type VDecl (LF_##x##Xob)


#if defined(_MSC_VER)
#pragma warning( pop ) // insufficient args to macro
#endif

#if 0
// 
// implementation without virtual
// 

template <typename Sig>
struct lfun_indirect {};

template <typename R>
struct lfun_indirect<R()> {
	typedef R(*handleref)(void * const);
	typedef R return_type;

	explicit lfun_indirect (void * const ref, handleref fn) CXXO_NOEXCEPTNOTHROW
	: obj_(ref), call_(fn)
	{
	}

	inline R operator() (...) const {
		return call_(obj_);
	}
	
	private:
	void * const obj_;
	handleref const call_;
	
};

template <typename R, typename A1>
struct lfun_indirect<R(A1)> {
	typedef R(*handleref)(void * const, A1);
	typedef R return_type;
	
	explicit lfun_indirect (void * const ref, handleref fn) CXXO_NOEXCEPTNOTHROW
	: obj_(ref), call_(fn)
	{ }
	
	inline R operator() (A1 a1) const {
		return call_(obj_, a1);
	}
	
	private:
	void * const obj_;
	handleref const call_;
	
	
};


template <typename R, typename A1, typename A2>
struct lfun_indirect<R(A1,A2)> {
	typedef R(*handleref)(void * const, A1, A2);
	typedef R return_type;
	
	explicit lfun_indirect (void * const ref, handleref fn) CXXO_NOEXCEPTNOTHROW
	: obj_(ref), call_(fn)
	{ }
	
	inline R operator() (A1 a1, A2 a2) const {
		return call_(obj_, a1, a2);
	}
	
	private:
	void * const obj_;
	handleref const call_;
	
	
};

//
// C++03 local function, can have state, needs to have a type nam,
// can have bound arguments (but the binding needs to be coded explicitly)
// (this is the "normal" implementation of localfn)
//
#if defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable:4003 ) // insufficient args to macro
#endif

#define CXXO_LOCALFN_BIND(...) LF_EXP(FOR_EACH(LF_INIT,__VA_ARGS__)) _reserved(0) {}

#define CXXO_LOCALFN_(tag,localsig,...) \
struct tag  {   \
 typedef ::cxxomfort::library::lfun_indirect< localsig > Ind_type;   \
 typename Ind_type::result_type operator ()
// la firma de la funcion debe ser completada, causa 1 repetición

#define CXXO_LOCALFN(tag,localsig,...) LF_EXP(CXXO_LOCALFN_(tag,localsig,__VA_ARGS__))

// gives an argument list to initialize the function object
#define CXXO_LOCALFN_INIT(x,VDecl,...) \
} LF_##x##Xob __VA_ARGS__ 

#define CXXO_LOCALFN_NAME(x,VDecl) } \
inline static typename Ind_type::return_type \
call (void* obj, int a) {
	lfnderived* self= static_cast<lfnderived*>(obj);
	return self->operator() (a);
}

x::base_type  VDecl (LF_##x##Xob)

#define CXXO_LOCALFN_NAME_DEF(x,VDecl,...) } \
LF_##x##Xob __VA_ARGS__ ; \
x::base_type VDecl (LF_##x##Xob)


#if defined(_MSC_VER)
#pragma warning( pop ) // insufficient args to macro
#endif

#endif


// 
// end 
// 

} } // namespace cxxomfort::library



#else 
//
// CXX11 localfn: this is just an anonymous struct
//

................................................................................
//#undef CONCATENATE1
//#undef CONCATENATE2

#undef LF_JOIN_IMPL2
#undef LF_JOIN_IMPL
#undef LF_JOIN


/**
 * @page cxxo-localfn 
 * @brief Local Functor emulation
 * @ingroup cxxo-sup
 * @xrefitem cxxo-sup "Supplements" "Local Function emulation"
 * 
 * @code
#include <cxxomfort/library/localfn.hpp>

CXXO_FOREACH(item , range) { ... }

@endcode
* 
 * Cxxomfort implements the "local functor" pattern that allows usage of "local" "functions" as arguments to templates such as STL algorithms when in C++03. In C++11 onwards this pattern maps to the classic anonymous functor struct usage pattern.
 * 
 * The interface is provided via the @c @ref CXXO_LOCALFN macro and its related macros.
 * 
 * 
 * 
 * */
 

#endif // CXXOMFORT_EXTRAS_LOCALFN_HPP

Changes to cxxomfort/cxxomfort/library/numeric.hpp.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iterator>

/**
 * @file cxxomfort/library/numeric.hpp
 * 
 */

#if (CXXOMFORT_CXX_STD>=1997)

#include "../impl/to_signed.hpp"

namespace cxxomfort { namespace library {
namespace numeric {

using cxxomfort::impl::numeric::to_signed;







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iterator>

/**
 * @file cxxomfort/library/numeric.hpp
 * 
 */

#if (CXXOMFORT_CXX_STD>=1997 || defined(DOXYGEN_DOC))

#include "../impl/to_signed.hpp"

namespace cxxomfort { namespace library {
namespace numeric {

using cxxomfort::impl::numeric::to_signed;

Changes to cxxomfort/cxxomfort/library/operatorit.hpp.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define CXXOMFORT_CXXO_OPERATORIT_HPP
/**
 * @file 
 */

#include <cxxomfort/cxxomfort.hpp>
#include CXXO_INCLUDE_SYS(functional)
#include <type_traits> // add_reference

namespace cxxomfort {
namespace library {
namespace functional {

/**
 * @ingroup cxxo-sup-functional 







|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define CXXOMFORT_CXXO_OPERATORIT_HPP
/**
 * @file 
 */

#include <cxxomfort/cxxomfort.hpp>
#include CXXO_INCLUDE_SYS(functional)
#include <cxxomfort/type_traits.hpp> // add_reference

namespace cxxomfort {
namespace library {
namespace functional {

/**
 * @ingroup cxxo-sup-functional 

Changes to cxxomfort/cxxomfort/library/random.hpp.

1
2
3
4
5
6


7
8
9
10
11
12
13
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
177
178
179
180
181
182
183







184
185
186
187
188
189
190
191
192
193
194
195
196
197

198
199
200
201
202
203
204
#ifndef CXXOMFORT_CXXO_RANDOM_SUPP_HPP
#define CXXOMFORT_CXXO_RANDOM_SUPP_HPP
/**
 * @file
 */



#include <cxxomfort/random.hpp>
#include <cxxomfort/functional.hpp>
#include <cxxomfort/cstdint.hpp>
#include <cxxomfort/limits.hpp>
#include <ctime>

namespace cxxomfort { namespace library {
................................................................................
MMIX_rand;

/**
 * @typedef 
 * @brief LCG as it appears recommended by Randall Munroe in <em>xkcd #221</em>.
 * @ingroup cxxo-sup-random
 * 
 * When invoked with <tt>operator()</tt> returns a @c uint32_t value.
 * */
typedef 
std::linear_congruential_engine<unsigned int, 0, 4, 0>
xkcd221_r;

// 
// splitmix54 from http://xoshiro.di.unimi.it/splitmix64.c 
................................................................................
    // we'll mirror the interface of eg.: minstd_rand somewhat
    private:
    uint64_t _state;
    public:
    typedef uint64_t result_type;
    
    static CXXO_CONSTEXPR14 const result_type min = 0;
    static CXXO_CONSTEXPR14 const result_type max = integral_limits<uint64_t>::const_max;
    
    CXXO_CONSTEXPR splitmix64 (uint64_t seed) CXXO_NOEXCEPTNOTHROW 
    : _state(seed)  {}
    
    void seed (uint64_t s) CXXO_NOEXCEPTNOTHROW {
        _state= s;
    }
................................................................................

} // cxxomfort::library::random
}}

/**
 * @page cxxo-sup-random
 *







 * This file provides supplementary features to the ones
 * present in <code><random></code> that are
 * specific to cxxomfort.
 *
 * * @c @ref xkcd221_g - xkcd's pseudorandom number generator selection.
 * * @c @ref MMIX_rand - Knuth's LCG generator selection.
 * * @c @ref lcg_numerical_recipes_rand - <em>Numerical Recipes</em>' LCG generator selection.
 * * @c splitmax64 .
 * * @c default_random_engine() , from Fundamentals v2.
 * * @c reseed() , from Fundamentals v2.
 * * @c randint() , from Fundamentals v2.
 *
 *
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.

 * 
 * Also see @link std0random <random> @endlink .
 *
 */


#endif






>
>







 







|







 







|







 







>
>
>
>
>
>
>
|












|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#ifndef CXXOMFORT_CXXO_RANDOM_SUPP_HPP
#define CXXOMFORT_CXXO_RANDOM_SUPP_HPP
/**
 * @file
 */

#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <cxxomfort/random.hpp>
#include <cxxomfort/functional.hpp>
#include <cxxomfort/cstdint.hpp>
#include <cxxomfort/limits.hpp>
#include <ctime>

namespace cxxomfort { namespace library {
................................................................................
MMIX_rand;

/**
 * @typedef 
 * @brief LCG as it appears recommended by Randall Munroe in <em>xkcd #221</em>.
 * @ingroup cxxo-sup-random
 * 
 * When invoked with <tt>operator()</tt> returns a <tt>unsigned int</tt> value.
 * */
typedef 
std::linear_congruential_engine<unsigned int, 0, 4, 0>
xkcd221_r;

// 
// splitmix54 from http://xoshiro.di.unimi.it/splitmix64.c 
................................................................................
    // we'll mirror the interface of eg.: minstd_rand somewhat
    private:
    uint64_t _state;
    public:
    typedef uint64_t result_type;
    
    static CXXO_CONSTEXPR14 const result_type min = 0;
    static CXXO_CONSTEXPR14 const result_type max = cxxomfort::fix::integral_limits<uint64_t>::const_max;
    
    CXXO_CONSTEXPR splitmix64 (uint64_t seed) CXXO_NOEXCEPTNOTHROW 
    : _state(seed)  {}
    
    void seed (uint64_t s) CXXO_NOEXCEPTNOTHROW {
        _state= s;
    }
................................................................................

} // cxxomfort::library::random
}}

/**
 * @page cxxo-sup-random
 *
 * @code
 * #include <cxxomfort/library/random.hpp>
 * 
 * namespace random2 = cxxomfort::library::random;
 * 
 * @endcode
 * 
 * This component provides supplementary features to the ones
 * present in <code><random></code> that are
 * specific to cxxomfort.
 *
 * * @c @ref xkcd221_g - xkcd's pseudorandom number generator selection.
 * * @c @ref MMIX_rand - Knuth's LCG generator selection.
 * * @c @ref lcg_numerical_recipes_rand - <em>Numerical Recipes</em>' LCG generator selection.
 * * @c splitmax64 .
 * * @c default_random_engine() , from Fundamentals v2.
 * * @c reseed() , from Fundamentals v2.
 * * @c randint() , from Fundamentals v2.
 *
 *
 * All interfaces are defined in the namespace 
 * <tt>cxxomfort::library::random::</tt>.
 * 
 * Also see @link std0random <random> @endlink .
 *
 */


#endif

Changes to cxxomfort/cxxomfort/library/sequences.hpp.

4
5
6
7
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
..
98
99
100
101
102
103
104







105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
 * @file
 *
 */

#include "../config.hpp"
#include <cxxomfort/array.hpp>

#include <cxxomfort/type_traits.hpp>
#include <vector>
#include "../util/type_traits.hpp"
#include "../library/i12n.hpp"
#include "../impl/17-bool_constant.hpp"

/**
 * @page cxxo-sequences Sequence Helpers
 * @ingroup cxxo-sup
 *
 * Interfaces defined in this file:
 *
 * * @c is_std_array
 * * @c is_sequence_container
 * * @c is_indexable_like_array
 * * @c is_iterator
 * * @c make_array
 * * @c seq_ , @c generic_sequence_t
 *
 * Pending:
 *
 * * @c array<> in C++03 mode with NO_TR1 defined
 *

................................................................................
} } //cxxomfort::library

// 
// sequence_t and seq_ generator
// 

#include "../impl/seq_.hpp"








//
// is_sequence -- for specializations based on ability to provide
// access to a sequence of objects
//
#include <iterator>
#include <type_traits>

namespace cxxomfort { namespace library {

//
// is_iterator
//








>


|













|







 







>
>
>
>
>
>
>





<
<







4
5
6
7
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
..
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
/**
 * @file
 *
 */

#include "../config.hpp"
#include <cxxomfort/array.hpp>
#include <cxxomfort/iterator.hpp>
#include <cxxomfort/type_traits.hpp>
#include <vector>
#include "../impl/07-type_traits.hpp"
#include "../library/i12n.hpp"
#include "../impl/17-bool_constant.hpp"

/**
 * @page cxxo-sequences Sequence Helpers
 * @ingroup cxxo-sup
 *
 * Interfaces defined in this file:
 *
 * * @c is_std_array
 * * @c is_sequence_container
 * * @c is_indexable_like_array
 * * @c is_iterator
 * * @c make_array (to be moved to <array>
 * * @c seq_ , @c generic_sequence_t
 *
 * Pending:
 *
 * * @c array<> in C++03 mode with NO_TR1 defined
 *

................................................................................
} } //cxxomfort::library

// 
// sequence_t and seq_ generator
// 

#include "../impl/seq_.hpp"

// 
// numeric_sequence, iterator and enumerator
// 

//#include "../impl/numeric-sequence.hpp"


//
// is_sequence -- for specializations based on ability to provide
// access to a sequence of objects
//



namespace cxxomfort { namespace library {

//
// is_iterator
//

Changes to cxxomfort/cxxomfort/library/string.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

#include <cxxomfort/base.hpp>
#include <cxxomfort/functional.hpp> // functors, binders, placeholders
#include <cxxomfort/string.hpp>

#if (CXXOMFORT_CXX_STD>=1997)

#include <cstring>

#include <string>
#include <sstream>
#include <cxxomfort/algorithm.hpp>
#include "../impl/character.hpp"
#include "../impl/to_basic_string_variadic.hpp"

namespace cxxomfort { namespace library {
/**
 * @ingroup cxxo-sup-string
 * @{
 */
namespace string {


using cxxomfort::impl::string::to_string; // variadic to_string


template <typename T> struct is_std_basic_string : std::false_type {};

template <typename CharType>
struct is_std_basic_string< std::basic_string< CharType > > 







|
>
|

<










>







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

#include <cxxomfort/base.hpp>
#include <cxxomfort/functional.hpp> // functors, binders, placeholders
#include <cxxomfort/string.hpp>

#if (CXXOMFORT_CXX_STD>=1997)

#include <cxxomfort/string.hpp>
#include <cxxomfort/algorithm.hpp>
#include <cstring>
#include <sstream>

#include "../impl/character.hpp"
#include "../impl/to_basic_string_variadic.hpp"

namespace cxxomfort { namespace library {
/**
 * @ingroup cxxo-sup-string
 * @{
 */
namespace string {

using cxxomfort::impl::string::to_basic_string; // variadic to_string
using cxxomfort::impl::string::to_string; // variadic to_string


template <typename T> struct is_std_basic_string : std::false_type {};

template <typename CharType>
struct is_std_basic_string< std::basic_string< CharType > > 

Changes to cxxomfort/cxxomfort/library/tuple.hpp.

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
...
114
115
116
117
118
119
120


121
122
123
124
125
126
127
128



129
130
131
132
133
134
135
...
234
235
236
237
238
239
240
241

242








243
244
245
246
247
248
249
...
360
361
362
363
364
365
366



367
368
369
370



371
372
373
374
375
376
377
...
382
383
384
385
386
387
388

389
390
391
392
393
394
395
396

397
398
399
400
401
402
403
404
405

406
407
408
409

410
411


412
413
414
415
416
417
418
...
455
456
457
458
459
460
461

462
463
464
465
466
467
468
...
475
476
477
478
479
480
481

482
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497
498
499

500
501
502
503
504
505
506
507
508
509
510
511
512








513
514
515
516
517
518
519
...
540
541
542
543
544
545
546


547
548
549
550
551
552
553
554
555
556
557
558
559
...
591
592
593
594
595
596
597



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616

617
618

619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668

669
670

671
672
673
674
675
676
677
// as per https://stackoverflow.com/questions/8274588/c2977-stdtuple-too-many-template-arguments-msvc11
// where for some reason MSVC 2011 defines it as 5... >_>

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && _VARIADIC_MAX < 9)
    #pragma message CXXO_WARNING(" low number of template arguments - set _VARIADIC_MAX to 9 or more")
#endif

//
// is_tuple -- for specializations of calls based on tuples in C++03




namespace cxxomfort { namespace library {
namespace tuple {

    using cxxomfort::impl::is_tuple;
    using cxxomfort::impl::tuple_count_type;
    using cxxomfort::impl::tuple_index;





























//
// tuple2array
//




template <typename Tuple>
struct _tuple2array_cnv_t {
    // Tuple is a tuple
    static_assert (is_tuple<Tuple>::value, "tuple_to_array: T must be a tuple");
    typedef /* typename std::decay<Tuple>::type */ Tuple InTuple;
    static const size_t _S = std::tuple_size<InTuple>::value;
................................................................................
};

template <typename T>
_tuple2array_cnv_t<T> tuple2array (T const& t) {
    return _tuple2array_cnv_t<T>(t);
}




//
// tuple2array
//

/*
 * array to tuple
 */




template <typename T> struct tuple_of_array_size;

template <typename T0> struct tuple_of_array_size< std::array<T0,1> > {
    typedef std::tuple<T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,2> > {
................................................................................
};

template <typename T, size_t N>
_array2tuple_cnv_t<std::array<T,N> > array2tuple (std::array<T,N> const& a) {
    return _array2tuple_cnv_t< std::array<T,N> >(a);
}













/**
 * @brief Convert from tuple type to function signature.
 * @ingroup cxxo-sup-tuple
 * 
 * Given a tuple of the form T<T1,T2,...>,
 * obtain a function signature Ret(T1,T2,...) 
................................................................................
        typename T5, typename T6, typename R>
    struct function2tuple_t<R(T0,T1,T2,T3,T4,T5,T6)> {
        typedef std::tuple<T0,T1,T2,T3,T4,T5,T6> type;
    };

#endif





// 
// tuple_pop
// 




#ifdef DOXYGEN_DOC
/**
 * @brief Removes the last type from a tuple
 * @ingroup cxxo-sup-tuple
 * @param tu A @c std::tuple of N+1 elements.
 * @return A tuple of N elements.
................................................................................
 * 
 * If @a tu is a tuple with only one element, @c tuple_pop returns an empty tuple.
 * 
 * In C++03, @c tuple_pop works with tuples of up to six (6) (seis) types.
 * 
 */
template <typename... TArgs, typename TLast>

std::tuple<TArgs...> tuple_pop (std::tuple<TArgs..., TLast> const& tu);

#endif

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename... Args, typename Az, size_t... Indices>
std::tuple<Args...> tuple_pop_impl 

(std::tuple<Args...,Az> const& _tuple, std::index_sequence<Indices...> ) {
	using namespace std;
	return make_tuple( get<Indices>(_tuple)...);
}


//! Pops (discards) the rightmost type in a tuple.
//! @ingroup independent-utilities
template <typename...Args, typename Az>

std::tuple<Args...> tuple_pop
(std::tuple<Args...,Az> const& _tuple) {
    using namespace std;
    //typedef std::tuple<A1,Args...> TT;

    auto ii = make_index_sequence< sizeof...(Args) /* this discounts Az */ >();
    return tuple_pop_impl ( _tuple, ii);


    //return make_tuple( forward<Args...>(get<Indices + 1>(_tuple)...) );
}


#else
template <typename A0, typename A1>
std::tuple<A0> tuple_pop (std::tuple<A0,A1> const& t) {
................................................................................
#endif // MSVC silliness

// c++03 impl
#endif

// 
// tuple_shift 

// 

#ifdef DOXYGEN_DOC
/**
 * @brief Removes the first type from a tuple
 * @ingroup cxxo-sup-tuple
 * @param tu A @c std::tuple of N+1 elements.
................................................................................
 * If @a tu is a tuple with only one element, @c tuple_shift returns an empty tuple.
 * 
 * In C++03, @c tuple_shift works with tuples of up to six (6) (seis) types.
 * 
 * 
 */
template <typename... TArgs, typename First>

std::tuple<TArgs...> tuple_shift (std::tuple<TFirst, TArgs...> const& tu);

#endif

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename A1, typename... Args, size_t... Indices>
std::tuple<Args...> tuple_shift_impl 

(std::tuple<A1,Args...> const& _tuple, std::index_sequence<Indices...> ) {
	using namespace std;
	return make_tuple( get<Indices+1>(_tuple)...);
}


//! Shifts a tuple one type to the left, discarding the leftmost type.
//! @ingroup independent-utilities
template <typename A1, typename... Args>
std::tuple<Args...> tuple_shift 

(std::tuple<A1,Args...> const& _tuple) {
    using namespace std;
    //typedef std::tuple<A1,Args...> TT;
    auto ii = make_index_sequence< sizeof...(Args) /* this discounts A1 */ >();
    return tuple_shift_impl ( _tuple, ii);
    //return make_tuple( forward<Args...>(get<Indices + 1>(_tuple)...) );
}



#else
// c++03 impl









template <typename A0>
std::tuple<> tuple_shift (std::tuple<A0> const&) {
    return std::make_tuple<>( );
}
template <typename A0, typename A1>
std::tuple<A1> tuple_shift (std::tuple<A0,A1> const& t) {
    using std::get;
................................................................................
    return std::make_tuple( get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
}
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
std::tuple<A1,A2,A3,A4,A5,A6> tuple_shift (std::tuple<A0,A1,A2,A3,A4,A5,A6> const& t) {
    using std::get;
    return std::make_tuple( get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t), get<6>(t) );
}



#endif

// 
// tuple_unshift, tuple_push
// these are basically just taking advantage of std::tuple_cat.
// 

#ifdef DOXYGEN_DOC
/**
 * @brief Returns a tuple with an extra element at the beginning.
 * @ingroup cxxo-sup-tuple
 * @param v An element to be added to a tuple.
................................................................................
template <typename T, typename... TArgs >
std::tuple<Targs...,T> tuple_push (T const& t0, std::tuple<TArgs...> const& tu);


#endif





#if (CXXOMFORT_CXX_STD >= 2011)

template <typename T, typename... TArgs>
std::tuple<T, TArgs...> tuple_unshift 
( T const& v, std::tuple<TArgs...> const& tu) {
	return std::tuple_cat ( std::make_tuple(v), tu);
}

template <typename... TArgs, typename T>
std::tuple<TArgs..., T> tuple_push
( std::tuple<TArgs...> const& tu, T const& v) {
	return std::tuple_cat ( tu, std::make_tuple(v) );
}

#else

namespace detail {

template <typename T, typename TType>

struct tuple_unshift_t {
};


template <typename T>
struct tuple_unshift_t<T, std::tuple<> > {
	typedef std::tuple<T> type;
	typedef std::tuple<> argument_type;
	type operator() (T const& t, argument_type const&) const {
		return std::make_tuple(t);
	}
};

template <typename T, typename T0>
struct tuple_unshift_t<T, std::tuple<T0> > {
	typedef std::tuple<T,T0> type;
	typedef std::tuple<T0> argument_type;
	type operator() (T const& t, argument_type const& tt) const {
		return std::tuple_cat (std::make_tuple(t), tt);
	}
};

template <typename T, typename T0, typename T1>
struct tuple_unshift_t<T, std::tuple<T0,T1> > {
	typedef std::tuple<T,T0,T1> type;
	type operator() (T const& t, std::tuple<T0,T1> const& tt) const {
		return std::tuple_cat (std::make_tuple(t), tt);
	}
};

template <typename T, typename T0, typename T1, typename T2>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2> > {
	typedef std::tuple<T0,T1,T2> argument_type;
	typedef std::tuple<T,T0,T1,T2> type;
	type operator() (T const& t, argument_type const& tt) const {
		return std::tuple_cat (std::make_tuple(t), tt);
	}
};

template <typename T, typename T0, typename T1, typename T2, typename T3>
struct tuple_unshift_t<T, std::tuple<T0,T1,T2,T3> > {
	typedef std::tuple<T0,T1,T2,T3> argument_type;
	typedef std::tuple<T,T0,T1,T2,T3> type;
	type operator() (T const& t, argument_type const& tt) const {
		return std::tuple_cat (std::make_tuple(t), tt);
	}
};


} // detail

template <typename T, typename Tuple>
typename detail::tuple_unshift_t<T,Tuple>::type 

tuple_unshift (T const& v, Tuple const& tt) {
	return detail::tuple_unshift_t<T,Tuple>()(v,tt);

}

#endif


}
}} // cxxomfort::cxxostd







|

>
>
>
>






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




>
>
>







 







>
>








>
>
>







 







|
>

>
>
>
>
>
>
>
>







 







>
>
>




>
>
>







 







>
|






|
>








|
>
|
|

<
>
|
<
>
>







 







>







 







>
|






|
>









|
>













>
>
>
>
>
>
>
>







 







>
>





|







 







>
>
>



|
|
|


|
|
|
|




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

<
>
|
<
>







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
57
58
59
60
61
62
63
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
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
...
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
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
...
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466

467
468

469
470
471
472
473
474
475
476
477
...
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
...
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
...
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689


690
691
692

693
694






695








































696

697
698

699
700
701
702
703
704
705
706
// as per https://stackoverflow.com/questions/8274588/c2977-stdtuple-too-many-template-arguments-msvc11
// where for some reason MSVC 2011 defines it as 5... >_>

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && _VARIADIC_MAX < 9)
    #pragma message CXXO_WARNING(" low number of template arguments - set _VARIADIC_MAX to 9 or more")
#endif

// 
// is_tuple -- for specializations of calls based on tuples in C++03
// tuple_count_type
// tuple_index 
// 

namespace cxxomfort { namespace library {
namespace tuple {

    using cxxomfort::impl::is_tuple;
    using cxxomfort::impl::tuple_count_type;
    using cxxomfort::impl::tuple_index;


}
}} // cxxomfort::library


// 
// tuple meta shift, pop
// 

namespace cxxomfort { namespace library {
namespace tuple {
	using cxxomfort::impl::tuple_shift_t;
	using cxxomfort::impl::tuple_pop_t;
}
}} // cxxomfort::library

// 
// tuple meta unshift, push
// 

namespace cxxomfort { namespace library {
namespace tuple {
	using cxxomfort::impl::tuple_unshift_t;
	using cxxomfort::impl::tuple_push_t;
}
}} // cxxomfort::library


//
// tuple2array
//

namespace cxxomfort { namespace library {
namespace tuple {

template <typename Tuple>
struct _tuple2array_cnv_t {
    // Tuple is a tuple
    static_assert (is_tuple<Tuple>::value, "tuple_to_array: T must be a tuple");
    typedef /* typename std::decay<Tuple>::type */ Tuple InTuple;
    static const size_t _S = std::tuple_size<InTuple>::value;
................................................................................
};

template <typename T>
_tuple2array_cnv_t<T> tuple2array (T const& t) {
    return _tuple2array_cnv_t<T>(t);
}

}
}}

//
// tuple2array
//

/*
 * array to tuple
 */

namespace cxxomfort { namespace library {
namespace tuple {

template <typename T> struct tuple_of_array_size;

template <typename T0> struct tuple_of_array_size< std::array<T0,1> > {
    typedef std::tuple<T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,2> > {
................................................................................
};

template <typename T, size_t N>
_array2tuple_cnv_t<std::array<T,N> > array2tuple (std::array<T,N> const& a) {
    return _array2tuple_cnv_t< std::array<T,N> >(a);
}

}
}}


// 
// tuple to function sig
// 

namespace cxxomfort { namespace library {
namespace tuple {


/**
 * @brief Convert from tuple type to function signature.
 * @ingroup cxxo-sup-tuple
 * 
 * Given a tuple of the form T<T1,T2,...>,
 * obtain a function signature Ret(T1,T2,...) 
................................................................................
        typename T5, typename T6, typename R>
    struct function2tuple_t<R(T0,T1,T2,T3,T4,T5,T6)> {
        typedef std::tuple<T0,T1,T2,T3,T4,T5,T6> type;
    };

#endif

}
}}


// 
// tuple_pop
// 

namespace cxxomfort { namespace library {
namespace tuple {

#ifdef DOXYGEN_DOC
/**
 * @brief Removes the last type from a tuple
 * @ingroup cxxo-sup-tuple
 * @param tu A @c std::tuple of N+1 elements.
 * @return A tuple of N elements.
................................................................................
 * 
 * If @a tu is a tuple with only one element, @c tuple_pop returns an empty tuple.
 * 
 * In C++03, @c tuple_pop works with tuples of up to six (6) (seis) types.
 * 
 */
template <typename... TArgs, typename TLast>
std::tuple<TArgs...> 
tuple_pop (std::tuple<TArgs..., TLast> const& tu);

#endif

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename... Args, typename Az, size_t... Indices>
std::tuple<Args...> 
tuple_pop_impl 
(std::tuple<Args...,Az> const& _tuple, std::index_sequence<Indices...> ) {
	using namespace std;
	return make_tuple( get<Indices>(_tuple)...);
}


//! Pops (discards) the rightmost type in a tuple.
//! @ingroup independent-utilities
template <typename...Args>
typename cxxomfort::impl::tuple_pop_t<std::tuple<Args...> >::type
tuple_pop
(std::tuple<Args...> const& _tuple) {
    using namespace std;

    //typedef typename cxxomfort::impl::tuple_pop_t<std::tuple<Args...> >::type return_type;
    typedef make_index_sequence< sizeof...(Args) -1 > IS;

    IS is;
    return cxxomfort::impl::tuple_pop_t< std::tuple<Args...> >::call(_tuple, is);
    //return make_tuple( forward<Args...>(get<Indices + 1>(_tuple)...) );
}


#else
template <typename A0, typename A1>
std::tuple<A0> tuple_pop (std::tuple<A0,A1> const& t) {
................................................................................
#endif // MSVC silliness

// c++03 impl
#endif

// 
// tuple_shift 
// (removes from the beginning of a tuple)
// 

#ifdef DOXYGEN_DOC
/**
 * @brief Removes the first type from a tuple
 * @ingroup cxxo-sup-tuple
 * @param tu A @c std::tuple of N+1 elements.
................................................................................
 * If @a tu is a tuple with only one element, @c tuple_shift returns an empty tuple.
 * 
 * In C++03, @c tuple_shift works with tuples of up to six (6) (seis) types.
 * 
 * 
 */
template <typename... TArgs, typename First>
std::tuple<TArgs...> 
tuple_shift (std::tuple<TFirst, TArgs...> const& tu);

#endif

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename A1, typename... Args, size_t... Indices>
std::tuple<Args...> 
tuple_shift_impl 
(std::tuple<A1,Args...> const& _tuple, std::index_sequence<Indices...> ) {
	using namespace std;
	return make_tuple( get<Indices+1>(_tuple)...);
}


//! Shifts a tuple one type to the left, discarding the leftmost type.
//! @ingroup independent-utilities
template <typename A1, typename... Args>
std::tuple<Args...> 
tuple_shift 
(std::tuple<A1,Args...> const& _tuple) {
    using namespace std;
    //typedef std::tuple<A1,Args...> TT;
    auto ii = make_index_sequence< sizeof...(Args) /* this discounts A1 */ >();
    return tuple_shift_impl ( _tuple, ii);
    //return make_tuple( forward<Args...>(get<Indices + 1>(_tuple)...) );
}



#else
// c++03 impl

template <typename Tuple>
typename cxxomfort::impl::tuple_shift_t<Tuple>::type 
tuple_shift (Tuple const& tu) {
	return cxxomfort::impl::tuple_shift_t<Tuple>::call(tu);
};


/*
template <typename A0>
std::tuple<> tuple_shift (std::tuple<A0> const&) {
    return std::make_tuple<>( );
}
template <typename A0, typename A1>
std::tuple<A1> tuple_shift (std::tuple<A0,A1> const& t) {
    using std::get;
................................................................................
    return std::make_tuple( get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
}
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
std::tuple<A1,A2,A3,A4,A5,A6> tuple_shift (std::tuple<A0,A1,A2,A3,A4,A5,A6> const& t) {
    using std::get;
    return std::make_tuple( get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t), get<6>(t) );
}

*/

#endif

// 
// tuple_unshift, tuple_push
// these are basically just taking advantage of std::tuple_cat in C++11.
// 

#ifdef DOXYGEN_DOC
/**
 * @brief Returns a tuple with an extra element at the beginning.
 * @ingroup cxxo-sup-tuple
 * @param v An element to be added to a tuple.
................................................................................
template <typename T, typename... TArgs >
std::tuple<Targs...,T> tuple_push (T const& t0, std::tuple<TArgs...> const& tu);


#endif


// tuple_unshift (adds at the beginning)
// tuple_push (adds at the end, is basically tuple_cat)

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename T, typename... TArgs>
std::tuple<T, TArgs...> 
tuple_unshift ( T const& tx, std::tuple<TArgs...> const& tu) {
	return cxxomfort::impl::tuple_unshift_t<T,std::tuple<TArgs...>>::call(tx,tu);
}

template <typename T, typename Tuple>
typename cxxomfort::impl::tuple_push_t<T,Tuple>::type 
tuple_push (T const& tx, Tuple const& tu) {
	return cxxomfort::impl::tuple_push_t<T,Tuple>::call(tx,tu);
}

#else



template <typename T, typename Tuple>
typename cxxomfort::impl::tuple_unshift_t<T,Tuple>::type 
tuple_unshift (T const& v, Tuple const& tu) {

	return cxxomfort::impl::tuple_unshift_t<T,Tuple>::call(v,tu);
}















































template <typename T, typename Tuple>

typename cxxomfort::impl::tuple_push_t<T,Tuple>::type 
tuple_push (T const& v, Tuple const& tu) {

	return cxxomfort::impl::tuple_push_t<T,Tuple>::call(v,tu);
}

#endif


}
}} // cxxomfort::cxxostd

Changes to cxxomfort/cxxomfort/library/type_name.hpp.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/config.hpp>
#include <cxxomfort/type_traits.hpp> // remove_reference, etc
#include <cxxomfort/string_view.hpp>
#include <cxxomfort/memory.hpp>
#include "../util/type_traits.hpp"
#include <string>
// #include <typeinfo> // user now has to include it explicitly

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
	#define CXXO_has_cxx_demangle 1
#endif
//#include <iostream> // debug only







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/config.hpp>
#include <cxxomfort/type_traits.hpp> // remove_reference, etc
#include <cxxomfort/string_view.hpp>
#include <cxxomfort/memory.hpp>
#include "../impl/07-type_traits.hpp"
#include <string>
// #include <typeinfo> // user now has to include it explicitly

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
	#define CXXO_has_cxx_demangle 1
#endif
//#include <iostream> // debug only

Changes to cxxomfort/cxxomfort/library/type_traits.hpp.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 *
 * */
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair
#include <cxxomfort/cstddef.hpp> // byte
#include <cxxomfort/array.hpp> // array
#include "sequences.hpp"

#include "../impl/character.hpp"


namespace cxxomfort{ namespace library{
namespace type_traits{

using cxxomfort::impl::type_traits::is_character_type;
................................................................................
template <typename A, typename B> struct is_std_pair< std::pair<A,B> >: std::true_type {};

// is_fundamental_wrapper


#if (CXXOMFORT_CXX_STD>=1997)
// using others from other facilities
using ::cxxomfort::is_std_array;
//using ::cxxomfort::library::string::is_std_basic_string;
using ::cxxomfort::library::tuple::is_tuple;
//using ::cxxomfort::library::is_typesafe_enum;
#endif

/**
 * @brief type_trait that identifies @c enum s , <code>enum class</code> es and typesafe_enums.







<







 







|







17
18
19
20
21
22
23

24
25
26
27
28
29
30
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 *
 * */
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair
#include <cxxomfort/cstddef.hpp> // byte
#include <cxxomfort/array.hpp> // array
#include "sequences.hpp"

#include "../impl/character.hpp"


namespace cxxomfort{ namespace library{
namespace type_traits{

using cxxomfort::impl::type_traits::is_character_type;
................................................................................
template <typename A, typename B> struct is_std_pair< std::pair<A,B> >: std::true_type {};

// is_fundamental_wrapper


#if (CXXOMFORT_CXX_STD>=1997)
// using others from other facilities
using ::cxxomfort::library::is_std_array;
//using ::cxxomfort::library::string::is_std_basic_string;
using ::cxxomfort::library::tuple::is_tuple;
//using ::cxxomfort::library::is_typesafe_enum;
#endif

/**
 * @brief type_trait that identifies @c enum s , <code>enum class</code> es and typesafe_enums.

Changes to cxxomfort/cxxomfort/library/typesafe_enum.hpp.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 @file
 @author Luis Machuca Bezzaza
 @see http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 @see http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using/11856721#11856721
**/
#include <cxxomfort/base.hpp>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/typesafe_enum-core.hpp>
//#include <cxxomfort/using.hpp>

/*
 * Usage is as follows:
 */
#if 0 







|







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 @file
 @author Luis Machuca Bezzaza
 @see http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 @see http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using/11856721#11856721
**/
#include <cxxomfort/base.hpp>
#include <cxxomfort/impl/07-type_traits.hpp>
#include <cxxomfort/impl/typesafe_enum-core.hpp>
//#include <cxxomfort/using.hpp>

/*
 * Usage is as follows:
 */
#if 0 

Changes to cxxomfort/cxxomfort/limits.hpp.

38
39
40
41
42
43
44
45































46
47
48
49
50
51
52
..
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
101
struct log_<0, base> {
    enum { value = 0 };
};


}

//! @ingroup independent-features































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_>           \
................................................................................
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


}




#endif

/**
 * @page std0limits <limits>
 * @brief Backports from <limits>
 * 





 * Interfaces defined here:
 *
 * (none from Standard C++)
 * 
 * Non-backport interfaces:
 * 
 * * @c @ref integral_limits 
 * 
 *
 * @section also See Also
 * 
 * * @see @cppref{header/limits} (cppreference)
 *
 * */







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







 







>
|
>
>






|

>
>
>
>
>




|

|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
...
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
struct log_<0, base> {
    enum { value = 0 };
};


}

namespace fix { 

/**
 * @brief An extension to <tt>numeric_limits</tt> that deals specifically with integer-like types.
 * @ingroup cxxomfort-fix
 * 
 * For a given integral or integer-like type @a Ty , <tt>integral_limits<Ty></tt> 
 * provides an interface to <tt>std::numeric_limits<Ty></tt> and in fact 
 * inherits from the latter. The interface is expanded to add some useful information 
 * about the integral type that is only available at compile time as macros 
 * pre-C++11.
 * 
 * <tt>integral_limits</tt> provides the following new members: 
 * 
 * * @c const_min - minimum value as a value (<tt>::min</tt> is constexpr in C++>=11).
 * * @c const_max - maximum value as a value (<tt>::max</tt> is constexpr in C++>=11).
 * * @c digits_base<N> - the total number of digits required to represent any value in the given base.
 * 
 * @e Pending members : 
 * 
 * * @c narrower_type - an alias to the next smaller integral type of the same signedness.
 * * @c wider_type - an alias to the next larger integral type of the same signedness.
 * * @c lo_mask - an integral value that can be AND-ed with this type to keep only the lower bits.
 * * @c hi_mask - an integral value that can be AND-ed with this type to keep only the higher bits.
 * 
 * @subsection Specializations 
 * 
 * cxxomfort provides specializations of the new <tt>integral_limits</tt> for 
 * all the types that are defined as integral. The list explicitly includes: 
 * short, int, long, long long 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_>           \
................................................................................
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



#endif

/**
 * @page std0limits <limits>
 * @brief Backports related to Standard header <tt><limits></tt> 
 * 
 * @code
 * #include <cxxomfort/limits.hpp>
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined here:
 *
 * (none from Standard C++)
 * 
 * Non-backport interfaces (<tt>cxxomfort::fix</tt>):
 * 
 * * @link cxxomfort::fix::integral_limits <tt>integral_limits</tt> @endlink - Allows access to the constant values of integral_limits in C++ < C++11.
 * 
 *
 * @section also See Also
 * 
 * * @see @cppref{header/limits} (cppreference)
 *
 * */

Changes to cxxomfort/cxxomfort/numeric.hpp.

77
78
79
80
81
82
83




84
85
86
87
88
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
127
}


template <typename T>
CXXO_CONSTEXPR T* midpoint (T* p1, T* p2) CXXO_NOEXCEPTNOTHROW {
	return p1+(p2-p1)/2;
}




#endif

	
} // numeric
}


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

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_std_cxx11_algorithms == 0)
    namespace std {
        using ::cxxomfort::cxxostd::iota;
    }
    #endif // c++

#endif // std using

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2017)
    namespace std {
        using ::cxxomfort::cxxostd::gcd;
        using ::cxxomfort::cxxostd::lcm;
    }
    #endif
#endif // no std using

#if defined(CXXOMFORT_USING_midpoint)
namespace std {
	using ::cxxomfort::cxxostd::midpoint;
}
	#undef CXXOMFORT_USING_midpoint
#endif



#endif

/**
 * @page std0numeric <numeric>
 * @brief Backports related to Standard header <tt><numeric></tt> 
 * 







>
>
>
>



|
<



|










<
<
<
<






<

|
|
|
|
<
|
>
>







77
78
79
80
81
82
83
84
85
86
87
88
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 T>
CXXO_CONSTEXPR T* midpoint (T* p1, T* p2) CXXO_NOEXCEPTNOTHROW {
	return p1+(p2-p1)/2;
}
#else

using std::midpoint;

#endif

	
} } // cxxomfort::cxxostd



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

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_std_cxx11_algorithms == 0)
    namespace std {
        using ::cxxomfort::cxxostd::iota;
    }
    #endif // c++





    #if (CXXOMFORT_CXX_STD < 2017)
    namespace std {
        using ::cxxomfort::cxxostd::gcd;
        using ::cxxomfort::cxxostd::lcm;
    }
    #endif


    #if (CXXOMFORT_CXX_STD < 2020 || defined(CXXOMFORT_USING_midpoint))
    namespace std {
        using ::cxxomfort::cxxostd::midpoint;
    }

    #endif

#endif // std using

#endif

/**
 * @page std0numeric <numeric>
 * @brief Backports related to Standard header <tt><numeric></tt> 
 * 

Added cxxomfort/cxxomfort/ostream.hpp.































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef CXXOMFORT_OSTREAM_HPP
#define CXXOMFORT_OSTREAM_HPP
/**
 * @file cxxomfort/ostream.hpp
 * @brief Implementations, Backports and helpers for Standard header <code>\<ostream\></code>.
 * @xrefitem std0ostream "<ostream>" "Header"
 * 
 * 
 */

#include "base.hpp"
#include CXXO_INCLUDE_SYS(ostream)



/*
 * 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)

namespace cxxomfort { namespace cxxostd {

template <typename Ch, typename ChTraits>
std::basic_ostream<Ch, ChTraits>&
operator<<  
(std::basic_ostream<Ch, ChTraits>& os
, basic_string_view<Ch, ChTraits> const v) CXXO_NOEXCEPTNOTHROW {
    using namespace std;
    //size_t const n= max(static_cast<size_t>(os.width()), v.size());
    //os.rdbuf()->sputn(v.data(), n);
    for (size_t i= 0; i < v.size(); ++i) { os<< v[i]; }
    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>
 * @brief Backports related to Standard header <tt><ostream></tt>
 * 
 * @code
 * #include <cxxomfort/ostream.hpp>
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 *
 * Interfaces defined in this section:
 * 
 * * <tt>operator<< (ostream&, T const&)</tt> for the following types T: 
 *   * <tt>unique_ptr<T></tt>
 *   * <tt>shared_ptr<T></tt>
 *   * <tt>std::byte</tt>
 * 
 *
 * @section also See Also
 * 
 * @see @cppref{header/ostream} (cppreference)
 * 
 * */

Changes to cxxomfort/cxxomfort/random.hpp.

181
182
183
184
185
186
187

188
189
190
191
192
193
194
...
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
// randmo 
// 
namespace cxxomfort { namespace fix {

// from https://stackoverflow.com/questions/10984974/why-do-people-say-there-is-modulo-bias-when-using-a-random-number-generator
/**
 * @brief Invokes @c rand and rids of some of the bias from the modulo.

 * @param mo An integer.
 * @returns An integer in the range <tt>[0, mo)</tt>.
 * @throws None.
 * */
static inline int randmo (int mo) CXXO_NOEXCEPTNOTHROW {
	int x= 0;
	do {
................................................................................


} }


/**
 * @page std0random <random>
 * @brief Backports from <random>
 * 







 * Including the header brings up <random>'s features, accounting for eg.: 
 * location being @c std::tr1::random... where set up in C++03.

 * 
 * Interfaces defined in this section:
 * 
 * * @c linear_congruent_engine , @c minstd , @c minstd0 (C++11).
 * * @c shuffle_order_engine , @c knuth_b  (C++11).
 * * @link cxxomfort::cxxostd::default_random_engine @c default_random_engine @endlink - in cxxomfort defined as ranlux24_base for C++03.
 * 


 * Fix (non-backport) interfaces:
 * 


 * * <tt>cxxomfort::fix::randmo()</tt> - modulo-respecting call to <tt>rand()</tt>.
 * * <tt>cxxomfort::fix::shuffle_order_engine</tt> - for broken std in MSVC 2010.
 * * @c cxxomfort::fix::knuth_b - for broken std in MSVC 2010.
 *
 * Pending:
 * 
 * * @c generate_canonical complementary (C++11).
 * * @c uniform_int_distribution complementary (C++11).
 * * @c discrete_distribution complementary (C++11).
 *
 * See also: @ref cxxo-sup-random (supplemental), 
 * <a href="https://en.cppreference.com/w/cpp/header/random">\<random\> \@cppreference</a>.
 * 
 * */







>







 







|

>
>
>
>
>
>
>

|
>



<
<


>
>
|

>
>
|













181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
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
// randmo 
// 
namespace cxxomfort { namespace fix {

// from https://stackoverflow.com/questions/10984974/why-do-people-say-there-is-modulo-bias-when-using-a-random-number-generator
/**
 * @brief Invokes @c rand and rids of some of the bias from the modulo.
 * @ingroup cxxomfort-fix
 * @param mo An integer.
 * @returns An integer in the range <tt>[0, mo)</tt>.
 * @throws None.
 * */
static inline int randmo (int mo) CXXO_NOEXCEPTNOTHROW {
	int x= 0;
	do {
................................................................................


} }


/**
 * @page std0random <random>
 * @brief Backports related to Standard Header <tt><random></tt>
 * 
 * @code
 * #include <cxxomfort/random.hpp>
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined in this section:
 * 
 * Including the header brings up <random>'s features, accounting for eg.: 
 * location being @c std::tr1::random... where set up in C++03, 
 * as well as its names back then varying according to the compiler.
 * 
 * Interfaces defined in this section:
 * 


 * * @link cxxomfort::cxxostd::default_random_engine @c default_random_engine @endlink - in cxxomfort defined as ranlux24_base for C++03.
 * 
 * Interfaces repointed here:
 * 
 * * @c linear_congruent_engine , @c minstd , @c minstd0 , when they are brought with different name.
 * 
 * Fixes / non-backport interfaces (<tt>cxxomfort::fix</tt>):
 * 
 * * <tt>randmo()</tt> - modulo-respecting call to <tt>rand()</tt>.
 * * <tt>cxxomfort::fix::shuffle_order_engine</tt> - for broken std in MSVC 2010.
 * * @c cxxomfort::fix::knuth_b - for broken std in MSVC 2010.
 *
 * Pending:
 * 
 * * @c generate_canonical complementary (C++11).
 * * @c uniform_int_distribution complementary (C++11).
 * * @c discrete_distribution complementary (C++11).
 *
 * See also: @ref cxxo-sup-random (supplemental), 
 * <a href="https://en.cppreference.com/w/cpp/header/random">\<random\> \@cppreference</a>.
 * 
 * */

Changes to cxxomfort/cxxomfort/string.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
..
59
60
61
62
63
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
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

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

#if (CXXOMFORT_CXX_STD >= 1997)

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

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

namespace cxxomfort {
namespace cxxostd {
}
}

	#include "impl/11-to_string.hpp"
	#include "impl/11-basic_string_charn.hpp"
	//#include "impl/14-string_literal.hpp"



	#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)

// #include "impl/11-basic_string_hash.hpp"

		#include <functional>

................................................................................
        }    
    };
    
}
	// compilers that don't have hash<> 
		#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,<1500))
		#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_OW,<9999))
		#else
    // GCC (c++03) does not have u16string, u32string 
namespace std { namespace tr1 {

    template<> 
    struct hash< std::u16string > {
        typedef std::u16string argument_type;
        typedef size_t result_type;
        result_type operator()(argument_type const& s) const CXXO_NOEXCEPTNOTHROW   {
            using namespace std;
            size_t const MS = (sizeof(size_t) - sizeof(char16_t) + 1) * CHAR_BIT;
            size_t r= s.length(), wi= 1;
            for ( size_t i= 0; i < s.length(); ++i, wi<<=1 ) {
                r ^= (static_cast<size_t>(s[i]) * wi);
                if (wi<<2 > MS ) { wi= 1; }
            }
            return r;
        }    
    };
    
    template<> 
    struct hash< std::u32string > {
        typedef std::u32string argument_type;
        typedef size_t result_type;
        result_type operator()(argument_type const& s) const CXXO_NOEXCEPTNOTHROW   {
            using namespace std;
            size_t const MS = (sizeof(size_t) - sizeof(char32_t) + 1) * CHAR_BIT;
            size_t r= s.length(), wi= 1;
            for ( size_t i= 0; i < s.length(); ++i, wi<<=1 ) {
                r ^= (static_cast<size_t>(s[i]) * wi);
                if (wi<<2 > MS ) { wi= 1; }
            }
            return r;
        }    
    };
    

} } // std::tr1

		
		#endif // gcc

	#endif // pre-2011


#else // CXX_STD

	#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































































#endif // file

/**
 * @page std0string <string>
 * @brief Backports related to Standard header <tt><string></tt>
 * 







<



|










<
<







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





|

|






<












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







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
..
56
57
58
59
60
61
62
63







































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
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

#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 {
}
}

	#include "impl/11-to_string.hpp"
	#include "impl/11-basic_string_charn.hpp"
	//#include "impl/14-string_literal.hpp"



	#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)

// #include "impl/11-basic_string_hash.hpp"

		#include <functional>

................................................................................
        }    
    };
    
}
	// compilers that don't have hash<> 
		#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,<1500))
		#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_OW,<9999))
		#elif (0)    







































		#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>
// 

	#if (CXXOMFORT_CXX_STD>=2011)
	#elif (CXXOMFORT_CXX_STD>=1997)
		#include <cxxomfort/functional.hpp>

		#if (0 && (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG))
			#include <tr1/functional>
namespace std { namespace tr1 { 
		#elif (0 && (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC))
namespace std {
		#else
CXXO_STDTR1_OPEN()
		#endif

template <> 
struct hash<std::u16string> {
	typedef std::u16string argument_type;
	typedef size_t result_type;
	result_type operator() (argument_type const& s) const CXXO_NOEXCEPTNOTHROW   {
		using namespace std;
		size_t const MS = (sizeof(size_t) - sizeof(char16_t) + 1) * CHAR_BIT;
		size_t r= s.length(), wi= 1;
		for ( size_t i= 0; i < s.length(); ++i, wi<<=1 ) {
			r ^= (static_cast<size_t>(s[i]) * wi);
			if (wi<<2 > MS ) { wi= 1; }
		}
		return r;
	}    
};

template<> 
struct hash< std::u32string > {
	typedef std::u32string argument_type;
	typedef size_t result_type;
	result_type operator()(argument_type const& s) const CXXO_NOEXCEPTNOTHROW   {
		using namespace std;
		size_t const MS = (sizeof(size_t) - sizeof(char32_t) + 1) * CHAR_BIT;
		size_t r= s.length(), wi= 1;
		for ( size_t i= 0; i < s.length(); ++i, wi<<=1 ) {
			r ^= (static_cast<size_t>(s[i]) * wi);
			if (wi<<2 > MS ) { wi= 1; }
		}
		return r;
	}    
};

		#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
} }
		#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
}
		#else
CXXO_STDTR1_CLOSE()
		#endif

	#else // < 1997
	#endif


#endif // file

/**
 * @page std0string <string>
 * @brief Backports related to Standard header <tt><string></tt>
 * 

Changes to cxxomfort/cxxomfort/string_view.hpp.

64
65
66
67
68
69
70

71
72
73
74
75
76
77
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined here:
 * 
 * * @c @link cxxomfort::cxxostd::basic_string_view basic_string_view @endlink (C++17).
 * * the related typedefs eg.: @c string_view .

 * 
 * For differences between the implementation of <tt>string_view</tt> 
 * here vs standard, check the notices at <tt> @link cxxomfort::cxxostd::basic_string_view basic_string_view @endlink </tt>
 * Fix (non-backport) interfaces:
 * 
 * * @c cxxomfort::fix::make_string_view() - Makes a @c string_view from a std::string or a literal string.
 * 







>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 * @endcode
 * 
 * (or automatically by including <tt><cxxomfort/backports.hpp></tt> / <tt><cxxomfort/cxxomfort.hpp></tt>)
 * Interfaces defined here:
 * 
 * * @c @link cxxomfort::cxxostd::basic_string_view basic_string_view @endlink (C++17).
 * * the related typedefs eg.: @c string_view .
 * * @c CXXOMFORT_IMPLEMENTS_stdheader_string_view - implementation status for the above.
 * 
 * For differences between the implementation of <tt>string_view</tt> 
 * here vs standard, check the notices at <tt> @link cxxomfort::cxxostd::basic_string_view basic_string_view @endlink </tt>
 * Fix (non-backport) interfaces:
 * 
 * * @c cxxomfort::fix::make_string_view() - Makes a @c string_view from a std::string or a literal string.
 * 

Changes to cxxomfort/cxxomfort/tuple.hpp.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
..
79
80
81
82
83
84
85





86
87
88
89
90
91
92
		using tr1::make_tuple;
		//using tr1::tuple_cat;

	}

	// backport tuple_cat

	namespace std {

	template <typename A0, typename B0>
	tuple<A0,B0>
	tuple_cat (tuple<A0> const& a, tuple<B0> const& b) {
		return make_tuple(get<0>(a), get<0>(b) );
	}

	template <typename A0, typename B0, typename B1>
	tuple<A0,B0,B1>
	tuple_cat (tuple<A0> const& a, tuple<B0,B1> const& b) {
		return make_tuple(get<0>(a), get<0>(b), get<1>(b) );
	}

	template <typename A0, typename A1, typename B0, typename B1>
	tuple<A0,A1,B0,B1>
	tuple_cat (tuple<A0,A1> const& a, tuple<B0,B1> const& b) {
		return make_tuple(get<0>(a), get<1>(a), get<0>(b), get<1>(b) );
	}

	}

	#endif

namespace cxxomfort {
namespace cxxostd {


} //cxxomfort::cxxostd
................................................................................

#else // CXX_STD < 1997

	#pragma message CXXO_NOTICE("<tuple> not supported")

#endif // CXX_STD






// 
// get<type>(tuple)
// 

#include "impl/14-tuple_get_type.hpp" // std::get<T> (tuple<>)









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







 







>
>
>
>
>







42
43
44
45
46
47
48






















49
50
51
52
53
54
55
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
		using tr1::make_tuple;
		//using tr1::tuple_cat;

	}

	// backport tuple_cat























	#endif

namespace cxxomfort {
namespace cxxostd {


} //cxxomfort::cxxostd
................................................................................

#else // CXX_STD < 1997

	#pragma message CXXO_NOTICE("<tuple> not supported")

#endif // CXX_STD

// 
// support stuff
// 
#include "impl/tuplemeta.hpp"

// 
// get<type>(tuple)
// 

#include "impl/14-tuple_get_type.hpp" // std::get<T> (tuple<>)


Changes to cxxomfort/cxxomfort/type_traits.hpp.

6
7
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
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
...
115
116
117
118
119
120
121
122
123
124
125






126
127




































128
129
130
131
132
133
134
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
282
283
284
285
286
287
288









289
290
291
292
293
294
295
...
299
300
301
302
303
304
305












306
307
308
309
310
311
312
...
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
...
674
675
676
677
678
679
680
681
682



683
684
685


686
687


688
689
690
691
692
693
694
695
696
697
 * @ingroup cxx11-backports
 * @xrefitem std0type_traits "" ""
 * 
 */

#include "config.hpp"
#include "base.hpp"


#if (CXXOMFORT_CXX_STD>=2014)
	#include <type_traits>
#elif (CXXOMFORT_CXX_STD>=2011)
	#include <type_traits>

#elif (CXXOMFORT_CXX_STD>=1997 && CXXO_COMPILER_SUPPORT_tr1_type_traits>0)






	
	// 
	// compilers that at least take some decent c++03
	// 
	
	#include "impl/11-conditional.hpp"
	#include "util/type_traits.hpp"
	#include "util/meta.hpp" // enable_if etc

	// we need to find a <type_traits> header. In GCC,
	// we depend on a wrapper like tr1_fwd set up to enable us
	// to directly include the header
	#include <type_traits>

	#include "impl/using_tr1_type_traits.hpp"


	#include "impl/11-decay.hpp"
	#include "impl/11-underlying_type.hpp"
	#include "impl/11-common_type.hpp"
................................................................................
	//
	
	#include "impl/11-conditional.hpp"
	#if defined(CXXOMFORT_USE_INTERNAL_TR1)
		#if (CXXOMFORT_NOTICES > 2)
			#pragma message CXXO_NOTICE("internal TR1: <type_traits>")
		#endif
		#include "util/type_traits.hpp" // at least the basic traits

namespace std {
	using ::cxxomfort::traits::integral_constant;
	using ::cxxomfort::traits::false_type;
	using ::cxxomfort::traits::true_type;
	using ::cxxomfort::traits::is_same;

................................................................................
	#include "impl/11-is_tn_xble.hpp"


#endif // CXX_STD


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








#if (CXXOMFORT_CXX_STD>=1997)






































/*
 * TR1 traits missing in c++03 in implementations
 * is_literal_type, is_trivial, etc
 */


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

#if defined(CXXO_LACKS_make_signed)
namespace std { namespace tr1 {
    using cxxomfort::traits::make_signed;
    using cxxomfort::traits::make_unsigned;
} }
#endif // bring missing make_signed, make_unsigned to tr1

//#include "using.hpp" // bring TR1 in


//
// lvalue_reference traits mirrored in C++03 mode
//

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)
    #define CXXO_MIRROR_LVALUE_REFERENCE 1
................................................................................



/*
 * is_trivial, is_literal
 * 
 * */
/*
 * is_trivial, is_literal_type
 */
#if (CXXOMFORT_CXX_STD>=1997 && CXXOMFORT_CXX_STD < 2011)

    // for is_trivial is_literal
    #if 0
    #elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
        #if (CXXOMFORT_CXX_STD < 2011)
        #define CXXO_enable_is_trivial 1
................................................................................
#undef CXXO_enable_is_trivial
#undef CXXO_enable_is_literal

}
#endif // c++11 mode or type_traits emulation












/*
 * make_void (c++17)
 */
#include "impl/17-void_t.hpp"


................................................................................
#include "impl/17-bool_constant.hpp"

/*
 * endian (c++20)
 */
#include "impl/20-endian.hpp"














//
// is_trivially_... missing in GCC 4.7 despite announcing C++11 mode
//

#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC , < 404) && CXXOMFORT_CXX_EMULATION==2011)
namespace std {
................................................................................

    > {
    };
} // namespace
#endif


/*
 * remove_cvref, from c++20
 * */

namespace std {

template< class T >
struct remove_cvref 
: public remove_cv < typename remove_reference<T>::type > 
{
};

} // std

#else // CXX_STD < 1997

	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
		#include <cxxomfort/config/ow/type_traits>
	#endif

	#include <cxxomfort/util/type_traits.hpp>
	
namespace std {
	using namespace cxxomfort::traits;
}


#endif // CXX_STD >= 1997
................................................................................
 * * @e is_nothrow_ family of traits.
 * * @ref @c is_trivial , @ref @c is_literal_type (C++11).
 * * @c is_null_pointer (C++14) - identifies @c std::nullptr_t .
 * * @c void_t , @c make_void - generic, type-absorbing @c void transformations (C++17).
 * * @ref @c cxxomfort::cxxostd::bool_constant "std::bool_constant"  (C++17).
 * * @c @ref remove_cvref (C++20).
 * 
 * Non-backport interfaces:
 * 



 * * @ref @c cxxomfort::fix::common_type - implements "variadic" @c common_type in MSVC 2010, MSVC 2012 where it has issues, or refers to @c std::common_type otherwise.
 * 
 * @attention General notes:


 * * A number of traits depend on <b>compiler intrinsics</b>. If they are not available, the library does not compile correctly.
 * * In compilers without at least @c \_\_typeof__ support, @c common_type may not resolve correctly.


 * * In older compilers @c underlying_type may not resolve correctly.
 * 
 * 
 * See also @link cxxo-sup-type_traits Supplemental type_traits @endlink for other 
 * traits and transformations available in cxxomfort.
 * 
 * General notes:
 * 
 * 
 */







>







>
>
>
>
>
>





|
<


<
<
<
<







 







|







 







|



>
>
>
>
>
>


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







 







<
<
<







 







<
<
<







 







>
>
>
>
>
>
>
>
>







 







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







 







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






|







 







|

>
>
>
|


>
>
|
|
>
>
|









6
7
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
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
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
171
172
173
174
175
176
177
178
...
195
196
197
198
199
200
201



202
203
204
205
206
207
208
...
236
237
238
239
240
241
242



243
244
245
246
247
248
249
...
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
...
682
683
684
685
686
687
688














689
690
691
692
693
694
695
696
697
698
699
700
701
702
...
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
 * @ingroup cxx11-backports
 * @xrefitem std0type_traits "" ""
 * 
 */

#include "config.hpp"
#include "base.hpp"
#include "impl/07-type_traits.hpp"

#if (CXXOMFORT_CXX_STD>=2014)
	#include <type_traits>
#elif (CXXOMFORT_CXX_STD>=2011)
	#include <type_traits>

#elif (CXXOMFORT_CXX_STD>=1997 && CXXO_COMPILER_SUPPORT_tr1_type_traits>0)

	#if (CXXOFLAG_directory_tr1)
		#include <tr1/type_traits>
	#else
		#include <type_traits>
	#endif
	
	// 
	// compilers that at least take some decent c++03
	// 
	
	#include "impl/11-conditional.hpp"	

	#include "util/meta.hpp" // enable_if etc






	#include "impl/using_tr1_type_traits.hpp"


	#include "impl/11-decay.hpp"
	#include "impl/11-underlying_type.hpp"
	#include "impl/11-common_type.hpp"
................................................................................
	//
	
	#include "impl/11-conditional.hpp"
	#if defined(CXXOMFORT_USE_INTERNAL_TR1)
		#if (CXXOMFORT_NOTICES > 2)
			#pragma message CXXO_NOTICE("internal TR1: <type_traits>")
		#endif
		#include "impl/07-type_traits.hpp" // at least the basic traits

namespace std {
	using ::cxxomfort::traits::integral_constant;
	using ::cxxomfort::traits::false_type;
	using ::cxxomfort::traits::true_type;
	using ::cxxomfort::traits::is_same;

................................................................................
	#include "impl/11-is_tn_xble.hpp"


#endif // CXX_STD


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


#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 {

template <typename T, T t>
inline T to_integral (std::integral_constant<T,t>) CXXO_NOEXCEPTNOTHROW {
	return t;
}

CXXO_CONSTEXPR inline bool to_bool (std::false_type) CXXO_NOEXCEPTNOTHROW { return false; }
CXXO_CONSTEXPR inline bool to_bool (std::true_type) CXXO_NOEXCEPTNOTHROW { return true; }


}} // cxxomfort::fix

/*
 * remove_cvref, from c++20
 * */

#if (CXXOMFORT_CXX_STD>=2020)
	#define CXXOMFORT_IMPLEMENTS_p0550 CXXO_IMPLSTATUS_NATIVE()
#else
	#define CXXOMFORT_IMPLEMENTS_p0550 CXXO_IMPLSTATUS_BACKPORT()
namespace std {
	using ::cxxomfort::traits::remove_cvref;
}

#endif

#define CXXOMFORT_IMPLEMENTS_std_remove_cvref CXXOMFORT_IMPLEMENTS_p0550


/*
 * TR1 traits missing in c++03 in implementations
 * is_literal_type, is_trivial, etc
 */


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

#if defined(CXXO_LACKS_make_signed)
namespace std { namespace tr1 {
    using cxxomfort::traits::make_signed;
    using cxxomfort::traits::make_unsigned;
} }
#endif // bring missing make_signed, make_unsigned to tr1




//
// lvalue_reference traits mirrored in C++03 mode
//

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)
    #define CXXO_MIRROR_LVALUE_REFERENCE 1
................................................................................



/*
 * is_trivial, is_literal
 * 
 * */



#if (CXXOMFORT_CXX_STD>=1997 && CXXOMFORT_CXX_STD < 2011)

    // for is_trivial is_literal
    #if 0
    #elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
        #if (CXXOMFORT_CXX_STD < 2011)
        #define CXXO_enable_is_trivial 1
................................................................................
#undef CXXO_enable_is_trivial
#undef CXXO_enable_is_literal

}
#endif // c++11 mode or type_traits emulation


/*
 * remove_all_extents (C++11)
 * */
#if (CXXOMFORT_CXX_STD>=2011)
#else
namespace std {
	using cxxomfort::traits::remove_all_extents;
}
#endif

/*
 * make_void (c++17)
 */
#include "impl/17-void_t.hpp"


................................................................................
#include "impl/17-bool_constant.hpp"

/*
 * endian (c++20)
 */
#include "impl/20-endian.hpp"


/*
 * bounded/unbounded array
 * */
#if (CXXOMFORT_CXX_STD>=2020)
#else
namespace std {
	using cxxomfort::traits::is_bounded_array;
	using cxxomfort::traits::is_unbounded_array;
}
#endif


//
// is_trivially_... missing in GCC 4.7 despite announcing C++11 mode
//

#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC , < 404) && CXXOMFORT_CXX_EMULATION==2011)
namespace std {
................................................................................

    > {
    };
} // namespace
#endif
















#else // CXX_STD < 1997

	#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
		#include <cxxomfort/config/ow/type_traits>
	#endif

	#include <cxxomfort/impl/07-type_traits.hpp>
	
namespace std {
	using namespace cxxomfort::traits;
}


#endif // CXX_STD >= 1997
................................................................................
 * * @e is_nothrow_ family of traits.
 * * @ref @c is_trivial , @ref @c is_literal_type (C++11).
 * * @c is_null_pointer (C++14) - identifies @c std::nullptr_t .
 * * @c void_t , @c make_void - generic, type-absorbing @c void transformations (C++17).
 * * @ref @c cxxomfort::cxxostd::bool_constant "std::bool_constant"  (C++17).
 * * @c @ref remove_cvref (C++20).
 * 
 * Non-backport interfaces (<tt>cxxomfort::fix</tt>):
 * 
 * * <tt>to_integral()</tt> for <tt>integral_constant</tt>.
 * * <tt>to_bool()</tt> for <tt>false_type</tt>, <tt>true_type</tt>.
 * * @link cxxomfort::fix::common_type @c common_type @endlink - 
 * implements "variadic" @c common_type in MSVC 2010, MSVC 2012 where it has issues, or refers to @c std::common_type otherwise.
 * 
 * @attention General notes:
 * 
 * * A number of traits depend on <b>compiler intrinsics</b>. 
 * If they are not available, the library does not compile correctly.
 * * In compilers without at least @c \_\_typeof__ support, 
 * @c common_type may not resolve correctly.
 * * In older compilers 
 * @c underlying_type may not resolve correctly.
 * 
 * 
 * See also @link cxxo-sup-type_traits Supplemental type_traits @endlink for other 
 * traits and transformations available in cxxomfort.
 * 
 * General notes:
 * 
 * 
 */

Changes to cxxomfort/cxxomfort/typeindex.hpp.

64
65
66
67
68
69
70
71




72
73
74
75
76
77
78
79
80
81
82
83
CXXO_STDTR1_CLOSE()
#endif // no_std_using

#endif

/**
 * @page std0typeindex <typeindex>
 * @brief Backports related to <typeindex>




 * 
 * Interfaces defined in this section:
 * 
 * * @c std::type_index - Hashable form of @c type_info (see @c @ref cxxomfort::cxxostd::typeindex "typeindex" ).
 * 
 * 
 * @section also See Also
 * 
 * * @see @cppref{header/typeindex} 
 * 
 */








|
>
>
>
>



|


|





64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
CXXO_STDTR1_CLOSE()
#endif // no_std_using

#endif

/**
 * @page std0typeindex <typeindex>
 * @brief Backports related to Standard header <tt><typeindex></tt> 
 * 
 * From C++11 onwards, <tt><typeindex></tt> provides an utility that 
 * allows using <tt>type_info</tt> information in a way that is indexable 
 * as criteria for eg.: a <tt>std::map</tt>.
 * 
 * Interfaces defined in this section:
 * 
 * * @c std::type_index - Hashable form of @c <tt>std::type_info</tt> (see @c @ref cxxomfort::cxxostd::typeindex "typeindex" ).
 * 
 * 
 * @subsection also See Also
 * 
 * * @see @cppref{header/typeindex} 
 * 
 */

Changes to cxxomfort/cxxomfort/util/meta.hpp.

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

template <typename... Bools>
struct meta_and; // make compiler happy

// at least 2 arguments
template <typename B0, typename... Bools>
struct meta_and<B0,Bools...>
: traits::integral_constant<
bool, (B0::value and meta_and<Bools...>::value)
> {};

template <typename B0>
struct meta_and<B0> : traits::integral_constant<bool, B0::value> {};

template <typename... Bools>
struct meta_or; // make compiler happy

// at least 2 arguments
template <typename B0, typename... Bools>
struct meta_or<B0,Bools...>
: traits::integral_constant<
bool, (B0::value or meta_and<Bools...>::value)
> {};

#else
// non-variadic up to 10 args, non-recursive

/*







|




|







|







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

template <typename... Bools>
struct meta_and; // make compiler happy

// at least 2 arguments
template <typename B0, typename... Bools>
struct meta_and<B0,Bools...>
: std::integral_constant<
bool, (B0::value and meta_and<Bools...>::value)
> {};

template <typename B0>
struct meta_and<B0> : std::integral_constant<bool, B0::value> {};

template <typename... Bools>
struct meta_or; // make compiler happy

// at least 2 arguments
template <typename B0, typename... Bools>
struct meta_or<B0,Bools...>
: std::integral_constant<
bool, (B0::value or meta_and<Bools...>::value)
> {};

#else
// non-variadic up to 10 args, non-recursive

/*

Changes to cxxomfort/cxxomfort/util/traits_tn.hpp.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define CXXOMFORT_UTIL_TRAITS_TN_HPP

#if (defined(CXXOMFORT_NOTICES) && CXXOMFORT_NOTICES>2)
    #pragma message CXXO_NOTICE("")
#endif

#include <type_traits>
#include "../util/type_traits.hpp"
//
// Triviality traits from C++11
//

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_CXX_EMULATION < 2011)
        #define CXXO_enable_is_trivially







|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define CXXOMFORT_UTIL_TRAITS_TN_HPP

#if (defined(CXXOMFORT_NOTICES) && CXXOMFORT_NOTICES>2)
    #pragma message CXXO_NOTICE("")
#endif

#include <type_traits>
#include "../impl/07-type_traits.hpp"
//
// Triviality traits from C++11
//

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_CXX_EMULATION < 2011)
        #define CXXO_enable_is_trivially

Deleted cxxomfort/cxxomfort/util/type_traits.hpp.

1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#ifndef CXXOMFORT_UTIL_TYPETRAITS_HPP
#define CXXOMFORT_UTIL_TYPETRAITS_HPP
/**
 * @brief Implements some of the type_traits additions in C++03 for internal use.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * This file implements some of the <type_traits> to remove dependencies
 * when using this library.
 *
 * Interfaces defined in this file
 * follow the proposal in n1424:
 * 
 * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1424.htm
 * 
 *
 * integral_constant, true_type, false_type,
 * is_void, is_integral, is_floating_point
 * is_array
 * is_pointer, is_reference
 * is_member_object_pointer, is_member_function_pointer
 * is_enum, is_union, is_class
 * is_function
 * 
 * is_arithmetic
 * is_fundamental
 * is_object
 * is_scalar
 * is_compound
 * is_member_pointer
 * 
 * is_const, is_volatile
 * is_pod
 * is_empty, is_polymorphic, is_abstract
 * is_signed, is_unsigned
 * 
 * 
 * add_const, remove_const, add_volatile, remove_volatile, add_cv, remove_cv,
 * add_pointer, remove_pointer, add_reference, remove_reference,
 * rank, extent, 
 * make_signed, make_unsigned
 * is_empty
 *
 * The following traits are handled via compiler intrinsics:
 * is_class, is_enum, is_pod, is_union, is_empty
 * (they are needed for stuff like scoped enum emulation and move emulation)
 *
 */

#include "../config.hpp"
#include "../base/nullptr.hpp"
//#include <cstddef>
//#include "meta.hpp"

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_OW)
	#include <cxxomfort/config/ow/type_traits>
#endif

namespace cxxomfort {
namespace traits {

namespace helper {

    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; };

} // helper

// this macro sets up a cv-specialization as true for the given type
#define TR1LITE_DEF_SPECIALIZE_TRUE(name,arg) template <> struct name < arg > : true_type {};
#define TR1LITE_DEF_SPECIALIZE_CV_TRUE(name,arg) \
template <> struct name < arg > : true_type {}; \
template <> struct name < arg const > : true_type {}; \
template <> struct name < arg volatile > : true_type {}; \
template <> struct name < arg const volatile > : true_type {}; \




/**
 * integral_constant
 */
template <typename Integral, Integral I> struct integral_constant {
    typedef Integral value_type;
    typedef integral_constant<Integral,I> type;
    static const Integral value= I;
    CXXO_CONSTEXPR operator value_type () const { return value; }
    CXXO_CONSTEXPR value_type operator() () const { return value; } // from C++14
};

template <bool B>
struct bool_constant 
: public integral_constant<bool, B> {};

//! true_type
struct false_type : integral_constant<bool,false> {};
//! false_type
struct true_type : integral_constant<bool,true> {};

//
// remove_cv
//
template <typename T> struct remove_cv {
    typedef T type;
};

template <typename T> struct remove_cv<T const> { typedef T type; };
template <typename T> struct remove_cv<T volatile> { typedef T type; };
template <typename T> struct remove_cv<T const volatile> { typedef T type; };

//
// is_void
//
template <typename T> struct is_void : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_void,void);

//
// is_null_pointer (c++14)
//
template <typename T> struct is_null_pointer : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_null_pointer,std::nullptr_t);


//
// is_integral
//
template <typename T> struct is_integral : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,unsigned int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,short int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,unsigned short int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,long int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,unsigned long int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,bool);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,char);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,wchar_t);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,unsigned char);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,signed char);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,long long int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_integral,unsigned long long int);

//
// is_floating_point
//
template <typename T> struct is_floating_point : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_floating_point,float);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_floating_point,double);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_floating_point,long double);


//
// is_same
//
template <typename TA, typename TB> struct is_same : false_type {};
template <typename T> struct is_same<T,T> : true_type {};



//! remove_const
template <typename T> struct remove_const {
    typedef T type;
};
template <typename T> struct remove_const<T const> {
    typedef T type;
};

//! remove_volatile
template <typename T> struct remove_volatile {
    typedef T type;
};
template <typename T> struct remove_volatile<T volatile> {
    typedef T type;
};


//
// is_const
//
template <typename T> struct is_const
: false_type {};
template <typename T> struct is_const<T const>
: true_type {};

//
// is_volatile
//
template <typename T> struct is_volatile
: false_type {};
template <typename T> struct is_volatile<T volatile>
: true_type {};

//
// add_const
//
template <typename T> struct add_const {
    typedef T const type;
};
template <typename T> struct add_const<T const> {
    typedef T const type;
};

//
// add_volatile
//
template <typename T> struct add_volatile {
    typedef T volatile type;
};
template <typename T> struct add_volatile<T volatile> {
    typedef T volatile type;
};

//
// add_cv
//
template <typename T> struct add_cv {
    typedef typename add_volatile< typename add_const<T>::type >::type type;
};


//
// is_array
//
template <typename T> struct is_array : false_type {};
template <typename T, size_t N> struct is_array <T[N]> : true_type {};
template <typename T, size_t N> struct is_array <T const [N]> : true_type {};
template <typename T, size_t N> struct is_array <T volatile [N]> : true_type {};
template <typename T, size_t N> struct is_array <T const volatile [N]> : true_type {};

//
// is_reference
//
template <typename T> struct is_reference : false_type {};
template <typename T> struct is_reference<T&> : true_type {};

// is_lvalue_reference
template <typename T> struct is_lvalue_reference : false_type {};
template <typename T> struct is_lvalue_reference<T&> : true_type {};

//
// is_pointer
//
template <typename T> struct is_pointer : false_type {};
template <typename T> struct is_pointer<T*> : true_type {};

//
// is_signed
//
template <typename T> struct is_signed : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_signed,signed short);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_signed,signed int);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_signed,signed long);
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_signed,signed long long);

//
// is_unsigned
//
template <typename T> struct is_unsigned : false_type {};
TR1LITE_DEF_SPECIALIZE_TRUE(is_unsigned,unsigned short);
TR1LITE_DEF_SPECIALIZE_TRUE(is_unsigned,unsigned int);
TR1LITE_DEF_SPECIALIZE_TRUE(is_unsigned,unsigned long);
TR1LITE_DEF_SPECIALIZE_TRUE(is_unsigned,unsigned long long);

//
// is_arithmetic
//
template <typename T> struct is_arithmetic
: integral_constant<bool, is_integral<T>::value || is_floating_point<T>::value >
{};

//
// is_fundamental
//
template <typename T> struct is_fundamental
: integral_constant<bool,
    is_arithmetic<T>::value || is_void<T>::value || is_null_pointer<T>::value
>
{};

//
// is_compound -- any type that is not fundamental
//
template <typename T> struct is_compound
: integral_constant<bool, !is_fundamental<T>::value> {};



//
// is_member_pointer and associates
//
template <typename T> struct is_member_object_pointer : false_type {};

template <typename T, typename Class>
struct is_member_object_pointer<T Class::*>
: true_type {};


// disable unneeded "no arguments to macro" warnings in MSVC
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable:4003 )
#endif

namespace detail_mfp {
// this gets a little wieldly, we handle up to 5 arguments (A0 to A4)

    template <typename T> struct helper : false_type {};

    #define _ty(A) typename A

    // no arguments
    #define HELPER_SPEC(cv)                                 \
    template <typename R, typename Class>  struct helper<R(Class::*)() cv> : true_type {};
    //template <typename R, typename Class>  struct helper<R(Class::*)() cv &> : true_type {}
    HELPER_SPEC();HELPER_SPEC(const);HELPER_SPEC(volatile);HELPER_SPEC(const volatile);
    #undef HELPER_SPEC

    // 1 argument
    #define HELPER_SPEC(cv)                                 \
    template <typename R, typename Class, _ty(A1)>  struct helper<R(Class::*)(A1) cv> : true_type {};
    //template <typename R, typename Class, _ty(A1)>  struct helper<R(Class::*)(A1) cv &> : true_type {}
    HELPER_SPEC();HELPER_SPEC(const);HELPER_SPEC(volatile);HELPER_SPEC(const volatile);
    #undef HELPER_SPEC

    // 2 arguments
    #define HELPER_SPEC(cv)                                 \
    template <typename R, typename Class, _ty(A1), _ty(A2)> struct helper<R(Class::*)(A1,A2) cv> : true_type {}
    HELPER_SPEC(); HELPER_SPEC(const); HELPER_SPEC(volatile); HELPER_SPEC(const volatile);
    #undef HELPER_SPEC

    // 3 arguments
    #define HELPER_SPEC(cv)                                 \
    template <typename R, typename Class, _ty(A1), _ty(A2), _ty(A3)> struct helper<R (Class::*)(A1,A2,A3) cv> : true_type {};
    HELPER_SPEC(); HELPER_SPEC(const); HELPER_SPEC(volatile); HELPER_SPEC(const volatile);
    #undef HELPER_SPEC

    // 4 arguments
    #define HELPER_SPEC(cv)                                 \
    template <typename R, typename Class, _ty(A1), _ty(A2), _ty(A3), _ty(A4)> struct helper<R (Class::*)(A1,A2,A3,A4) cv> : true_type {};
    HELPER_SPEC(); HELPER_SPEC(const); HELPER_SPEC(volatile); HELPER_SPEC(const volatile);
    #undef HELPER_SPEC

    template <typename R, typename Class, _ty(A1), _ty(A2), _ty(A3), _ty(A4), _ty(A5)>
    struct helper<R (Class::*)(A1,A2,A3,A4,A5)> : true_type {};

    template <typename R, typename Class, _ty(A1), _ty(A2), _ty(A3), _ty(A4), _ty(A5)>
    struct helper<R (Class::*)(A1,A2,A3,A4,A5,...)> : true_type {};

    #undef _ty

} // member function pointer helper

#ifdef _MSC_VER
#pragma warning( pop ) // MSVC "no arguments to macro" warning
#endif

// is_member_function_pointer
template <typename T> struct is_member_function_pointer
: detail_mfp::helper <
    typename remove_cv<T>::type
> {};

namespace detail_mfp {
    template< class T >
    struct is_member_pointer_helper         : false_type {};
    template< class T, class U >
    struct is_member_pointer_helper<T U::*> : true_type {};
} // detail_mfp::

template< class T >
struct is_member_pointer :
detail_mfp::is_member_pointer_helper<typename remove_cv<T>::type> {};


#undef TR1LITE_DEF_SPECIALIZE_TRUE

//
// is_function
//

template <typename T> struct is_function : false_type {};
// we handle up to 5 arguments (1 to 5) then ellipsis
template <typename R> struct is_function <R()>
: true_type {};
template <typename R, typename T1>  struct is_function<R(T1)>
: true_type {};
template <typename R, typename T1, typename T2> struct is_function<R(T1,T2)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3> struct is_function<R(T1,T2,T3)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4> struct is_function<R(T1,T2,T3,T4)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5> struct is_function<R(T1,T2,T3,T4,T5)>
: true_type {};
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5> struct is_function<R(T1,T2,T3,T4,T5,...)>
: true_type {};


//
// rank = number of dimensions
//
template <typename T> struct rank : integral_constant< size_t, 0> {};
template <typename T> struct rank<T[]> : integral_constant< size_t, rank<T>::value + 1> {};
template <typename T, size_t N> struct rank<T[N]> : integral_constant< size_t, rank<T>::value + 1> {};

//
// extent = size of topmost dimension
//
template<typename T, unsigned N=0> struct extent 
: integral_constant<size_t, 0> {};
template<typename T>                    struct extent<T[],0> 
: integral_constant<size_t, 0> {};
template<typename T, unsigned N>        struct extent<T[],N> 
: integral_constant<size_t, extent<T,N-1>::value> {};
template<typename T, size_t N>          struct extent<T[N],0> 
: integral_constant<size_t, N> {};
template<typename T, size_t I, unsigned N> struct extent<T[I],N> 
: integral_constant<size_t, extent<T,N-1>::value> {};

//
// remove extent
//
template <typename T>
struct remove_extent { typedef T type; };

template <typename T>
struct remove_extent<T[]> { typedef T type; };

template <typename T, std::size_t N>
struct remove_extent<T[N]> { typedef T type;};

//
// remove_reference
//
template <typename T> struct remove_reference {
    typedef T type;
};
template <typename T> struct remove_reference<T&> {
    typedef T type;
};


//
// add_reference
template <typename T> struct add_reference {
    // careful with T == cv-qualified void
    typedef typename helper::conditional< 
        is_reference< T >::value, T, T&
    >::type type;
};
template <> struct add_reference<void> {
    typedef void type;
};
template <> struct add_reference<void const> {
    typedef void const type;
};
template <> struct add_reference<void volatile> {
    typedef void volatile type;
};
template <> struct add_reference<void const volatile> {
    typedef void const volatile type;
};



// add_pointer
template <typename T> struct add_pointer {
    typedef T* type;
};

// remove_pointer
template <typename T> struct remove_pointer {
    typedef T type;
};
template <typename T> struct remove_pointer<T*> {
    typedef T type;
};

//
// make_signed, make_unsigned
//

namespace detail {
template <typename T> struct make_signed_impl { typedef T type; };

template <typename T> struct make_unsigned_impl { typedef T type; };

#define SIGNED_HELPER(T1,S1) \
template<> struct make_signed_impl<T1> { typedef S1 type; }; \
template<> struct make_signed_impl<T1 const> { typedef S1 const type; }; \
template<> struct make_signed_impl<T1 volatile> { typedef S1 volatile type; }; \
template<> struct make_signed_impl<T1 const volatile> { typedef S1 const volatile type; }; \

#define UNSIGNED_HELPER(T1,U1) template<> struct make_unsigned_impl<T1> { typedef U1 type; }
SIGNED_HELPER(signed char,signed char);
SIGNED_HELPER(unsigned char,signed char);
SIGNED_HELPER(char,signed char);

UNSIGNED_HELPER(signed char,unsigned char);
UNSIGNED_HELPER(unsigned char,unsigned char);
UNSIGNED_HELPER(char,unsigned char);

SIGNED_HELPER(signed short,signed short);
SIGNED_HELPER(unsigned short,signed short);
UNSIGNED_HELPER(signed short,unsigned short);
UNSIGNED_HELPER(unsigned short,unsigned short);

SIGNED_HELPER(signed long,signed long);
SIGNED_HELPER(unsigned long,signed long);
UNSIGNED_HELPER(signed long,unsigned long);
UNSIGNED_HELPER(unsigned long,unsigned long);

SIGNED_HELPER(signed int,signed int);
SIGNED_HELPER(unsigned int,signed int);
UNSIGNED_HELPER(signed int,unsigned int);
UNSIGNED_HELPER(unsigned int,unsigned int);

#undef SIGNED_HELPER
#undef UNSIGNED_HELPER
}

template <typename T> struct make_unsigned 
: detail::make_unsigned_impl<T> {
};

template <typename T> struct make_signed 
: detail::make_signed_impl<T> {
};


/*
 * The traits starting at this point are intended 
 * to require compiler support, so we rely on intrinsics
 */

// for the following compilers, we just return false unless otherwise specified

#if (CXXOMFORT_CXX_STD >= 1997)

// is_class
template <typename T> struct is_class
: helper::conditional< __is_class(T), true_type, false_type>::type {};

// is_empty
template <typename T> struct is_empty 
: helper::conditional< __is_empty(T), true_type, false_type>::type {};

// is_enum
template <typename T> struct is_enum
: helper::conditional< __is_enum(T), true_type, false_type>::type {};

// is_union
template <typename T> struct is_union
: helper::conditional< __is_union(T), true_type, false_type>::type {};


// is_abstract
template <typename T> struct is_abstract
: helper::conditional< __is_abstract(T), true_type, false_type>::type {};

// is_base_of
template <typename B, typename D> struct is_base_of
: helper::conditional< __is_base_of(B,D), true_type, false_type>::type {};

// is_polymorphic
template <typename T> struct is_polymorphic
: helper::conditional< __is_polymorphic(T), true_type, false_type>::type {};

// is_pod
template <typename T> struct is_pod
: helper::conditional< __is_pod(T), true_type, false_type>::type {};


#else

template <typename T>
struct is_enum { enum { value = __is_enum(T) }; };

template <typename T>
struct is_union { enum { value = __is_union(T) }; };

template <typename T>
struct is_class { enum { value = __is_class(T) }; };

template <typename T>
struct is_pod { enum { value = is_arithmetic<T>::value  }; };

#endif


/*
 * Advanced type properties
 */

// given the above, it should be possible to 
// implement is_scalar.
template<class T>
struct is_scalar 
: integral_constant < bool,
    is_arithmetic<T>::value || is_pointer<T>::value ||
    is_member_pointer<T>::value || is_enum<T>::value ||
    is_null_pointer<T>::value
> {};

// as well as is_object
template <class T> 
struct is_object 
: helper::conditional< 
    !(is_function<T>::value 
     || is_reference<T>::value 
     || is_void<T>::value)
, true_type, false_type>::type     {};

} // traits::
} // cxxomfort::


#endif // type traits
// see http://stackoverflow.com/questions/9343329/how-to-know-underlying-type-of-class-enum/10956467#10956467
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Changes to cxxomfort/cxxomfort/utility.hpp.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "config.hpp"
#include "base.hpp"   // move, forward
#include CXXO_INCLUDE_SYS(utility)

#if (CXXOMFORT_CXX_STD >= 1997)

#include "util/meta.hpp"
#include "util/type_traits.hpp"

//#include "type_traits.hpp"
//USING

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







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "config.hpp"
#include "base.hpp"   // move, forward
#include CXXO_INCLUDE_SYS(utility)

#if (CXXOMFORT_CXX_STD >= 1997)

#include "util/meta.hpp"
#include "impl/07-type_traits.hpp"

//#include "type_traits.hpp"
//USING

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

Changes to cxxomfort/cxxomfort/various.hpp.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
...
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
/*
 * integral_of_size
 * 
 * @brief Query if an integral with the given size exists
 * 
 */

#include "util/type_traits.hpp"
#include "util/meta.hpp"      // enable_if, etc...
#include "utility.hpp"
//#include "using.hpp"


/*
 * is_any_of
................................................................................
: std::integral_constant<bool, (Tr1::value or Tr2::value or Tr3::value or Tr4::value or Tr5::value)> {
};

#endif

} // cxxomfort::


namespace cxxomfort {

#if (CXXOMFORT_CXX_STD >= 2011)
/*
 * compose <int&, add_const, remove_reference>
 * would evaluate to:
 * add_const<int&>::type --> T1
 * then remove_reference<T1>::type --> type
 */
template <typename T, template <typename> class Conv1, template <typename> class... Conversions>
struct static_compose {
    private:
    typedef typename Conv1<T>::type T1;
    public:
    typedef typename static_compose<T1,Conversions...>::type type;
};

template <typename T, template <typename> class Conv1>
struct static_compose<T,Conv1> {
    typedef typename Conv1<T>::type type;
};

#endif

}



#if 0
//
// piecewise tuple constructor for cxxomfort pair
//
#include "utility.hpp"
#include <tuple>
................................................................................


} //cxxomfort::

#endif



//
// function_return_type
// (because result_of does not take plain function types)
//

namespace cxxomfort {
template <typename Sig> struct result_of_function ;

template <typename R> struct result_of_function<R()> {
    typedef R type;
};

template <typename R, typename A1> struct result_of_function<R(A1)>
: result_of_function<R()> {};
template <typename R, typename A1, typename A2> struct result_of_function<R(A1,A2)>
: result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3> 
struct result_of_function<R(A1,A2,A3)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4> 
struct result_of_function<R(A1,A2,A3,A4)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4, typename A5> 
struct result_of_function<R(A1,A2,A3,A4,A5)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6> 
struct result_of_function<R(A1,A2,A3,A4,A5,A6)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7> 
struct result_of_function<R(A1,A2,A3,A4,A5,A6,A7)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8> 
struct result_of_function<R(A1,A2,A3,A4,A5,A6,A7,A8)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9> 
struct result_of_function<R(A1,A2,A3,A4,A5,A6,A7,A8,A9)> : result_of_function<R()> {};
template <typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename B0> 
struct result_of_function<R(A1,A2,A3,A4,A5,A6,A7,A8,A9,B0)> : result_of_function<R()> {};

}


/*
//
// Given a STL iterator, obtain where possible the type of the container
//

template <typename Iterator>







|







 







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







 







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







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
149
150
151
152
153
154
155




























156
157
158
159
160
161
162
...
243
244
245
246
247
248
249




































250
251
252
253
254
255
256
/*
 * integral_of_size
 * 
 * @brief Query if an integral with the given size exists
 * 
 */

#include "impl/07-type_traits.hpp"
#include "util/meta.hpp"      // enable_if, etc...
#include "utility.hpp"
//#include "using.hpp"


/*
 * is_any_of
................................................................................
: std::integral_constant<bool, (Tr1::value or Tr2::value or Tr3::value or Tr4::value or Tr5::value)> {
};

#endif

} // cxxomfort::






























#if 0
//
// piecewise tuple constructor for cxxomfort pair
//
#include "utility.hpp"
#include <tuple>
................................................................................


} //cxxomfort::

#endif







































/*
//
// Given a STL iterator, obtain where possible the type of the container
//

template <typename Iterator>

Added cxxomfort/cxxomfort/vendor/pstdint.h.

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
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
57
58
59
60
61
62
63
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
/*  A portable stdint.h
 ****************************************************************************
 *  BSD License:
 ****************************************************************************
 *
 *  Copyright (c) 2005-2016 Paul Hsieh
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. The name of the author may not be used to endorse or promote products
 *     derived from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************
 *
 *  Version 0.1.15.4
 *
 *  The ANSI C standard committee, for the C99 standard, specified the
 *  inclusion of a new standard include file called stdint.h.  This is
 *  a very useful and long desired include file which contains several
 *  very precise definitions for integer scalar types that is
 *  critically important for making portable several classes of
 *  applications including cryptography, hashing, variable length
 *  integer libraries and so on.  But for most developers its likely
 *  useful just for programming sanity.
 *
 *  The problem is that some compiler vendors chose to ignore the C99
 *  standard and some older compilers have no opportunity to be updated.
 *  Because of this situation, simply including stdint.h in your code
 *  makes it unportable.
 *
 *  So that's what this file is all about.  Its an attempt to build a
 *  single universal include file that works on as many platforms as
 *  possible to deliver what stdint.h is supposed to.  Even compilers
 *  that already come with stdint.h can use this file instead without
 *  any loss of functionality.  A few things that should be noted about
 *  this file:
 *
 *    1) It is not guaranteed to be portable and/or present an identical
 *       interface on all platforms.  The extreme variability of the
 *       ANSI C standard makes this an impossibility right from the
 *       very get go. Its really only meant to be useful for the vast
 *       majority of platforms that possess the capability of
 *       implementing usefully and precisely defined, standard sized
 *       integer scalars.  Systems which are not intrinsically 2s
 *       complement may produce invalid constants.
 *
 *    2) There is an unavoidable use of non-reserved symbols.
 *
 *    3) Other standard include files are invoked.
 *
 *    4) This file may come in conflict with future platforms that do
 *       include stdint.h.  The hope is that one or the other can be
 *       used with no real difference.
 *
 *    5) In the current version, if your platform can't represent
 *       int32_t, int16_t and int8_t, it just dumps out with a compiler
 *       error.
 *
 *    6) 64 bit integers may or may not be defined.  Test for their
 *       presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
 *       Note that this is different from the C99 specification which
 *       requires the existence of 64 bit support in the compiler.  If
 *       this is not defined for your platform, yet it is capable of
 *       dealing with 64 bits then it is because this file has not yet
 *       been extended to cover all of your system's capabilities.
 *
 *    7) (u)intptr_t may or may not be defined.  Test for its presence
 *       with the test: #ifdef PTRDIFF_MAX.  If this is not defined
 *       for your platform, then it is because this file has not yet
 *       been extended to cover all of your system's capabilities, not
 *       because its optional.
 *
 *    8) The following might not been defined even if your platform is
 *       capable of defining it:
 *
 *       WCHAR_MIN
 *       WCHAR_MAX
 *       (u)int64_t
 *       PTRDIFF_MIN
 *       PTRDIFF_MAX
 *       (u)intptr_t
 *
 *    9) The following have not been defined:
 *
 *       WINT_MIN
 *       WINT_MAX
 *
 *   10) The criteria for defining (u)int_least(*)_t isn't clear,
 *       except for systems which don't have a type that precisely
 *       defined 8, 16, or 32 bit types (which this include file does
 *       not support anyways). Default definitions have been given.
 *
 *   11) The criteria for defining (u)int_fast(*)_t isn't something I
 *       would trust to any particular compiler vendor or the ANSI C
 *       committee.  It is well known that "compatible systems" are
 *       commonly created that have very different performance
 *       characteristics from the systems they are compatible with,
 *       especially those whose vendors make both the compiler and the
 *       system.  Default definitions have been given, but its strongly
 *       recommended that users never use these definitions for any
 *       reason (they do *NOT* deliver any serious guarantee of
 *       improved performance -- not in this file, nor any vendor's
 *       stdint.h).
 *
 *   12) The following macros:
 *
 *       PRINTF_INTMAX_MODIFIER
 *       PRINTF_INT64_MODIFIER
 *       PRINTF_INT32_MODIFIER
 *       PRINTF_INT16_MODIFIER
 *       PRINTF_LEAST64_MODIFIER
 *       PRINTF_LEAST32_MODIFIER
 *       PRINTF_LEAST16_MODIFIER
 *       PRINTF_INTPTR_MODIFIER
 *
 *       are strings which have been defined as the modifiers required
 *       for the "d", "u" and "x" printf formats to correctly output
 *       (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
 *       (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
 *       PRINTF_INTPTR_MODIFIER is not defined for some systems which
 *       provide their own stdint.h.  PRINTF_INT64_MODIFIER is not
 *       defined if INT64_MAX is not defined.  These are an extension
 *       beyond what C99 specifies must be in stdint.h.
 *
 *       In addition, the following macros are defined:
 *
 *       PRINTF_INTMAX_HEX_WIDTH
 *       PRINTF_INT64_HEX_WIDTH
 *       PRINTF_INT32_HEX_WIDTH
 *       PRINTF_INT16_HEX_WIDTH
 *       PRINTF_INT8_HEX_WIDTH
 *       PRINTF_INTMAX_DEC_WIDTH
 *       PRINTF_INT64_DEC_WIDTH
 *       PRINTF_INT32_DEC_WIDTH
 *       PRINTF_INT16_DEC_WIDTH
 *       PRINTF_UINT8_DEC_WIDTH
 *       PRINTF_UINTMAX_DEC_WIDTH
 *       PRINTF_UINT64_DEC_WIDTH
 *       PRINTF_UINT32_DEC_WIDTH
 *       PRINTF_UINT16_DEC_WIDTH
 *       PRINTF_UINT8_DEC_WIDTH
 *
 *       Which specifies the maximum number of characters required to
 *       print the number of that type in either hexadecimal or decimal.
 *       These are an extension beyond what C99 specifies must be in
 *       stdint.h.
 *
 *  Compilers tested (all with 0 warnings at their highest respective
 *  settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
 *  bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
 *  .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
 *
 *  This file should be considered a work in progress.  Suggestions for
 *  improvements, especially those which increase coverage are strongly
 *  encouraged.
 *
 *  Acknowledgements
 *
 *  The following people have made significant contributions to the
 *  development and testing of this file:
 *
 *  Chris Howie
 *  John Steele Scott
 *  Dave Thorup
 *  John Dill
 *  Florian Wobbe
 *  Christopher Sean Morrison
 *  Mikkel Fahnoe Jorgensen
 *
 */

#include <stddef.h>
#include <limits.h>
#include <signal.h>

/*
 *  For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
 *  do nothing else.  On the Mac OS X version of gcc this is _STDINT_H_.
 */

#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
#include <stdint.h>
#define _PSTDINT_H_INCLUDED
# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "l"
#  endif
#  ifndef PRINTF_INT32_MODIFIER
#   define PRINTF_INT32_MODIFIER ""
#  endif
# else
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
#  ifndef PRINTF_INT32_MODIFIER
#   if (UINT_MAX == UINT32_MAX)
#    define PRINTF_INT32_MODIFIER ""
#   else
#    define PRINTF_INT32_MODIFIER "l"
#   endif
#  endif
# endif
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER "h"
# endif
# ifndef PRINTF_INTMAX_MODIFIER
#  define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INT64_HEX_WIDTH
#  define PRINTF_INT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_UINT64_HEX_WIDTH
#  define PRINTF_UINT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_INT32_HEX_WIDTH
#  define PRINTF_INT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_UINT32_HEX_WIDTH
#  define PRINTF_UINT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_INT16_HEX_WIDTH
#  define PRINTF_INT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_UINT16_HEX_WIDTH
#  define PRINTF_UINT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_INT8_HEX_WIDTH
#  define PRINTF_INT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_UINT8_HEX_WIDTH
#  define PRINTF_UINT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_INT64_DEC_WIDTH
#  define PRINTF_INT64_DEC_WIDTH "19"
# endif
# ifndef PRINTF_UINT64_DEC_WIDTH
#  define PRINTF_UINT64_DEC_WIDTH "20"
# endif
# ifndef PRINTF_INT32_DEC_WIDTH
#  define PRINTF_INT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_UINT32_DEC_WIDTH
#  define PRINTF_UINT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_INT16_DEC_WIDTH
#  define PRINTF_INT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_UINT16_DEC_WIDTH
#  define PRINTF_UINT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_INT8_DEC_WIDTH
#  define PRINTF_INT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_UINT8_DEC_WIDTH
#  define PRINTF_UINT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_UINTMAX_HEX_WIDTH
#  define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif
# ifndef PRINTF_UINTMAX_DEC_WIDTH
#  define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif

/*
 *  Something really weird is going on with Open Watcom.  Just pull some of
 *  these duplicated definitions from Open Watcom's stdint.h file for now.
 */

# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
#  if !defined (INT64_C)
#   define INT64_C(x)   (x + (INT64_MAX - INT64_MAX))
#  endif
#  if !defined (UINT64_C)
#   define UINT64_C(x)  (x + (UINT64_MAX - UINT64_MAX))
#  endif
#  if !defined (INT32_C)
#   define INT32_C(x)   (x + (INT32_MAX - INT32_MAX))
#  endif
#  if !defined (UINT32_C)
#   define UINT32_C(x)  (x + (UINT32_MAX - UINT32_MAX))
#  endif
#  if !defined (INT16_C)
#   define INT16_C(x)   (x)
#  endif
#  if !defined (UINT16_C)
#   define UINT16_C(x)  (x)
#  endif
#  if !defined (INT8_C)
#   define INT8_C(x)   (x)
#  endif
#  if !defined (UINT8_C)
#   define UINT8_C(x)  (x)
#  endif
#  if !defined (UINT64_MAX)
#   define UINT64_MAX  18446744073709551615ULL
#  endif
#  if !defined (INT64_MAX)
#   define INT64_MAX  9223372036854775807LL
#  endif
#  if !defined (UINT32_MAX)
#   define UINT32_MAX  4294967295UL
#  endif
#  if !defined (INT32_MAX)
#   define INT32_MAX  2147483647L
#  endif
#  if !defined (INTMAX_MAX)
#   define INTMAX_MAX INT64_MAX
#  endif
#  if !defined (INTMAX_MIN)
#   define INTMAX_MIN INT64_MIN
#  endif
# endif
#endif

/*
 *  I have no idea what is the truly correct thing to do on older Solaris.
 *  From some online discussions, this seems to be what is being
 *  recommended.  For people who actually are developing on older Solaris,
 *  what I would like to know is, does this define all of the relevant
 *  macros of a complete stdint.h?  Remember, in pstdint.h 64 bit is
 *  considered optional.
 */

#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
#include <sys/inttypes.h>
#define _PSTDINT_H_INCLUDED
#endif

#ifndef _PSTDINT_H_INCLUDED
#define _PSTDINT_H_INCLUDED

#ifndef SIZE_MAX
# define SIZE_MAX (~(size_t)0)
#endif

/*
 *  Deduce the type assignments from limits.h under the assumption that
 *  integer sizes in bits are powers of 2, and follow the ANSI
 *  definitions.
 */

#ifndef UINT8_MAX
# define UINT8_MAX 0xff
#endif
#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
    typedef unsigned char uint8_t;
#   define UINT8_C(v) ((uint8_t) v)
# else
#   error "Platform not supported"
# endif
#endif

#ifndef INT8_MAX
# define INT8_MAX 0x7f
#endif
#ifndef INT8_MIN
# define INT8_MIN INT8_C(0x80)
#endif
#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
    typedef signed char int8_t;
#   define INT8_C(v) ((int8_t) v)
# else
#   error "Platform not supported"
# endif
#endif

#ifndef UINT16_MAX
# define UINT16_MAX 0xffff
#endif
#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
  typedef unsigned int uint16_t;
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER ""
# endif
# define UINT16_C(v) ((uint16_t) (v))
#elif (USHRT_MAX == UINT16_MAX)
  typedef unsigned short uint16_t;
# define UINT16_C(v) ((uint16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif

#ifndef INT16_MAX
# define INT16_MAX 0x7fff
#endif
#ifndef INT16_MIN
# define INT16_MIN INT16_C(0x8000)
#endif
#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
  typedef signed int int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER ""
# endif
#elif (SHRT_MAX == INT16_MAX)
  typedef signed short int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
#  define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif

#ifndef UINT32_MAX
# define UINT32_MAX (0xffffffffUL)
#endif
#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
  typedef unsigned long uint32_t;
# define UINT32_C(v) v ## UL
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER "l"
# endif
#elif (UINT_MAX == UINT32_MAX)
  typedef unsigned int uint32_t;
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
# define UINT32_C(v) v ## U
#elif (USHRT_MAX == UINT32_MAX)
  typedef unsigned short uint32_t;
# define UINT32_C(v) ((unsigned short) (v))
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif

#ifndef INT32_MAX
# define INT32_MAX (0x7fffffffL)
#endif
#ifndef INT32_MIN
# define INT32_MIN INT32_C(0x80000000)
#endif
#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
  typedef signed long int32_t;
# define INT32_C(v) v ## L
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER "l"
# endif
#elif (INT_MAX == INT32_MAX)
  typedef signed int int32_t;
# define INT32_C(v) v
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
#elif (SHRT_MAX == INT32_MAX)
  typedef signed short int32_t;
# define INT32_C(v) ((short) (v))
# ifndef PRINTF_INT32_MODIFIER
#  define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif

/*
 *  The macro stdint_int64_defined is temporarily used to record
 *  whether or not 64 integer support is available.  It must be
 *  defined for any 64 integer extensions for new platforms that are
 *  added.
 */

#undef stdint_int64_defined
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
#  define stdint_int64_defined
   typedef long long int64_t;
   typedef unsigned long long uint64_t;
#  define UINT64_C(v) v ## ULL
#  define  INT64_C(v) v ## LL
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
# endif
#endif

#if !defined (stdint_int64_defined)
# if defined(__GNUC__) && !defined(vxWorks)
#  define stdint_int64_defined
   __extension__ typedef long long int64_t;
   __extension__ typedef unsigned long long uint64_t;
#  define UINT64_C(v) v ## ULL
#  define  INT64_C(v) v ## LL
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
#  define stdint_int64_defined
   typedef long long int64_t;
   typedef unsigned long long uint64_t;
#  define UINT64_C(v) v ## ULL
#  define  INT64_C(v) v ## LL
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "ll"
#  endif
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
#  define stdint_int64_defined
   typedef __int64 int64_t;
   typedef unsigned __int64 uint64_t;
#  define UINT64_C(v) v ## UI64
#  define  INT64_C(v) v ## I64
#  ifndef PRINTF_INT64_MODIFIER
#   define PRINTF_INT64_MODIFIER "I64"
#  endif
# endif
#endif

#if !defined (LONG_LONG_MAX) && defined (INT64_C)
# define LONG_LONG_MAX INT64_C (9223372036854775807)
#endif
#ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
#endif

#if !defined (INT64_MAX) && defined (INT64_C)
# define INT64_MAX INT64_C (9223372036854775807)
#endif
#if !defined (INT64_MIN) && defined (INT64_C)
# define INT64_MIN INT64_C (-9223372036854775808)
#endif
#if !defined (UINT64_MAX) && defined (INT64_C)
# define UINT64_MAX UINT64_C (18446744073709551615)
#endif

/*
 *  Width of hexadecimal for number field.
 */

#ifndef PRINTF_INT64_HEX_WIDTH
# define PRINTF_INT64_HEX_WIDTH "16"
#endif
#ifndef PRINTF_INT32_HEX_WIDTH
# define PRINTF_INT32_HEX_WIDTH "8"
#endif
#ifndef PRINTF_INT16_HEX_WIDTH
# define PRINTF_INT16_HEX_WIDTH "4"
#endif
#ifndef PRINTF_INT8_HEX_WIDTH
# define PRINTF_INT8_HEX_WIDTH "2"
#endif
#ifndef PRINTF_INT64_DEC_WIDTH
# define PRINTF_INT64_DEC_WIDTH "19"
#endif
#ifndef PRINTF_INT32_DEC_WIDTH
# define PRINTF_INT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_INT16_DEC_WIDTH
# define PRINTF_INT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_INT8_DEC_WIDTH
# define PRINTF_INT8_DEC_WIDTH "3"
#endif
#ifndef PRINTF_UINT64_DEC_WIDTH
# define PRINTF_UINT64_DEC_WIDTH "20"
#endif
#ifndef PRINTF_UINT32_DEC_WIDTH
# define PRINTF_UINT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_UINT16_DEC_WIDTH
# define PRINTF_UINT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_UINT8_DEC_WIDTH
# define PRINTF_UINT8_DEC_WIDTH "3"
#endif

/*
 *  Ok, lets not worry about 128 bit integers for now.  Moore's law says
 *  we don't need to worry about that until about 2040 at which point
 *  we'll have bigger things to worry about.
 */

#ifdef stdint_int64_defined
  typedef int64_t intmax_t;
  typedef uint64_t uintmax_t;
# define  INTMAX_MAX   INT64_MAX
# define  INTMAX_MIN   INT64_MIN
# define UINTMAX_MAX  UINT64_MAX
# define UINTMAX_C(v) UINT64_C(v)
# define  INTMAX_C(v)  INT64_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
#   define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
# endif
#else
  typedef int32_t intmax_t;
  typedef uint32_t uintmax_t;
# define  INTMAX_MAX   INT32_MAX
# define UINTMAX_MAX  UINT32_MAX
# define UINTMAX_C(v) UINT32_C(v)
# define  INTMAX_C(v)  INT32_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
#   define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
# endif
#endif

/*
 *  Because this file currently only supports platforms which have
 *  precise powers of 2 as bit sizes for the default integers, the
 *  least definitions are all trivial.  Its possible that a future
 *  version of this file could have different definitions.
 */

#ifndef stdint_least_defined
  typedef   int8_t   int_least8_t;
  typedef  uint8_t  uint_least8_t;
  typedef  int16_t  int_least16_t;
  typedef uint16_t uint_least16_t;
  typedef  int32_t  int_least32_t;
  typedef uint32_t uint_least32_t;
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
# define  UINT_LEAST8_MAX  UINT8_MAX
# define   INT_LEAST8_MAX   INT8_MAX
# define UINT_LEAST16_MAX UINT16_MAX
# define  INT_LEAST16_MAX  INT16_MAX
# define UINT_LEAST32_MAX UINT32_MAX
# define  INT_LEAST32_MAX  INT32_MAX
# define   INT_LEAST8_MIN   INT8_MIN
# define  INT_LEAST16_MIN  INT16_MIN
# define  INT_LEAST32_MIN  INT32_MIN
# ifdef stdint_int64_defined
    typedef  int64_t  int_least64_t;
    typedef uint64_t uint_least64_t;
#   define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
#   define UINT_LEAST64_MAX UINT64_MAX
#   define  INT_LEAST64_MAX  INT64_MAX
#   define  INT_LEAST64_MIN  INT64_MIN
# endif
#endif
#undef stdint_least_defined

/*
 *  The ANSI C committee pretending to know or specify anything about
 *  performance is the epitome of misguided arrogance.  The mandate of
 *  this file is to *ONLY* ever support that absolute minimum
 *  definition of the fast integer types, for compatibility purposes.
 *  No extensions, and no attempt to suggest what may or may not be a
 *  faster integer type will ever be made in this file.  Developers are
 *  warned to stay away from these types when using this or any other
 *  stdint.h.
 */

typedef   int_least8_t   int_fast8_t;
typedef  uint_least8_t  uint_fast8_t;
typedef  int_least16_t  int_fast16_t;
typedef uint_least16_t uint_fast16_t;
typedef  int_least32_t  int_fast32_t;
typedef uint_least32_t uint_fast32_t;
#define  UINT_FAST8_MAX  UINT_LEAST8_MAX
#define   INT_FAST8_MAX   INT_LEAST8_MAX
#define UINT_FAST16_MAX UINT_LEAST16_MAX
#define  INT_FAST16_MAX  INT_LEAST16_MAX
#define UINT_FAST32_MAX UINT_LEAST32_MAX
#define  INT_FAST32_MAX  INT_LEAST32_MAX
#define   INT_FAST8_MIN   INT_LEAST8_MIN
#define  INT_FAST16_MIN  INT_LEAST16_MIN
#define  INT_FAST32_MIN  INT_LEAST32_MIN
#ifdef stdint_int64_defined
  typedef  int_least64_t  int_fast64_t;
  typedef uint_least64_t uint_fast64_t;
# define UINT_FAST64_MAX UINT_LEAST64_MAX
# define  INT_FAST64_MAX  INT_LEAST64_MAX
# define  INT_FAST64_MIN  INT_LEAST64_MIN
#endif

#undef stdint_int64_defined

/*
 *  Whatever piecemeal, per compiler thing we can do about the wchar_t
 *  type limits.
 */

#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
# include <wchar.h>
# ifndef WCHAR_MIN
#  define WCHAR_MIN 0
# endif
# ifndef WCHAR_MAX
#  define WCHAR_MAX ((wchar_t)-1)
# endif
#endif

/*
 *  Whatever piecemeal, per compiler/platform thing we can do about the
 *  (u)intptr_t types and limits.
 */

#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
# define STDINT_H_UINTPTR_T_DEFINED
#endif

#ifndef STDINT_H_UINTPTR_T_DEFINED
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
#  define stdint_intptr_bits 64
# elif defined (__WATCOMC__) || defined (__TURBOC__)
#  if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
#    define stdint_intptr_bits 16
#  else
#    define stdint_intptr_bits 32
#  endif
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
#  define stdint_intptr_bits 32
# elif defined (__INTEL_COMPILER)
/* TODO -- what did Intel do about x86-64? */
# else
/* #error "This platform might not be supported yet" */
# endif

# ifdef stdint_intptr_bits
#  define stdint_intptr_glue3_i(a,b,c)  a##b##c
#  define stdint_intptr_glue3(a,b,c)    stdint_intptr_glue3_i(a,b,c)
#  ifndef PRINTF_INTPTR_MODIFIER
#    define PRINTF_INTPTR_MODIFIER      stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
#  endif
#  ifndef PTRDIFF_MAX
#    define PTRDIFF_MAX                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
#  endif
#  ifndef PTRDIFF_MIN
#    define PTRDIFF_MIN                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
#  endif
#  ifndef UINTPTR_MAX
#    define UINTPTR_MAX                 stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
#  endif
#  ifndef INTPTR_MAX
#    define INTPTR_MAX                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
#  endif
#  ifndef INTPTR_MIN
#    define INTPTR_MIN                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
#  endif
#  ifndef INTPTR_C
#    define INTPTR_C(x)                 stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
#  endif
#  ifndef UINTPTR_C
#    define UINTPTR_C(x)                stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
#  endif
  typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
  typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t)  intptr_t;
# else
/* TODO -- This following is likely wrong for some platforms, and does
   nothing for the definition of uintptr_t. */
  typedef ptrdiff_t intptr_t;
# endif
# define STDINT_H_UINTPTR_T_DEFINED
#endif

/*
 *  Assumes sig_atomic_t is signed and we have a 2s complement machine.
 */

#ifndef SIG_ATOMIC_MAX
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
#endif

#endif

#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)

/*
 *  Please compile with the maximum warning settings to make sure macros are
 *  not defined more than once.
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define glue3_aux(x,y,z) x ## y ## z
#define glue3(x,y,z) glue3_aux(x,y,z)

#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);

#define DECL(us,bits) glue3(DECL,us,) (bits)

#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)

#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }

int main () {
	int err_n = 0;
	int err_first = 0;
	DECL(I,8)
	DECL(U,8)
	DECL(I,16)
	DECL(U,16)
	DECL(I,32)
	DECL(U,32)
#ifdef INT64_MAX
	DECL(I,64)
	DECL(U,64)
#endif
	intmax_t imax = INTMAX_C(0);
	uintmax_t umax = UINTMAX_C(0);
	char str0[256], str1[256];

	sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
	if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
	if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
	sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
	if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
	if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
#ifdef INT64_MAX
	sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
	if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
	if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
	sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
	if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
	if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
#endif

	sprintf (str0, "%d %x\n", 0, ~0);

	sprintf (str1, "%d %x\n",  i8, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
	sprintf (str1, "%u %x\n",  u8, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
	sprintf (str1, "%d %x\n",  i16, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
	sprintf (str1, "%u %x\n",  u16, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
	sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n",  i32, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
	sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n",  u32, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
#ifdef INT64_MAX
	sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n",  i64, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
#endif
	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n",  imax, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n",  umax, ~0);
	if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));

	TESTUMAX(8);
	TESTUMAX(16);
	TESTUMAX(32);
#ifdef INT64_MAX
	TESTUMAX(64);
#endif

#define STR(v) #v
#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
	if (err_n) {
		printf ("pstdint.h is not correct.  Please use sizes below to correct it:\n");
	}

	Q(int)
	Q(unsigned)
	Q(long int)
	Q(short int)
	Q(int8_t)
	Q(int16_t)
	Q(int32_t)
#ifdef INT64_MAX
	Q(int64_t)
#endif

	return EXIT_SUCCESS;
}

#endif