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

Overview
Comment:Commit 2018-12-18 - Hashing out changes and stringing along (3/3).
  • cxxomfort: output_info now uses printf instead of ostream.
  • cxxomfort: Added macros NOTHROW and OPEN/CLOSE_STDTR1.
  • cxxomfort: Fixed implementation of _CONSTRUCTOR generator macros.
  • cxxomfort: Added cuchar, string_view.
  • cxxomfort: Fixed implementations in impl/ to not depend on library/ for easier decoupling.
  • cstd: Fixed byte, typesafe_enum non-dependent on library/, use impl/ instead.
  • config: Added better detection of MSVC 2008 w/o SP1, Digital Mars.
  • config: Added patched header for MSVC 2010 <system_error>
  • cuchar: Added header: char16_t, char32_t backport as typedefs.
  • functional: Added a specialization-friendly version of hash<>.
  • functional: Added cxxostd::hash<> for charn_t types (C++11).
  • functional: Added cxxostd:hash<> for enum types (C++14).
  • memory: Added to_bool assist to unique_ptr.
  • string: Added hash<> spec for u16string, u32string (C++11).
  • string_view: Added header: string_view with a preview interface (C++17).
  • system_error: Fixed missing elements to the interface of error_condition.
  • system_error: Added some missing errc identifiers for MSVC 2008.
  • system_error: Added support cxxomfort::errc to deal with wrong errc defintion in MSVC 2010.
  • library:array_ref: Added new members to array_ref for slicing, substring.
  • library:foreach: Added "auto"-esque for the compilers that can support it.
  • library:iterator: Added the p1227 proposal for global ssize.
  • library:type_name: Changed implementation to use string_view.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:575605addfb1c0e0c179a08bb1ae1d11e012d26fc7628a90f22f69fab93c6e51
User & Date: luismachuca 2018-12-20 14:11:57
References
2019-02-20
23:17 Closed ticket [ca81f91c]: No testing with MSVC 2010, 2012 plus 5 other changes artifact: a7f73bc8 user: luismachuca
Context
2018-12-20
16:10
Commit 2018-12-18 - Minor fix.
  • library: Fix inclusion of ssize header.
check-in: e00700a4 user: luismachuca tags: trunk
14:11
Commit 2018-12-18 - Hashing out changes and stringing along (3/3).
  • cxxomfort: output_info now uses printf instead of ostream.
  • cxxomfort: Added macros NOTHROW and OPEN/CLOSE_STDTR1.
  • cxxomfort: Fixed implementation of _CONSTRUCTOR generator macros.
  • cxxomfort: Added cuchar, string_view.
  • cxxomfort: Fixed implementations in impl/ to not depend on library/ for easier decoupling.
  • cstd: Fixed byte, typesafe_enum non-dependent on library/, use impl/ instead.
  • config: Added better detection of MSVC 2008 w/o SP1, Digital Mars.
  • config: Added patched header for MSVC 2010 <system_error>
  • cuchar: Added header: char16_t, char32_t backport as typedefs.
  • functional: Added a specialization-friendly version of hash<>.
  • functional: Added cxxostd::hash<> for charn_t types (C++11).
  • functional: Added cxxostd:hash<> for enum types (C++14).
  • memory: Added to_bool assist to unique_ptr.
  • string: Added hash<> spec for u16string, u32string (C++11).
  • string_view: Added header: string_view with a preview interface (C++17).
  • system_error: Fixed missing elements to the interface of error_condition.
  • system_error: Added some missing errc identifiers for MSVC 2008.
  • system_error: Added support cxxomfort::errc to deal with wrong errc defintion in MSVC 2010.
  • library:array_ref: Added new members to array_ref for slicing, substring.
  • library:foreach: Added "auto"-esque for the compilers that can support it.
  • library:iterator: Added the p1227 proposal for global ssize.
  • library:type_name: Changed implementation to use string_view.
check-in: 575605ad user: luismachuca tags: trunk
2018-11-26
05:08
Commit 2018-11-25 - Heading on, hashing out the future. Preparation for large-scale project changes (2/3).
  • cxxomfort: Added implementation of std::type_index.
  • cstd: Added minimal <typeindex>.
  • functional: Fixed CXXO_IMPLEMENTS_ flag for heterogeneous functors impl (n3421).
  • iterator: Moved cbegin, cend out of base and marked as backports (C++14).
  • iterator: Moved rbegin, rend out of base and marked as backports (C++14).
  • memory: Added missing == nullptr relationals for unique_ptr, to match cppreference.
  • memory: Fixed emplace construct() (move emulation) for allocator_traits, still pending fixes for std::allocator<> support.
  • memory: Fixed hash<> specialization for unique_ptr (C++11).
  • string: Added hash<> specialization for basic_string (C++11).
  • type_index: Added implementation.
  • type_traits: Fixed is_nothrow..., is_trivially... traits in GCC <= 4.6.
  • type_traits: Fixed ...destructible traits in GCC == 4.7.
  • type_traits: Fixed is_final, is_standard_layout for GCC (C++03).
  • utility: Added in_place, in_place_t, etc... (C++17).
  • library: Added strict_type.
  • library: Added string_cast.
check-in: 7bcaa7ae user: luismachuca tags: trunk
Changes

Changes to cxxomfort/cxxomfort/VERSION.txt.

1
cxxomfort 0.81 2018-11-25
|
1
cxxomfort 0.82 2018-12-18

Changes to cxxomfort/cxxomfort/base.hpp.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "./base/nullptr.hpp" // nullptr
#include "./base/static_assert.hpp" // static_assert
#include "./base/move.hpp" // move emulation

#include "./base/cstdint.hpp" // c++11 integer types ([u]intNN_t)
#include "./base/iterator.hpp" // iter. accessors (begin/end, next/prev)
#include "./base/explicit_cast.hpp" // explicit cast operator
#include "./library/i12n.hpp" // { sequence } initialization emulation

#endif

/**
 * @page cxxomfort-base
 * 
 * The set of basic features of cxxomfort. 







<







19
20
21
22
23
24
25

26
27
28
29
30
31
32
#include "./base/nullptr.hpp" // nullptr
#include "./base/static_assert.hpp" // static_assert
#include "./base/move.hpp" // move emulation

#include "./base/cstdint.hpp" // c++11 integer types ([u]intNN_t)
#include "./base/iterator.hpp" // iter. accessors (begin/end, next/prev)
#include "./base/explicit_cast.hpp" // explicit cast operator


#endif

/**
 * @page cxxomfort-base
 * 
 * The set of basic features of cxxomfort. 

Changes to cxxomfort/cxxomfort/config.hpp.

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
..
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
..
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
...
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
...
239
240
241
242
243
244
245









246
247
248
249
250
251
252
...
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
...
354
355
356
357
358
359
360


361
362
363
364
365
366
367
...
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
 * This file contains configuration macros used by the cxxomfort library
 * and it is not intended to be directly used.
 */

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


//
// Standard Mode
//

//! Year of the standard in use (the year part in @c __cplusplus ).
#define CXXOMFORT_CXX_STD (__cplusplus/100)
//! Year of the standard emulated when the compiler is in emulation mode.
#define CXXOMFORT_CXX_EMULATION 0




//
// This section detects the compiler type, major and minor version
// and assigns them for macros for easy evaluation.
//

#define CXXO_COMPILERID_GCC 101
#define CXXO_COMPILERID_DIGITALMARS 102
#define CXXO_COMPILERID_MSC 103
#define CXXO_COMPILERID_CLANG 104

/*
 * Behaviour macros
 */

#if defined(DOXYGEN_DOC)
/**
................................................................................
 * If this macro is defined and has a value <code>>=0</code>, 
 * cxxomfort will, when in C++03 mode, define "away" the word @c constexpr 
 * when found.
 */
#define CXXOFLAG_SHADOW_KEYWORD_constexpr 0

#define CXXOFLAG_INCLUDE_PATH() "/usr/local/include"


#endif






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

#define CXXO_NOTICE_IMPL_(msg) (msg)
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_(  __FILE__ "(" CXXO_STRINGIZE(__LINE__) ") : cxxomfort notice: " msg)
#define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( __FILE__ "(" CXXO_STRINGIZE(__LINE__) ") : cxxomfort warning: " msg)


//------------------------------------------------


#include "config/_support.hpp"


// Detect CXX_STD and operation mode (initial)

/*
#if (__cplusplus >= 201103L && __cplusplus < 201402L)
    #undef  CXXOMFORT_CXX_STD
................................................................................
#if 0
#elif defined(__clang__)
    #include "./config/clang.hpp"
#elif defined(__GNUC__)
    #include "./config/gcc.hpp"
#elif defined(_MSC_VER)
    #include "./config/msc.hpp"


#else

// this is an unknown / unsupported compiler, assume things just work™.
    #define CXXOMFORT_COMPILER_ID 0
    #define CXXOMFORT_COMPILER_VERSION 0


    #define CXXO_NOTICE(msg) _Pragma(message ("WARNING - " msg))
    #if defined(CXXOMFORT_NOTICES)
        #pragma message CXXO_WARNING("Found an undetermined compiler.")
    #endif
#endif

#if (defined(CXXOMFORT_NOTICES))
    #pragma message CXXO_NOTICE("compiler found : " CXXO_STRINGIZE(CXXOMFORT_COMPILER_ID) "." CXXO_STRINGIZE(CXXOMFORT_COMPILER_VERSION)  )

    #pragma message CXXO_NOTICE("library mode   : ver=" CXXO_STRINGIZE(CXXOMFORT_DATE) " std=" CXXO_STRINGIZE(CXXOMFORT_CXX_STD) ",emu=" CXXO_STRINGIZE(CXXOMFORT_CXX_EMULATION) )


/*
 * Set up more friendly messages
 */
    #if (CXXOMFORT_NOTICES > 1)

        #if 0
................................................................................
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i586
#elif defined(__arm__) || defined(_M_ARM) || defined (__thumb__)
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_arm
#else
    #define CXXOMFORT_ARCHITECTURE 0
#endif

/*
 * Set the location of the default C++ system headers so that they can be
 * #included directly and distinguished from the system wrappers in cstd/
 */
#if defined(_WIN32) && defined(_MSC_VER)
#elif defined(__linux__) || defined(__GNUC__)
#else
    //#warning (" cxxomfort - taking ???? include path")
    // with no better information we just bet that the
    // includes live in the standard directory
    // warning: this might cause an endless #include loop if used with the
    // cstd/ wrapper headers
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_WARNING("Using default include paths")
    #endif
    #define CXXO_INCLUDE_SYS(NAME) <NAME>
#endif

//
// ---------------------------------------------------------
//

// Macros to conditionally generate keywords

................................................................................
// Evaluates to noexcept where noexcept is supported
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOEXCEPT
#else
    #define CXXO_NOEXCEPT noexcept
#endif










//
// CXXO_NOEXCEPTNOTHROW
// Evaluates to noexcept where noexcept is supported, and to throw() in C++03
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOEXCEPTNOTHROW throw() 
#else
    #define CXXO_NOEXCEPTNOTHROW noexcept
................................................................................

//
// CXXO_NOEXCEPT_COND(...)
// Evaluates to the noexcept of the condition in C++11 onwards, and to nothing in C++03
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOEXCEPT_COND(...)
#else
    #define CXXO_NOEXCEPT_COND(...) noexcept(...)
#endif

//
//if CXXOFLAG_SHADOW_KEYWORD_constexpr is defined and >=0, c++03 will whisk away "constexpr"
#ifdef CXXOFLAG_SHADOW_KEYWORD_constexpr
    #if (CXXOMFORT_CXX_STD < 2011 && CXXOFLAG_SHADOW_KEYWORD_constexpr>0)
        #define constexpr 
        #if (CXXOMFORT_NOTICES > 1)
            #pragma message CXXO_NOTICE("flag 'SHADOW_KEYWORD_constexpr' - constexpr has been whisked away")
        #endif
    #endif
#endif



#define CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(Type) \
CXXO_CONSTEXPR14 Type () CXXOMFORT_CXX11_CODE( noexcept = default, throw() {} )









#define CXXO_DEFAULT_COPY_CONSTRUCTOR(Type, ...) \
CXXO_CONSTEXPR Type (Type const& t) CXXOMFORT_CXX11_CODE( noexcept = default, throw() __VA_ARGS__ );













#define CXXO_DEFAULT_COPY_CONSTRUCTOR_UNSAFE(Type, ...) \
CXXO_CONSTEXPR Type (Type const& t) CXXOMFORT_CXX11_CODE( = default, __VA_ARGS__ );


















































//
// ---------------------------------------------------------
//

/*
 * Set up the minimal configuration.
................................................................................
#endif // default_delete
}
*/

//
// ---------------------------------------------------------
//



//! The default namespace of C++ Standard stuff.
namespace std {}
//! Namespace of the @c cxxomfort library.
namespace cxxomfort {
//! Namespace that holds the library's backports of named C++ features.
namespace cxxostd {}
................................................................................
    enum {
    //! library version
    version = CXXOMFORT_VERSION , 
    date = CXXOMFORT_DATE, 
    //! compiler identification code
    compilerid = CXXOMFORT_COMPILER_ID ,
    //! compiler version code (usually <code>100*major+minor</code>)
    compilerversion = CXXOMFORT_COMPILER_VERSION ,

    //! value of the standard
    cxx_std = CXXOMFORT_CXX_STD ,
    //! level of support of C++11 features in C++11 emulation / c++0x mode
    cxx_emulation = CXXOMFORT_CXX_EMULATION , 
    cplusplus = __cplusplus
    };
    
    /* struct */ 
} $ = {};

template <typename SS> 
static void output_info (SS& os) {
    os<< "(cxxomfort:"<< $.date<< ":"<< $.version
      << " compiler:"<< $.compilerid<< ":"<< $.compilerversion
      << " mode:"<< $.cxx_std<< ":"<< $.cxx_emulation<< " cpp:"<< __cplusplus<< ")";


    //return os;
}

// ~::cxxomfort
}

/**







<








>
>
>







|
|
|







 







>

|
>
>
>
>





|
|





<







 







>
>





>
>







|
>
|
>







 







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







 







>
>
>
>
>
>
>
>
>







 







|





|








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

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

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







 







>
>







 







|
>

|

|







|
|
|
|
>
>







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
..
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
...
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
...
203
204
205
206
207
208
209

















210
211
212
213
214
215
216
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
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
...
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
...
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
 * This file contains configuration macros used by the cxxomfort library
 * and it is not intended to be directly used.
 */

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


//
// Standard Mode
//

//! Year of the standard in use (the year part in @c __cplusplus ).
#define CXXOMFORT_CXX_STD (__cplusplus/100)
//! Year of the standard emulated when the compiler is in emulation mode.
#define CXXOMFORT_CXX_EMULATION 0

#include "config/_support.hpp"


//
// This section detects the compiler type, major and minor version
// and assigns them for macros for easy evaluation.
//

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

/*
 * Behaviour macros
 */

#if defined(DOXYGEN_DOC)
/**
................................................................................
 * If this macro is defined and has a value <code>>=0</code>, 
 * cxxomfort will, when in C++03 mode, define "away" the word @c constexpr 
 * when found.
 */
#define CXXOFLAG_SHADOW_KEYWORD_constexpr 0

#define CXXOFLAG_INCLUDE_PATH() "/usr/local/include"
#define CXXO_INCLUDE_SYS(NAME) <NAME>

#endif // doxygen


#define CXXOFLAG_INCLUDE_PATH() "/usr/local/include"
#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)
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_(  __FILE__ "(" CXXO_STRINGIZE1(__LINE__) ") : cxxomfort notice: " msg)
#define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( __FILE__ "(" CXXO_STRINGIZE1(__LINE__) ") : cxxomfort warning: " msg)


//------------------------------------------------





// Detect CXX_STD and operation mode (initial)

/*
#if (__cplusplus >= 201103L && __cplusplus < 201402L)
    #undef  CXXOMFORT_CXX_STD
................................................................................
#if 0
#elif defined(__clang__)
    #include "./config/clang.hpp"
#elif defined(__GNUC__)
    #include "./config/gcc.hpp"
#elif defined(_MSC_VER)
    #include "./config/msc.hpp"
#elif defined(__DMC__)
    #include "./config/dmc.hpp"
#else

// this is an unknown / unsupported compiler, assume things just work™.
    #define CXXOMFORT_COMPILER_ID 0
    #define CXXOMFORT_COMPILER_VERSION 0
    #define CXXOMFORT_COMPILER_VERSION_FULL 0

    #define CXXO_NOTICE(msg) _Pragma(message ("WARNING - " msg))
    #if defined(CXXOMFORT_NOTICES)
        #pragma message CXXO_WARNING("Found an undetermined compiler.")
    #endif
#endif

#if (defined(CXXOMFORT_NOTICES))
    #pragma message CXXO_NOTICE("compiler found : " \
    CXXO_STRINGIZE1(CXXOMFORT_COMPILER_ID) "." CXXO_STRINGIZE1(CXXOMFORT_COMPILER_VERSION)  )
    #pragma message CXXO_NOTICE("library mode   : ver=" \
    CXXO_STRINGIZE1(CXXOMFORT_DATE) " std=" CXXO_STRINGIZE1(CXXOMFORT_CXX_STD) ",emu=" CXXO_STRINGIZE1(CXXOMFORT_CXX_EMULATION) )

/*
 * Set up more friendly messages
 */
    #if (CXXOMFORT_NOTICES > 1)

        #if 0
................................................................................
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i586
#elif defined(__arm__) || defined(_M_ARM) || defined (__thumb__)
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_arm
#else
    #define CXXOMFORT_ARCHITECTURE 0
#endif



















//
// ---------------------------------------------------------
//

// Macros to conditionally generate keywords

................................................................................
// Evaluates to noexcept where noexcept is supported
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOEXCEPT
#else
    #define CXXO_NOEXCEPT noexcept
#endif

//
// CXXO_NOTHROW
// Evaluates to noexcept where noexcept is supported
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOTHROW throw()
#else
    #define CXXO_NOTHROW 
#endif

//
// CXXO_NOEXCEPTNOTHROW
// Evaluates to noexcept where noexcept is supported, and to throw() in C++03
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOEXCEPTNOTHROW throw() 
#else
    #define CXXO_NOEXCEPTNOTHROW noexcept
................................................................................

//
// CXXO_NOEXCEPT_COND(...)
// Evaluates to the noexcept of the condition in C++11 onwards, and to nothing in C++03
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_noexcept == 0)
    #define CXXO_NOEXCEPT_COND(...)
#else
    #define CXXO_NOEXCEPT_COND(...) noexcept(__VA_ARGS__)
#endif

//
//if CXXOFLAG_SHADOW_KEYWORD_constexpr is defined and >=0, c++03 will whisk away "constexpr"
#ifdef CXXOFLAG_SHADOW_KEYWORD_constexpr
    #if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_constexpr == 0)
        #define constexpr 
        #if (CXXOMFORT_NOTICES > 1)
            #pragma message CXXO_NOTICE("flag 'SHADOW_KEYWORD_constexpr' - constexpr has been whisked away")
        #endif
    #endif
#endif


/**
 * @def CXXO_DEFAULT_DEFAULT_CONSTRUCTOR

 * Macros for generating code snippers that change between C++ versions 
 * for particular types of members.
 * Examples: default-ctors, trivial copy-ctors, default assignment, etc.
 * 
 * */

// Announces the default-generated default constructor.
#if (CXXOMFORT_CXX_STD >= 2011 || \
(CXXO_COMPILER_SUPPORT_default_delete && CXXO_COMPILER_SUPPORT_noexcept))
    #define CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(Type) \

    CXXO_CONSTEXPR Type () = default
#else
    #define CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(Type) \
    Type () throw() {} 
#endif

/**
 * @def CXXO_DEFAULT_COPY_CONSTRUCTOR
 * @brief Announces a default copy constructor.
 * @param Su constructor suffix (eg.: noexcept)
 * @params ... Explicit constructor body (for C++03)
 * */
#if (CXXOMFORT_CXX_STD>=2011 || CXXO_COMPILER_SUPPORT_default_delete)
    #define CXXO_DEFAULT_COPY_CONSTRUCTOR(Type, Su, ...) \

    Type (Type const& ) Su = default 
#else 
    #define CXXO_DEFAULT_COPY_CONSTRUCTOR(Type, Su, ...) \
    Type (Type const& v) Su \
    : __VA_ARGS__ {} 
#endif


/**
 * @def CXXO_DELETED_COPY_CONSTRUCTOR
 * @brief Announces a deleted (unavailable) copy constructor.
 * */
#if (CXXOMFORT_CXX_STD>=2011 || CXXO_COMPILER_SUPPORT_default_delete)
    #define CXXO_DELETED_COPY_CONSTRUCTOR(Type) Type (Type const&) = delete
    #define CXXO_DELETED_COPY_ASSIGN(Type) Type& operator= (Type const&) = delete
#else
    #define CXXO_DELETED_COPY_CONSTRUCTOR(Type) private: Type (Type const&);public: 
    #define CXXO_DELETED_COPY_ASSIGN(Type) private: Type& operator= (Type const&); public: 
#endif

/**
 * */
// uses macro CXXO_SIG_CONDITION, to be set at call site, 
// to create conditional template/function arguments for SFINAE
#if (CXXOMFORT_CXX_STD >= 2011)
    #define CXXO_ENABLEIF_TEMPLATE() \
    , typename = typename std::enable_if< CXXO_SIGCONDITION >::type 
    #define CXXO_ENABLEIF_FUNCTION() 
#else
    #define CXXO_ENABLEIF_TEMPLATE() 
    #define CXXO_ENABLEIF_FUNCTION() \
    , typename std::enable_if< CXXO_SIGCONDITION >::type * = nullptr 
    
#endif


/*
 * Opens the namespace where tr1 extensions live
 * */
#if (CXXOMFORT_CXX_STD < 2011 && \
    (CXXOMFORT_CXX_EMULATION < 2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC) || \
    (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && CXXOMFORT_COMPILER_VERSION < 1600) \
)
    #define CXXO_OPEN_STDTR1() namespace std { namespace tr1 {
    #define CXXO_CLOSE_STDTR1() } }
#else 
    #define CXXO_OPEN_STDTR1() namespace std { 
    #define CXXO_CLOSE_STDTR1() } 
#endif

//
// ---------------------------------------------------------
//

/*
 * Set up the minimal configuration.
................................................................................
#endif // default_delete
}
*/

//
// ---------------------------------------------------------
//

#include <cstdio>

//! The default namespace of C++ Standard stuff.
namespace std {}
//! Namespace of the @c cxxomfort library.
namespace cxxomfort {
//! Namespace that holds the library's backports of named C++ features.
namespace cxxostd {}
................................................................................
    enum {
    //! library version
    version = CXXOMFORT_VERSION , 
    date = CXXOMFORT_DATE, 
    //! compiler identification code
    compilerid = CXXOMFORT_COMPILER_ID ,
    //! compiler version code (usually <code>100*major+minor</code>)
    compilerversion = static_cast<unsigned>(CXXOMFORT_COMPILER_VERSION) ,
    compilerversionfull = static_cast<unsigned long>(CXXOMFORT_COMPILER_VERSION_FULL) ,
    //! value of the standard
    cxx_std = static_cast<unsigned>(CXXOMFORT_CXX_STD) ,
    //! level of support of C++11 features in C++11 emulation / c++0x mode
    cxx_emulation = static_cast<unsigned>(CXXOMFORT_CXX_EMULATION) , 
    cplusplus = __cplusplus
    };
    
    /* struct */ 
} $ = {};

template <typename SS> 
static void output_info (SS&) {
    using namespace std;
    printf( "(cxxomfort:%u:%u ", $.date, $.version);
    printf( "compiler:%u:%u (%u)", $.compilerid, $.compilerversion, $.compilerversionfull );
    printf( " mode:%u:%u cpp:%lu)\n", $.cxx_std, $.cxx_emulation
    , static_cast<unsigned long>(__cplusplus));
    //return os;
}

// ~::cxxomfort
}

/**

Changes to cxxomfort/cxxomfort/config/_pre.hpp.

1
2
3
4
5
6

7


8

9
10
11
12

13
14
15
16

17
18
19
20
21
22
23
#ifndef CXXOMFORT_CONFIG_HPP
    #error "This file should only be #included via <cxxomfort/config.hpp>"
#endif
#ifndef CXXOMFORT_CONFIG_PRE_HPP
#define CXXOMFORT_CONFIG_PRE_HPP





#define CXXO_STRINGIZE_IMPL(...) #__VA_ARGS__

#define CXXO_STRINGIZE(...) CXXO_STRINGIZE_IMPL(__VA_ARGS__)

#define CXXO_STRINGIZE1_IMPL2(x) #x
#define CXXO_STRINGIZE1_IMPL1(x) CXXO_STRINGIZE1_IMPL2(x)

#define CXXO_STRINGIZE1(x) CXXO_STRINGIZE1_IMPL1(x)

#define CXXO_JOIN_IMPL2(x,y) x##y
#define CXXO_JOIN_IMPL1(x,y) CXXO_JOIN_IMPL2(x,y)

#define CXXO_JOIN(x,y) CXXO_JOIN_IMPL1(x,y)

#define CXXOMFORT_ISODATE() \
( \
((__DATE__[7]-'0')*1000 + (__DATE__[8]-'0')*100 + (__DATE__[9]-'0')*10 + (__DATE__[10]-'0') ) * 10000UL \
+ ( \
 ((__DATE__[0]=='J' ? 1:0)) | \






>

>
>

>




>




>







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
#ifndef CXXOMFORT_CONFIG_HPP
    #error "This file should only be #included via <cxxomfort/config.hpp>"
#endif
#ifndef CXXOMFORT_CONFIG_PRE_HPP
#define CXXOMFORT_CONFIG_PRE_HPP

#define CXXO_NONE() 

#define CXXO_COMMA() ,

#define CXXO_STRINGIZE_IMPL(...) #__VA_ARGS__
//! Stringizes tokens (transforms them into a string literal)
#define CXXO_STRINGIZE(...) CXXO_STRINGIZE_IMPL(__VA_ARGS__)

#define CXXO_STRINGIZE1_IMPL2(x) #x
#define CXXO_STRINGIZE1_IMPL1(x) CXXO_STRINGIZE1_IMPL2(x)
//! Stringizes a token (transforms it into a string literal)
#define CXXO_STRINGIZE1(x) CXXO_STRINGIZE1_IMPL1(x)

#define CXXO_JOIN_IMPL2(x,y) x##y
#define CXXO_JOIN_IMPL1(x,y) CXXO_JOIN_IMPL2(x,y)
//! Joins tokens
#define CXXO_JOIN(x,y) CXXO_JOIN_IMPL1(x,y)

#define CXXOMFORT_ISODATE() \
( \
((__DATE__[7]-'0')*1000 + (__DATE__[8]-'0')*100 + (__DATE__[9]-'0')*10 + (__DATE__[10]-'0') ) * 10000UL \
+ ( \
 ((__DATE__[0]=='J' ? 1:0)) | \

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

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
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
213
214
215
216
217
218
219
220

















221


 * @file
 */

/**
 * @ingroup cxxomfort-config
 * @{
 * */



// c++03 stuff

//! If compiler provides support for <code>\<functional\></code>'s classic binders.
#define CXXO_COMPILER_SUPPORT_functional_oldstyle (CXXOMFORT_CXX_STD<2017)
//! If compiler includes tr1/random header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_random 0
//! If compiler includes tr1/tuple header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_tuple 0
//! If compiler includes tr1/type_traits header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_type_traits 0
//! If compiler provides support for @c __typeof__ in C++03.
#define CXXO_COMPILER_SUPPORT_typeof 0



// c++11 stuff

//! If compiler provides support for alignment tools (@c alignas , @c aligned_storage , etc).
#define CXXO_COMPILER_SUPPORT_alignment_tools 0
//! If compiler provides support for @c alignof(T) .
#define CXXO_COMPILER_SUPPORT_alignof 0
//! If compiler provides support for <code>[[__attribute__]]</code>.
#define CXXO_COMPILER_SUPPORT_attribute (CXXOMFORT_CXX_STD >= 2011)
//! If compiler supports new (type-deduction) semantics for @c auto .
#define CXXO_COMPILER_SUPPORT_auto (CXXOMFORT_CXX_STD>=2011)




//! If compiler provides support for the new C++11 helpers std::enable_if, std::conditional.
#define CXXO_COMPILER_SUPPORT_conditional_enableif (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cinttypes> header
#define CXXO_COMPILER_SUPPORT_cstd_cinttypes (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cstdint> header
#define CXXO_COMPILER_SUPPORT_cstd_cstdint (CXXOMFORT_CXX_STD>=2011)


//! If compiler brings <system_error> header.
#define CXXO_COMPILER_SUPPORT_cstd_system_error (CXXOMFORT_CXX_STD>=2011)
//! If compiler brings <typeindex> header.
#define CXXO_COMPILER_SUPPORT_cstd_typeindex (CXXOMFORT_CXX_STD>=2011)
//! If compiler supports @c decltype(expr) .
#define CXXO_COMPILER_SUPPORT_decltype (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code>=default</code>-ed and <code>=delete</code>-d members.
................................................................................
#define CXXO_COMPILER_SUPPORT_trailing_returns (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for user-defined-literals.
#define CXXO_COMPILER_SUPPORT_user_defined_literals (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c unique_ptr<T> .
#define CXXO_COMPILER_SUPPORT_unique_ptr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for variadic templates.
#define CXXO_COMPILER_SUPPORT_variadic (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for variadic macros (<code>__VA_ARG__</code>).
#define CXXO_COMPILER_SUPPORT_va_args 0

// c++14 stuff

//! If compiler provides support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_attribute_deprecated (CXXOMFORT_CXX_STD>=2014)
//! If compiler provides support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)
................................................................................
 * n3928 - static_assert without message
 * p0005r2 - not_fn
 * p0007r1 - as_const
 * 
 
 * 
 */


















#endif









>
>
>












>
>











>
>
>
>








>
>







 







<
<







 








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

>
>
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
..
99
100
101
102
103
104
105


106
107
108
109
110
111
112
...
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
 * @file
 */

/**
 * @ingroup cxxomfort-config
 * @{
 * */

#define CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x 0

// c++03 stuff

//! If compiler provides support for <code>\<functional\></code>'s classic binders.
#define CXXO_COMPILER_SUPPORT_functional_oldstyle (CXXOMFORT_CXX_STD<2017)
//! If compiler includes tr1/random header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_random 0
//! If compiler includes tr1/tuple header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_tuple 0
//! If compiler includes tr1/type_traits header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_type_traits 0
//! If compiler provides support for @c __typeof__ in C++03.
#define CXXO_COMPILER_SUPPORT_typeof 0
//! If compiler provides support for variadic macros (<code>__VA_ARG__</code>).
#define CXXO_COMPILER_SUPPORT_va_args 0

// c++11 stuff

//! If compiler provides support for alignment tools (@c alignas , @c aligned_storage , etc).
#define CXXO_COMPILER_SUPPORT_alignment_tools 0
//! If compiler provides support for @c alignof(T) .
#define CXXO_COMPILER_SUPPORT_alignof 0
//! If compiler provides support for <code>[[__attribute__]]</code>.
#define CXXO_COMPILER_SUPPORT_attribute (CXXOMFORT_CXX_STD >= 2011)
//! If compiler supports new (type-deduction) semantics for @c auto .
#define CXXO_COMPILER_SUPPORT_auto (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for the new C++11 char types.
#define CXXO_COMPILER_SUPPORT_charn_t (CXXOMFORT_CXX_STD>=2011)
//! If the above types are defined as typedef of integral types (such as unsigned short).
#define CXXO_COMPILER_SUPPORT_charn_t_IS_TYPEDEF 0
//! If compiler provides support for the new C++11 helpers std::enable_if, std::conditional.
#define CXXO_COMPILER_SUPPORT_conditional_enableif (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cinttypes> header
#define CXXO_COMPILER_SUPPORT_cstd_cinttypes (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cstdint> header
#define CXXO_COMPILER_SUPPORT_cstd_cstdint (CXXOMFORT_CXX_STD>=2011)
//! If compiler supports <cuchar> header.
#define CXXO_COMPILER_SUPPORT_cstd_cuchar (CXXOMFORT_CXX_STD>=2011)
//! If compiler brings <system_error> header.
#define CXXO_COMPILER_SUPPORT_cstd_system_error (CXXOMFORT_CXX_STD>=2011)
//! If compiler brings <typeindex> header.
#define CXXO_COMPILER_SUPPORT_cstd_typeindex (CXXOMFORT_CXX_STD>=2011)
//! If compiler supports @c decltype(expr) .
#define CXXO_COMPILER_SUPPORT_decltype (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code>=default</code>-ed and <code>=delete</code>-d members.
................................................................................
#define CXXO_COMPILER_SUPPORT_trailing_returns (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for user-defined-literals.
#define CXXO_COMPILER_SUPPORT_user_defined_literals (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c unique_ptr<T> .
#define CXXO_COMPILER_SUPPORT_unique_ptr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for variadic templates.
#define CXXO_COMPILER_SUPPORT_variadic (CXXOMFORT_CXX_STD>=2011)



// c++14 stuff

//! If compiler provides support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_attribute_deprecated (CXXOMFORT_CXX_STD>=2014)
//! If compiler provides support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)
................................................................................
 * n3928 - static_assert without message
 * p0005r2 - not_fn
 * p0007r1 - as_const
 * 
 
 * 
 */

#if defined(DOXYGEN_DOC)
#define CXXOFLAG_CXXHEADERS defined_if_using_cstd
//! If defined, most names are not added to namespace std (note: unsupported).
#define CXXOFLAG_NO_STD_USING defined_if_no_using_namespace_std_for_names
//! If defined, the keyword "constexpr" is defined away in c++03.
#define CXXOFLAG_SHADOW_KEYWORD_constexpr defined_if_constexpr_is_custom_keyword
//! if defined, the keyword "noexcept" is defined away in c++03.
#define CXXOFLAG_SHADOW_KEYWORD_noexcept defined_if_noexcept_is_custom_keyword
//! If defined, alternate filesystm path where to find C++ headers.
#define CXXOFLAG_INCLUDE_PATH includepath_to_system_includes
//! If defined, ????
#define CXXOFLAG_MAKE_CXXOSTD_TYPES_NATIVE 0
//! If defined, ????
#define CXXOFLAG_byte_IS_TYPEDEF 0
//! If defined, backports of char16_t, char32_t use typedefs.
#define CXXOFLAG_MAKE_TYPEDEF_charn_t 0

#endif

#endif

Changes to cxxomfort/cxxomfort/config/_version.hpp.

1
2
3
4
5
//! Library version and release date as YYYYMMDD
#define CXXOMFORT_DATE 20181125UL
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 81


|

|

1
2
3
4
5
//! Library version and release date as YYYYMMDD
#define CXXOMFORT_DATE 20181218UL
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 82

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

21
22
23
24
25
26
27


28
29
30
31
32
33
34
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_( "cxxomfort notice: " msg)
#define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( "cxxomfort warning: " msg)

#if defined(CXXOMFORT_NOTICES)
    #pragma CXXO_NOTICE("Found the Clang C++ Compiler.")
#endif



#undef  CXXO_COMPILER_SUPPORT_alignof
#define CXXO_COMPILER_SUPPORT_alignof (CXXOMFORT_CXX_STD >= 2011)
#undef  CXXO_COMPILER_SUPPORT_alignment_tools
#define CXXO_COMPILER_SUPPORT_alignment_tools __has_extension(cxx_alignas)
#undef  CXXO_COMPILER_SUPPORT_attribute
#define CXXO_COMPILER_SUPPORT_attribute __has_extension(cxx_attributes)
#undef  CXXO_COMPILER_SUPPORT_auto







>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_( "cxxomfort notice: " msg)
#define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( "cxxomfort warning: " msg)

#if defined(CXXOMFORT_NOTICES)
    #pragma CXXO_NOTICE("Found the Clang C++ Compiler.")
#endif

#undef  CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x
#define CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x 1
#undef  CXXO_COMPILER_SUPPORT_alignof
#define CXXO_COMPILER_SUPPORT_alignof (CXXOMFORT_CXX_STD >= 2011)
#undef  CXXO_COMPILER_SUPPORT_alignment_tools
#define CXXO_COMPILER_SUPPORT_alignment_tools __has_extension(cxx_alignas)
#undef  CXXO_COMPILER_SUPPORT_attribute
#define CXXO_COMPILER_SUPPORT_attribute __has_extension(cxx_attributes)
#undef  CXXO_COMPILER_SUPPORT_auto

Added cxxomfort/cxxomfort/config/dmc.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
#ifndef CXXOMFORT_CONFIG_HPP
    #error "This file must not be included directly (see cxxomfort/config.hpp)"
#endif
#ifndef CXXOMFORT_CONFIG_DMC_HPP
#define CXXOMFORT_CONFIG_DMC_HPP


// from https://sourceforge.net/p/predef/wiki/Compilers/
#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_DMC
#define CXXOMFORT_COMPILER_VERSION (__DMC__)
// eg.: 120 for VC6 (ugh!), 150 for VC9 (Studio / Express 2008)

#define CXXO_PRAGMA(x) _Pragma (#x)

#undef  CXXO_NOTICE_IMPL_ 
#define CXXO_NOTICE_IMPL_(msg) msg
#undef  CXXO_NOTICE
#define CXXO_NOTICE(msg) CXXO_NOTICE_IMPL_( "cxxomfort notice: " msg)



#if defined(CXXOMFORT_NOTICES)

    #pragma message CXXO_NOTICE("Found the Digital Mars Compiler [" CXXO_STRINGIZE(__DMC__) "]" )
#endif


#undef  CXXO_INCLUDE_SYS
#define CXXO_INCLUDE_SYS(NAME) <../../dm/stlport/stlport/NAME>


#if (CXXOMFORT_COMPILER_VERSION >= 850)
    #undef  CXXO_COMPILER_SUPPORT_charn_t
    #define CXXO_COMPILER_SUPPORT_charn_t 1
    #define CXXO_COMPILER_SUPPORT_charn_t_IS_TYPEDEF 0
    #undef  CXXO_COMPILER_SUPPORT_decltype
    #define CXXO_COMPILER_SUPPORT_decltype 1
    #undef  CXXO_COMPILER_SUPPORT_nullptr
    #define CXXO_COMPILER_SUPPORT_nullptr 1
    

#endif


#include <cstddef>
namespace std {
    using ::nullptr_t;
}


#endif

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

32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
..
70
71
72
73
74
75
76

77
78
79
80
81
82
83
..
92
93
94
95
96
97
98


99

100
101
102
103
104
105
106
...
123
124
125
126
127
128
129




130
131
132
133
134
135
136
...
145
146
147
148
149
150
151


152
153
154
155
156
157
158
 * For correct usage of this library emulation mode
 * ("C++0x") should not be used below GCC 4.6; 
 * normal C++03 plus a TR1 implementation should be used instead.
 */


#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_GCC
#define CXXOMFORT_COMPILER_VERSION (__GNUC__*100+__GNUC_MINOR__)


//#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
................................................................................
#endif


/**
 * GCC headers tend to be organized via a 
 * path with subfolders {bits,tr1}
 */

#define CXXO_INCLUDE_SYS(name) <bits/../tr1/../name>
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_WARNING("Using bits/../tr1/../<version> include paths")
#endif


#undef  CXXO_COMPILER_SUPPORT_typeof
................................................................................
            #pragma message CXXO_WARNING( "Configuration not supported (nullptr and other basic features might be missing)" )
        #endif
        #undef  CXXO_COMPILER_SUPPORT_static_assert
        #define CXXO_COMPILER_SUPPORT_static_assert 1
        #undef  CXXO_COMPILER_SUPPORT_decltype
        #define CXXO_COMPILER_SUPPORT_decltype 2343
    #endif


#endif

#if (CXXOMFORT_COMPILER_VERSION >= 404)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        // Note: *Unsupported* c++0x emulation mode
        #undef  CXXO_COMPILER_SUPPORT_auto
        #define CXXO_COMPILER_SUPPORT_auto 1984
        #undef  CXXO_COMPILER_SUPPORT_conditional_enableif 
        #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
................................................................................
        #define CXXO_COMPILER_SUPPORT_variadic 1
    #else
        #undef  CXXO_COMPILER_SUPPORT_tr1_random
        #undef  CXXO_COMPILER_SUPPORT_tr1_tuple
        #define CXXO_COMPILER_SUPPORT_tr1_random 1
        #define CXXO_COMPILER_SUPPORT_tr1_tuple 1
        




    #endif
#endif
#if (CXXOMFORT_COMPILER_VERSION >= 405)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        #undef  CXXO_COMPILER_SUPPORT_alignof
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #undef  CXXO_COMPILER_SUPPORT_explicit_operator
................................................................................
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #undef  CXXO_COMPILER_SUPPORT_auto
        #define CXXO_COMPILER_SUPPORT_auto 1
        #undef  CXXO_COMPILER_SUPPORT_cstd_cstdint
        #define CXXO_COMPILER_SUPPORT_cstd_cstdint 1
        #undef  CXXO_COMPILER_SUPPORT_cstd_system_error
        #define CXXO_COMPILER_SUPPORT_cstd_system_error 1


        #undef  CXXO_COMPILER_SUPPORT_conditional_enableif 
        #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
        #undef  CXXO_COMPILER_SUPPORT_default_delete
        #define CXXO_COMPILER_SUPPORT_default_delete 1
        #undef  CXXO_COMPILER_SUPPORT_enum_class
        #define CXXO_COMPILER_SUPPORT_enum_class 1
        #undef  CXXO_COMPILER_SUPPORT_foreach







|
>







 







>







 







>
>

>







 







>
>
>
>







 







>
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
..
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 * For correct usage of this library emulation mode
 * ("C++0x") should not be used below GCC 4.6; 
 * normal C++03 plus a TR1 implementation should be used instead.
 */


#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
................................................................................
#endif


/**
 * GCC headers tend to be organized via a 
 * path with subfolders {bits,tr1}
 */
#undef  CXXO_INCLUDE_SYS
#define CXXO_INCLUDE_SYS(name) <bits/../tr1/../name>
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_WARNING("Using bits/../tr1/../<version> include paths")
#endif


#undef  CXXO_COMPILER_SUPPORT_typeof
................................................................................
            #pragma message CXXO_WARNING( "Configuration not supported (nullptr and other basic features might be missing)" )
        #endif
        #undef  CXXO_COMPILER_SUPPORT_static_assert
        #define CXXO_COMPILER_SUPPORT_static_assert 1
        #undef  CXXO_COMPILER_SUPPORT_decltype
        #define CXXO_COMPILER_SUPPORT_decltype 2343
    #endif
    #undef  CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x
    #define CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x 1
#endif

#if (CXXOMFORT_COMPILER_VERSION >= 404)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        // Note: *Unsupported* c++0x emulation mode
        #undef  CXXO_COMPILER_SUPPORT_auto
        #define CXXO_COMPILER_SUPPORT_auto 1984
        #undef  CXXO_COMPILER_SUPPORT_conditional_enableif 
        #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
................................................................................
        #define CXXO_COMPILER_SUPPORT_variadic 1
    #else
        #undef  CXXO_COMPILER_SUPPORT_tr1_random
        #undef  CXXO_COMPILER_SUPPORT_tr1_tuple
        #define CXXO_COMPILER_SUPPORT_tr1_random 1
        #define CXXO_COMPILER_SUPPORT_tr1_tuple 1
        
        #if !defined(CXXOFLAG_MAKE_TYPEDEF_charn_t)
            #define CXXOFLAG_MAKE_TYPEDEF_charn_t // necessary because of SSO in <string>
        #endif

    #endif
#endif
#if (CXXOMFORT_COMPILER_VERSION >= 405)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        #undef  CXXO_COMPILER_SUPPORT_alignof
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #undef  CXXO_COMPILER_SUPPORT_explicit_operator
................................................................................
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #undef  CXXO_COMPILER_SUPPORT_auto
        #define CXXO_COMPILER_SUPPORT_auto 1
        #undef  CXXO_COMPILER_SUPPORT_cstd_cstdint
        #define CXXO_COMPILER_SUPPORT_cstd_cstdint 1
        #undef  CXXO_COMPILER_SUPPORT_cstd_system_error
        #define CXXO_COMPILER_SUPPORT_cstd_system_error 1
        #undef  CXXO_COMPILER_SUPPORT_charn_t
        #define CXXO_COMPILER_SUPPORT_charn_t 2 // defined as their own types
        #undef  CXXO_COMPILER_SUPPORT_conditional_enableif 
        #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
        #undef  CXXO_COMPILER_SUPPORT_default_delete
        #define CXXO_COMPILER_SUPPORT_default_delete 1
        #undef  CXXO_COMPILER_SUPPORT_enum_class
        #define CXXO_COMPILER_SUPPORT_enum_class 1
        #undef  CXXO_COMPILER_SUPPORT_foreach

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

21
22
23
24
25
26
27

28
29
30
31
32
33
34
..
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
..
97
98
99
100
101
102
103

104
105
106
107
108
109
110
...
142
143
144
145
146
147
148





149
150
151
152
 * http://msdn.microsoft.com/en-us/library/ms177194%28v=VS.100%29.aspx
 *
*/


#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_MSC
#define CXXOMFORT_COMPILER_VERSION (_MSC_VER)

// eg.: 120 for VC6 (ugh!), 150 for VC9 (Studio / Express 2008)

#define CXXO_PRAGMA(x) _Pragma (#x)

#if defined(CXXOMFORT_NOTICES)

    #pragma message CXXO_NOTICE("Found the Microsoft C++ Compiler [" CXXO_STRINGIZE(_MSC_VER) "]" )
................................................................................
    #error "cxxomfort -- Detected an horribly broken compiler! (MSVC6 or earlier)"
#endif

/**
 * MSVC headers tend to be organized via a 
 * path like ${VISUAL_STUDIO}/VC/include
 */

#define CXXO_INCLUDE_SYS(NAME) <../../VC/include/NAME>
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_WARNING("Using Windows+MSC include paths")
#endif


// At least VC2005
#if (CXXOMFORT_COMPILER_VERSION > 1200)
#endif

// At least VC2008
#if (CXXOMFORT_COMPILER_VERSION >= 1500)






    #undef  CXXO_COMPILER_SUPPORT_va_args
    #define CXXO_COMPILER_SUPPORT_va_args 1
    #undef  CXXO_COMPILER_SUPPORT_tr1_tuple 
    #define CXXO_COMPILER_SUPPORT_tr1_tuple 1
    #undef  CXXO_COMPILER_SUPPORT_tr1_type_traits
    #define CXXO_COMPILER_SUPPORT_tr1_type_traits 1
    
#endif

// At least VC2010
#if (CXXOMFORT_COMPILER_VERSION >= 1600) // VC10 or higher




    #undef  CXXOMFORT_CXX_EMULATION
    #define CXXOMFORT_CXX_EMULATION 2011
    #undef  CXXO_COMPILER_SUPPORT_cstd_system_error
    #define CXXO_COMPILER_SUPPORT_cstd_system_error 1
    #undef  CXXO_COMPILER_SUPPORT_auto
    #define CXXO_COMPILER_SUPPORT_auto 1984




    #undef  CXXO_COMPILER_SUPPORT_conditional_enableif
    #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
    #undef  CXXO_COMPILER_SUPPORT_decltype
    #define CXXO_COMPILER_SUPPORT_decltype 2343
    #undef  CXXO_COMPILER_SUPPORT_iterator_helpers
    #define CXXO_COMPILER_SUPPORT_iterator_helpers 0
    #undef  CXXO_COMPILER_SUPPORT_local_types
................................................................................
    #define CXXO_COMPILER_SUPPORT_std_iterator_helpers 1
    #undef  CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers
    #define CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers 1
    #undef  CXXO_COMPILER_SUPPORT_trailing_returns
    #define CXXO_COMPILER_SUPPORT_trailing_returns 1
    #undef  CXXO_COMPILER_SUPPORT_unique_ptr
    #define CXXO_COMPILER_SUPPORT_unique_ptr 1

    
#endif

// -- TODO -- get my claws on a MSVC 2012 / 2013 for actual testing
// At least VC2012
#if (CXXOMFORT_COMPILER_VERSION >= 1700) // VC12 or higher
    #undef  CXXO_COMPILER_SUPPORT_cstd_cstdint 
................................................................................
    #define CXXO_COMPILER_SUPPORT_rvref 3053
    #undef  CXXO_COMPILER_SUPPORT_user_defined_literals
    #define CXXO_COMPILER_SUPPORT_user_defined_literals 1
    #undef  CXXO_COMPILER_SUPPORT_variadic
    #define CXXO_COMPILER_SUPPORT_variadic 1

#endif







// -- END Microsoft C++ Compiler --
#endif







>







 







>












>
>
>
>
>
>











>
>
>
>






>
>
>
>







 







>







 







>
>
>
>
>




21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
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
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
 * http://msdn.microsoft.com/en-us/library/ms177194%28v=VS.100%29.aspx
 *
*/


#define CXXOMFORT_COMPILER_ID CXXO_COMPILERID_MSC
#define CXXOMFORT_COMPILER_VERSION (_MSC_VER)
#define CXXOMFORT_COMPILER_VERSION_FULL (_MSC_FULL_VER)
// eg.: 120 for VC6 (ugh!), 150 for VC9 (Studio / Express 2008)

#define CXXO_PRAGMA(x) _Pragma (#x)

#if defined(CXXOMFORT_NOTICES)

    #pragma message CXXO_NOTICE("Found the Microsoft C++ Compiler [" CXXO_STRINGIZE(_MSC_VER) "]" )
................................................................................
    #error "cxxomfort -- Detected an horribly broken compiler! (MSVC6 or earlier)"
#endif

/**
 * MSVC headers tend to be organized via a 
 * path like ${VISUAL_STUDIO}/VC/include
 */
#undef  CXXO_INCLUDE_SYS
#define CXXO_INCLUDE_SYS(NAME) <../../VC/include/NAME>
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_WARNING("Using Windows+MSC include paths")
#endif


// At least VC2005
#if (CXXOMFORT_COMPILER_VERSION > 1200)
#endif

// At least VC2008
#if (CXXOMFORT_COMPILER_VERSION >= 1500)
    #if (_MSC_FULL_VER == 150030729)
        #undef  CXXOMFORT_COMPILER_VERSION
        #define CXXOMFORT_COMPILER_VERSION 1501
    #endif
    #undef  CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x
    #define CXXO_COMPILER_SUPPORT_compiler_intrinsics_is_x 1
    #undef  CXXO_COMPILER_SUPPORT_va_args
    #define CXXO_COMPILER_SUPPORT_va_args 1
    #undef  CXXO_COMPILER_SUPPORT_tr1_tuple 
    #define CXXO_COMPILER_SUPPORT_tr1_tuple 1
    #undef  CXXO_COMPILER_SUPPORT_tr1_type_traits
    #define CXXO_COMPILER_SUPPORT_tr1_type_traits 1
    
#endif

// At least VC2010
#if (CXXOMFORT_COMPILER_VERSION >= 1600) // VC10 or higher
    #if (_MSC_FULL_VER == 160040219)
        #undef  CXXOMFORT_COMPILER_VERSION
        #define CXXOMFORT_COMPILER_VERSION 1601
    #endif
    #undef  CXXOMFORT_CXX_EMULATION
    #define CXXOMFORT_CXX_EMULATION 2011
    #undef  CXXO_COMPILER_SUPPORT_cstd_system_error
    #define CXXO_COMPILER_SUPPORT_cstd_system_error 1
    #undef  CXXO_COMPILER_SUPPORT_auto
    #define CXXO_COMPILER_SUPPORT_auto 1984
    #undef  CXXO_COMPILER_SUPPORT_charn_t
    #define CXXO_COMPILER_SUPPORT_charn_t 2 // char16_t as typedef in yvals.h
    #undef  CXXO_COMPILER_SUPPORT_charn_t_IS_TYPEDEF
    #define CXXO_COMPILER_SUPPORT_charn_t_IS_TYPEDEF 1
    #undef  CXXO_COMPILER_SUPPORT_conditional_enableif
    #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
    #undef  CXXO_COMPILER_SUPPORT_decltype
    #define CXXO_COMPILER_SUPPORT_decltype 2343
    #undef  CXXO_COMPILER_SUPPORT_iterator_helpers
    #define CXXO_COMPILER_SUPPORT_iterator_helpers 0
    #undef  CXXO_COMPILER_SUPPORT_local_types
................................................................................
    #define CXXO_COMPILER_SUPPORT_std_iterator_helpers 1
    #undef  CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers
    #define CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers 1
    #undef  CXXO_COMPILER_SUPPORT_trailing_returns
    #define CXXO_COMPILER_SUPPORT_trailing_returns 1
    #undef  CXXO_COMPILER_SUPPORT_unique_ptr
    #define CXXO_COMPILER_SUPPORT_unique_ptr 1

    
#endif

// -- TODO -- get my claws on a MSVC 2012 / 2013 for actual testing
// At least VC2012
#if (CXXOMFORT_COMPILER_VERSION >= 1700) // VC12 or higher
    #undef  CXXO_COMPILER_SUPPORT_cstd_cstdint 
................................................................................
    #define CXXO_COMPILER_SUPPORT_rvref 3053
    #undef  CXXO_COMPILER_SUPPORT_user_defined_literals
    #define CXXO_COMPILER_SUPPORT_user_defined_literals 1
    #undef  CXXO_COMPILER_SUPPORT_variadic
    #define CXXO_COMPILER_SUPPORT_variadic 1

#endif

#if (0 && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>= 1600) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, < 1700))
    #undef  CXXO_COMPILER_SUPPORT_cstd_system_error
    #define CXXO_COMPILER_SUPPORT_cstd_system_error 0
#endif // <system_error>


// -- END Microsoft C++ Compiler --
#endif

Changes to cxxomfort/cxxomfort/cstd/system_error.

2
3
4
5
6
7
8
9
10
11
12
13
14
#define CXXOMFORT_STD_SYSTEM_ERROR

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
    #include CXXO_INCLUDE_SYS(system_error)
#endif
#include "../system_error.hpp"
#endif








<
<
<



2
3
4
5
6
7
8



9
10
11
#define CXXOMFORT_STD_SYSTEM_ERROR

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"



#include "../system_error.hpp"
#endif

Added cxxomfort/cxxomfort/cuchar.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_CUCHAR_HPP
#define CXXOMFORT_CUCHAR_HPP
/**
 * @file
 *
 */

#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <cwchar>
// uchar is only available in some compilers
#if (CXXO_COMPILER_SUPPORT_cstd_cuchar)
#include <cuchar>
#else
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
        #include "impl/uchar.hpp"
    #else
        #include <uchar.h>
        #include "impl/uchar.hpp"
    #endif
#endif


#endif

Changes to cxxomfort/cxxomfort/cxxomfort.hpp.

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
//
// (pending minor reorganization as of v0.49)
#include "base.hpp"
//#include "using.hpp"
#include "algorithm.hpp" // <algorithm> backports (copy_if, minmax, etc...)
#include "cstddef.hpp" // <cstddef> backports (byte, nullptr, etc...)
#include "cstdint.hpp" // <cstdint> backports (integer types)

#include "forward_list.hpp" // <forward_list> backports
#include "functional.hpp" // <functional> backports (transparent functors, etc...)
#include "iterator.hpp" // <iterator> backports (begin, end, size, data, 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 "string.hpp" // <string> backports (to_string, 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 "utility.hpp" // <utility> backports (declval, exchange, pair, etc...)
#include "using.hpp" // namespaces in order

#include "library.hpp" // cxxomfort library supplements
#include "limits.hpp" // compile-time integral limits


#endif








>







>












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
//
// (pending minor reorganization as of v0.49)
#include "base.hpp"
//#include "using.hpp"
#include "algorithm.hpp" // <algorithm> backports (copy_if, minmax, etc...)
#include "cstddef.hpp" // <cstddef> backports (byte, nullptr, etc...)
#include "cstdint.hpp" // <cstdint> backports (integer types)
#include "cuchar.hpp" // <cuchar> backports, besides char16_t, char32_t
#include "forward_list.hpp" // <forward_list> backports
#include "functional.hpp" // <functional> backports (transparent functors, etc...)
#include "iterator.hpp" // <iterator> backports (begin, end, size, data, 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 "string.hpp" // <string> backports (to_string, etc...)
//#include "strinv_view.hpp" // <string_view> backports
#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 "utility.hpp" // <utility> backports (declval, exchange, pair, etc...)
#include "using.hpp" // namespaces in order

#include "library.hpp" // cxxomfort library supplements
#include "limits.hpp" // compile-time integral limits


#endif

Changes to cxxomfort/cxxomfort/functional.hpp.

40
41
42
43
44
45
46
47



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

#include "./impl/14-functional-transparent.hpp"

//#include "./impl/17-notfn.hpp"

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




#endif








>
>
>

40
41
42
43
44
45
46
47
48
49
50
51
#include "./impl/03-functional_bit.hpp"

#include "./impl/14-functional-transparent.hpp"

//#include "./impl/17-notfn.hpp"

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

// extra power for std::hash
#include "./impl/hash.hpp"

#endif

Added cxxomfort/cxxomfort/impl/11-basic_string_charn.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
#ifndef CXXOMFORT_IMPL_BASIC_STRING_CHARn_HPP
#define CXXOMFORT_IMPL_BASIC_STRING_CHARn_HPP
/**
 * @file
 * @brief Implementation of basic_string for char16_t, char32_t in C++03
 *
 */

#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)
namespace std {
    typedef basic_string<uint16_t> u16string;
    typedef basic_string<uint32_t> u32string;
}

#else
// this is a specialization, so it goes in std::
namespace std {

template<>
class basic_string<char16_t> : public basic_string<uint16_t> {
    // c++03 has no inheriting constructors
    typedef basic_string<uint16_t> base_t;
    public:
    basic_string () : base_t() {}
    basic_string (basic_string const& s) : base_t(s) {}
    basic_string (size_t n, char16_t c) : base_t(n,static_cast<uint16_t>(c)) {}
    explicit basic_string (char16_t const * p) : base_t(reinterpret_cast<uint16_t const*>(p)) {}
};

template<>
class basic_string<char32_t> : public basic_string<uint32_t> {
    // c++03 has no inheriting constructors
    typedef basic_string<uint32_t> base_t;
    public:
    basic_string () : base_t() {}
    basic_string (basic_string const& s) : base_t(s) {}
    basic_string (size_t n, char32_t c) : base_t(n,static_cast<uint32_t>(c)) {}
    explicit basic_string (char32_t const * p) : base_t(reinterpret_cast<uint32_t const*>(p)) {}
};

typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;

}
#endif


#endif // c++<2011

#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
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP
#define CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP

/**
 * @file
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/library/utility.hpp> // integral_of_size
#include <cxxomfort/type_traits.hpp> // make_signed


#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)
................................................................................
     * @brief Given an enumeration type, provides the integral type serving as its storage.
     * @ingroup cxx11-backports
     * @xrefitem std0typetraits "<type_traits>" ""
     * @anchor underlying_type
     * */
    template< typename TpEnum >
    struct underlying_type {
        typedef typename ::cxxomfort::library::utility::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;







|
|
|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#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/impl/zzzvarious.hpp> // integral_of_size
//#include <cxxomfort/type_traits.hpp> // make_signed


#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)
................................................................................
     * @brief Given an enumeration type, provides the integral type serving as its storage.
     * @ingroup cxx11-backports
     * @xrefitem std0typetraits "<type_traits>" ""
     * @anchor underlying_type
     * */
    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;

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

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
#define CXXOMFORT_IMPLEMENTS_n3584 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n3670 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_tuple_get_type CXXOMFORT_IMPLEMENTS_n3584


#include <type_traits>
#include <tuple>
#include <cxxomfort/library/tuple.hpp> // is_tuple, tuple_index

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled tuple get<type> implementation")
    #endif
#endif

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

// This probably has to go in namespace std
// because otherwise we can get a "already using" error instead of an overload

namespace std {

namespace {
    using cxxomfort::library::tuple::is_tuple;
    using cxxomfort::library::tuple::tuple_index;
} // anonymous was here

#if (CXXOMFORT_CXX_STD >= 2014 || CXXOMFORT_CXX_EMULATION == 2014)
    // already available, do nothing
#elif (CXXOMFORT_CXX_STD == 2011 || (CXXO_COMPILER_SUPPORT_variadic && CXXO_COMPILER_SUPPORT_rvref) )









|







 







|
|







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
#define CXXOMFORT_IMPLEMENTS_n3584 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n3670 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_tuple_get_type CXXOMFORT_IMPLEMENTS_n3584


#include <type_traits>
#include <tuple>
#include <cxxomfort/impl/tuplemeta.hpp> // is_tuple, tuple_index

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled tuple get<type> implementation")
    #endif
#endif

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

// This probably has to go in namespace std
// because otherwise we can get a "already using" error instead of an overload

namespace std {

namespace {
    using cxxomfort::impl::is_tuple;
    using cxxomfort::impl::tuple_index;
} // anonymous was here

#if (CXXOMFORT_CXX_STD >= 2014 || CXXOMFORT_CXX_EMULATION == 2014)
    // already available, do nothing
#elif (CXXOMFORT_CXX_STD == 2011 || (CXXO_COMPILER_SUPPORT_variadic && CXXO_COMPILER_SUPPORT_rvref) )


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

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        
    #else
        #define CXXOMFORT_IMPLEMENTS_p0298r2 CXXO_IMPLSTATUS_EMULATION()
        #define CXXOMFORT_IMPLEMENTS_p0298r3 CXXOMFORT_IMPLEMENTS_p0298r2
        #define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3
        // these three go here to ensure that we call namespace std outside
        }}
        #include "../library/typesafe_enum.hpp"
        namespace cxxomfort { namespace cxxostd {

namespace detail { // detail

struct mybyte_def { enum type {};  };
typedef cxxomfort::library::typesafe_enum<mybyte_def,unsigned char> byteimpl;
// quick and easy encapsulation

}

struct byte
: public detail::byteimpl  {
    private:







|





|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        
    #else
        #define CXXOMFORT_IMPLEMENTS_p0298r2 CXXO_IMPLSTATUS_EMULATION()
        #define CXXOMFORT_IMPLEMENTS_p0298r3 CXXOMFORT_IMPLEMENTS_p0298r2
        #define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3
        // these three go here to ensure that we call namespace std outside
        }}
        #include "./typesafe_enum-core.hpp"
        namespace cxxomfort { namespace cxxostd {

namespace detail { // detail

struct mybyte_def { enum type {};  };
typedef cxxomfort::impl::typesafe_enum<mybyte_def,unsigned char> byteimpl;
// quick and easy encapsulation

}

struct byte
: public detail::byteimpl  {
    private:

Added cxxomfort/cxxomfort/impl/17-string_view.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
#ifndef CXXOMFORT_IMPL_STRING_VIEW_HPP
#define CXXOMFORT_IMPL_STRING_VIEW_HPP
/**
 * @file
 * @brief Implementation for std::string_view and allies
 *
 */

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

namespace cxxomfort { namespace cxxostd {

/**
 * @brief View of a string or string-like object
 * */
template <typename CharT, typename CTraits = std::char_traits<CharT>
> class basic_string_view 
: protected cxxomfort::impl::array_ref::array_ref<CharT const> {
    private:
    typedef cxxomfort::impl::array_ref::array_ref<CharT const> membertype;
    public:
    // using membertype::value_type;
    typedef typename membertype::value_type      value_type;
    typedef typename membertype::size_type          size_type;
    typedef typename membertype::difference_type    difference_type;
    typedef typename membertype::pointer            pointer;
    typedef typename membertype::const_pointer   const_pointer;
    typedef typename membertype::reference          reference;
    typedef typename membertype::const_reference    const_reference;
    typedef typename membertype::const_iterator     const_iterator;
    static const size_type npos= size_type(-1);

    
    public:
    // def-ctor
    CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(basic_string_view);
    CXXO_CONSTEXPR CXXO_DEFAULT_COPY_CONSTRUCTOR(basic_string_view,CXXO_NOTHROW,
    membertype(v) );
    
    CXXO_CONSTEXPR basic_string_view (pointer px, size_t sz) CXXO_NOEXCEPTNOTHROW
    : membertype(px,sz)
    {}
    
    CXXO_CONSTEXPR basic_string_view (pointer px) CXXO_NOEXCEPTNOTHROW 
    : membertype(px, CTraits::length(px) )
    {}

    template<size_t N>
    CXXO_CONSTEXPR basic_string_view (CharT const(&arr)[N])
    : membertype(arr,N)
    {}

    using membertype::max_size;
    using membertype::size;
    using membertype::empty;
    using membertype::data;
    CXXO_CONSTEXPR 
    size_type  length () const CXXO_NOEXCEPTNOTHROW { return this->size(); }
    
    using membertype::begin;
    using membertype::end;
    
    using membertype::operator[];
    reference       at (size_type idx) { return this->at(idx); }
    const_reference at (size_type idx) const { return this->at(idx); }
    
    using membertype::front;
    using membertype::back;
    
    size_type  copy (CharT* d, size_type count, size_type pos=0) const;
    basic_string_view    substr (size_type pos, size_type count = npos) const;
    
    int        compare (basic_string_view r) const CXXO_NOEXCEPTNOTHROW;
    int        compare (pointer r) const CXXO_NOEXCEPTNOTHROW;
    
    CXXO_CONSTEXPR  
    size_type  find (basic_string_view, size_type pos=0) const CXXO_NOEXCEPTNOTHROW;
    CXXO_CONSTEXPR
    size_type  find (CharT, size_type pos= 0) const CXXO_NOEXCEPTNOTHROW;
    CXXO_CONSTEXPR
    size_type  find (const_pointer s, size_type pos= 0) const CXXO_NOEXCEPTNOTHROW {
        return find(basic_string_view(s), pos);
    }
    CXXO_CONSTEXPR
    size_type  find (const_pointer s, size_type pos, size_type count) const CXXO_NOEXCEPTNOTHROW {
        return find(basic_string_view(s,count), pos);
    }

    
};

// Copies the substring [pos, pos + rcount) to the character string pointed to by dest, 
// where rcount is the smaller of count and size() - pos
template <typename Ch, typename ChT>
typename basic_string_view<Ch,ChT>::size_type basic_string_view<Ch,ChT>::copy 
(Ch* dest, size_type count, size_type pos) const {
    using namespace std;
    size_t rcount = min(count, size()-pos);
    Ch* d= copy(data()+pos, data()+pos+rcount, dest);
    return d-dest;
}


template <typename Ch, typename ChT>
basic_string_view<Ch,ChT> basic_string_view<Ch,ChT>::substr 
(size_type pos, size_type count) const {
    using namespace std;
    // rcount is the smaller of count and size() - pos. 
    size_type rcount = min(count, size()-pos);
    return basic_string_view(data()+pos,rcount);
}

template <typename Ch, typename ChT>
CXXO_CONSTEXPR
typename basic_string_view<Ch,ChT>::size_type basic_string_view<Ch,ChT>::find 
(basic_string_view<Ch,ChT> s, size_type pos) const CXXO_NOEXCEPTNOTHROW {
    if (pos >= this->length()) return npos;
    using namespace std;
    const_iterator st = this->begin()+pos;
    const_iterator loc = search(
        st, this->end(), s.begin(), s.end());
    if (loc==this->end()) return npos;
    else return static_cast<size_type>(loc - this->begin());
}


template <typename Ch, typename ChT>
CXXO_CONSTEXPR
typename basic_string_view<Ch,ChT>::size_type basic_string_view<Ch,ChT>::find 
(Ch c, size_type pos) const CXXO_NOEXCEPTNOTHROW {
    using namespace std;
    if (pos >= this->length()) return npos;
    const_iterator pf = std::find(this->begin()+pos, this->end(), c);
    if (pf == this->end()) return npos;
    else return pf - this->begin();
}

//CXXO_GENERATE_RELATIONALS_T(basic_string_view,CharT,Traits);

typedef basic_string_view<char> string_view;
typedef basic_string_view<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


template <class Ch, class ChTraits>
std::basic_ostream<Ch, ChTraits>&
operator<<  (std::basic_ostream<Ch, ChTraits>& os, basic_string_view<Ch, ChTraits> 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;
}

               
               
} }

#endif

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

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#if (CXXOMFORT_CXX_STD>=2011)
enum class endian { CXXO_endian_members() };
#else
namespace {
    struct def { enum type { CXXO_endian_members() }; };
}
typedef cxxomfort::library::typesafe_enum_simple<def,unsigned> endian;

#endif
#undef CXXO_endian_members

}} // cxxomfort::std

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







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#if (CXXOMFORT_CXX_STD>=2011)
enum class endian { CXXO_endian_members() };
#else
namespace {
    struct def { enum type { CXXO_endian_members() }; };
}
typedef ::cxxomfort::impl::typesafe_enum<def,unsigned> endian;

#endif
#undef CXXO_endian_members

}} // cxxomfort::std

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

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

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

#include <cxxomfort/config.hpp>
#include <cxxomfort/library/typesafe_enum.hpp>

// https://en.cppreference.com/w/cpp/types/type_identity

namespace cxxomfort {
namespace cxxostd {

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




<







1
2
3
4

5
6
7
8
9
10
11
#ifndef CXXOMFORT_IMPL_20_IDENTITY_FINALLY_HPP
#define CXXOMFORT_IMPL_20_IDENTITY_FINALLY_HPP

#include <cxxomfort/config.hpp>


// https://en.cppreference.com/w/cpp/types/type_identity

namespace cxxomfort {
namespace cxxostd {

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

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

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

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

namespace cxxomfort{ namespace library{ namespace type_traits {

template <typename T> struct is_character_type: std::false_type {};
template <> struct is_character_type<char> : std::true_type {};
template <> struct is_character_type<signed char> : std::true_type {};
template <> struct is_character_type<unsigned char> : std::true_type {};
template <> struct is_character_type<wchar_t> : std::true_type {};








|







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

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

namespace cxxomfort{ namespace impl{ namespace type_traits {

template <typename T> struct is_character_type: std::false_type {};
template <> struct is_character_type<char> : std::true_type {};
template <> struct is_character_type<signed char> : std::true_type {};
template <> struct is_character_type<unsigned char> : std::true_type {};
template <> struct is_character_type<wchar_t> : std::true_type {};

Changes to cxxomfort/cxxomfort/impl/errc-win.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
address_family_not_supported =EAFNOSUPPORT,
address_in_use =EADDRINUSE,
address_not_available =EADDRNOTAVAIL,
already_connected =EISCONN,
argument_list_too_long =E2BIG,
argument_out_of_domain =EDOM,
bad_address =EFAULT,
bad_file_descriptor =EBADF,
bad_message =EBADMSG,
broken_pipe =EPIPE,
connection_aborted =ECONNABORTED,
connection_already_in_progress =EALREADY,
connection_refused =ECONNREFUSED,
connection_reset =ECONNRESET,
cross_device_link =EXDEV,
destination_address_required =EDESTADDRREQ,
device_or_resource_busy =EBUSY,
directory_not_empty =ENOTEMPTY,
executable_format_error =ENOEXEC,
file_exists =EEXIST,
file_too_large =EFBIG,
filename_too_long =ENAMETOOLONG,
function_not_supported =ENOSYS,
host_unreachable =EHOSTUNREACH,
identifier_removed =EIDRM,
illegal_byte_sequence =EILSEQ,
inappropriate_io_control_operation =ENOTTY,
interrupted =EINTR,
invalid_argument =EINVAL,
invalid_seek =ESPIPE,
io_error =EIO,
is_a_directory =EISDIR,
message_size =EMSGSIZE,
network_down =ENETDOWN,
network_reset =ENETRESET,
network_unreachable =ENETUNREACH,
no_buffer_space =ENOBUFS,
no_child_process =ECHILD,
no_link =ENOLINK,
no_lock_available =ENOLCK,
no_message_available =ENODATA,
no_message =ENOMSG,
no_protocol_option =ENOPROTOOPT,
no_space_on_device =ENOSPC,
no_stream_resources =ENOSR,
no_such_device_or_address =ENXIO,
no_such_device =ENODEV,
no_such_file_or_directory =ENOENT,
no_such_process =ESRCH,
not_a_directory =ENOTDIR,
not_a_socket =ENOTSOCK,
not_a_stream =ENOSTR,
not_connected =ENOTCONN,
not_enough_memory =ENOMEM,
not_supported =ENOTSUP,
operation_canceled =ECANCELED,
operation_in_progress =EINPROGRESS,
operation_not_permitted =EPERM,
operation_not_supported =EOPNOTSUPP,
operation_would_block =EWOULDBLOCK,
owner_dead =EOWNERDEAD,
permission_denied =EACCES,
protocol_error =EPROTO,
protocol_not_supported =EPROTONOSUPPORT,
read_only_file_system =EROFS,
resource_deadlock_would_occur =EDEADLK,
resource_unavailable_try_again =EAGAIN,
result_out_of_range =ERANGE,
state_not_recoverable =ENOTRECOVERABLE,
stream_timeout =ETIME,
text_file_busy =ETXTBSY,
timed_out =ETIMEDOUT,
too_many_files_open_in_system =ENFILE,
too_many_files_open =EMFILE,
too_many_links =EMLINK,
too_many_symbolic_link_levels =ELOOP,
value_too_large =EOVERFLOW,
wrong_protocol_type =EPROTOTYPE 

Added cxxomfort/cxxomfort/impl/errno-msvc.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
#include <errno.h>

#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, <= 1600))
    // mostly copied from the ones in VC2010's errno.h

#define EADDRINUSE      100
#define EADDRNOTAVAIL   101
#define EAFNOSUPPORT    102
#define EALREADY        103
#define EBADMSG         104
#define ECANCELED       105
#define ECONNABORTED    106
#define ECONNREFUSED    107
#define ECONNRESET      108
#define EDESTADDRREQ    109
#define EHOSTUNREACH    110
#define EIDRM           111
#define EINPROGRESS     112
#define EISCONN         113
#define ELOOP           114
#define EMSGSIZE        115
#define ENETDOWN        116
#define ENETRESET       117
#define ENETUNREACH     118
#define ENOBUFS         119
#define ENODATA         120
#define ENOLINK         121
#define ENOMSG          122
#define ENOPROTOOPT     123
#define ENOSR           124
#define ENOSTR          125
#define ENOTCONN        126
#define ENOTRECOVERABLE 127
#define ENOTSOCK        128
#define ENOTSUP         129
#define EOPNOTSUPP      130
#define EOTHER          131
#define EOVERFLOW       132
#define EOWNERDEAD      133
#define EPROTO          134
#define EPROTONOSUPPORT 135
#define EPROTOTYPE      136
#define ETIME           137
#define ETIMEDOUT       138
#define ETXTBSY         139
#define EWOULDBLOCK     140

    
#endif

Changes to cxxomfort/cxxomfort/impl/foreach_artima.hpp.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
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
//#include <functional>
#include <cxxomfort/base.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/meta.hpp>
#include <valarray>

namespace cxxomfort {
namespace library {
namespace detail {

///////////////////////////////////////////////////////////////////////////////
// auto_any

struct auto_any_base {
    operator bool() const { return false; }
................................................................................
    }
};

// convert an expression of type T to an
// expression of type type2type<T> without
// evaluating the expression
#define ENCODED_TYPEOF( container ) \
  ( true ? ::cxxomfort::library::detail::any_type() : ::cxxomfort::library::detail::encode_type( container ) )


///////////////////////////////////////////////////////////////////////////////
// FOREACH helper function

template <typename T>
struct type2iterator {
................................................................................


#if defined(_MSC_VER)
// use a modified version with pragmas to suppress
// "assignment within conditional" warnings
#define CXXO_FOREACH(item, container)                  \
__pragma(warning(suppress:4706)) __pragma(warning(suppress:6001)) \
if(::cxxomfort::library::detail::auto_any_base const& bX = ::cxxomfort::library::detail::begin(container)) {} else   \
if(::cxxomfort::library::detail::auto_any_base const& eX = ::cxxomfort::library::detail::end(container)) {} else     \
for(bool more = true;                                   \
    more && !::cxxomfort::library::detail::done(bX,eX,ENCODED_TYPEOF(container));                       \
    more ? ::cxxomfort::library::detail::next(bX,ENCODED_TYPEOF(container)) : (void)0)                 \
    __pragma(warning(suppress:4706))                       \
    if ((more = false)!=0) {} else                           \
    for(item = ::cxxomfort::library::detail::deref(bX,ENCODED_TYPEOF(container)); !more; more = true)

#else
// all other compilers
#define CXXO_FOREACH(item, container)                  \
if(::cxxomfort::library::detail::auto_any_base const& bX = ::cxxomfort::library::detail::begin(container)) {} else   \
if(::cxxomfort::library::detail::auto_any_base const& eX = ::cxxomfort::library::detail::end(container)) {} else     \
for(bool more = true;                                   \
    more && !::cxxomfort::library::detail::done(bX,eX,ENCODED_TYPEOF(container));                       \
    more ? ::cxxomfort::library::detail::next(bX,ENCODED_TYPEOF(container)) : (void)0)                 \
    if ((more = false)!=0) {} else                           \
    for(item = ::cxxomfort::library::detail::deref(bX,ENCODED_TYPEOF(container)); !more; more = true)

#endif // foreach macro definition





#undef Suppress_








|







 







|







 







|
|

|
|


|




|
|

|
|

|



>
>
>
>


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
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
//#include <functional>
#include <cxxomfort/base.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/meta.hpp>
#include <valarray>

namespace cxxomfort {
namespace impl {
namespace detail {

///////////////////////////////////////////////////////////////////////////////
// auto_any

struct auto_any_base {
    operator bool() const { return false; }
................................................................................
    }
};

// convert an expression of type T to an
// expression of type type2type<T> without
// evaluating the expression
#define ENCODED_TYPEOF( container ) \
  ( true ? ::cxxomfort::impl::detail::any_type() : ::cxxomfort::impl::detail::encode_type( container ) )


///////////////////////////////////////////////////////////////////////////////
// FOREACH helper function

template <typename T>
struct type2iterator {
................................................................................


#if defined(_MSC_VER)
// use a modified version with pragmas to suppress
// "assignment within conditional" warnings
#define CXXO_FOREACH(item, container)                  \
__pragma(warning(suppress:4706)) __pragma(warning(suppress:6001)) \
if(::cxxomfort::impl::detail::auto_any_base const& bX = ::cxxomfort::impl::detail::begin(container)) {} else   \
if(::cxxomfort::impl::detail::auto_any_base const& eX = ::cxxomfort::impl::detail::end(container)) {} else     \
for(bool more = true;                                   \
    more && !::cxxomfort::impl::detail::done(bX,eX,ENCODED_TYPEOF(container));                       \
    more ? ::cxxomfort::impl::detail::next(bX,ENCODED_TYPEOF(container)) : (void)0)                 \
    __pragma(warning(suppress:4706))                       \
    if ((more = false)!=0) {} else                           \
    for(item = ::cxxomfort::impl::detail::deref(bX,ENCODED_TYPEOF(container)); !more; more = true)

#else
// all other compilers
#define CXXO_FOREACH(item, container)                  \
if(::cxxomfort::impl::detail::auto_any_base const& bX = ::cxxomfort::impl::detail::begin(container)) {} else   \
if(::cxxomfort::impl::detail::auto_any_base const& eX = ::cxxomfort::impl::detail::end(container)) {} else     \
for(bool more = true;                                   \
    more && !::cxxomfort::impl::detail::done(bX,eX,ENCODED_TYPEOF(container));                       \
    more ? ::cxxomfort::impl::detail::next(bX,ENCODED_TYPEOF(container)) : (void)0)                 \
    if ((more = false)!=0) {} else                           \
    for(item = ::cxxomfort::impl::detail::deref(bX,ENCODED_TYPEOF(container)); !more; more = true)

#endif // foreach macro definition


#define CXXO_FOREACH_AUTO(item, container)     \
void f_foreach_no_typeof_deduction (void* item) 

#undef Suppress_

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

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74







75
76

77
#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 library {

template <typename T> struct impl_is_array { enum { value = false }; };

template <typename T, size_t N> struct impl_is_array<T[N]> { enum { value = true }; };

struct seq2iter_base {
    operator bool () const { return false; }
................................................................................
    : _i(i) {}
    
};

// for compilers that support __typeof__

#define CXXO_FOREACH(item,container)    \
if (::cxxomfort::library::seq2iter< __typeof__(container) > const& bX = ::std::begin(container)) {} else \
if (::cxxomfort::library::seq2iter< __typeof__(container) > const& eX = ::std::end(container))   {} else \
for (bool more=true; more && (bX._i != eX._i)                                     \
    ; more ? (void)++bX._i : (void)0 )                                               \
    if ((more=false)!=0) {} else                                            \
    for( item = *bX._i; !more; more=true)









}
}









|







 







|
|






>
>
>
>
>
>
>
|
|
>

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
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
#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 {

template <typename T> struct impl_is_array { enum { value = false }; };

template <typename T, size_t N> struct impl_is_array<T[N]> { enum { value = true }; };

struct seq2iter_base {
    operator bool () const { return false; }
................................................................................
    : _i(i) {}
    
};

// for compilers that support __typeof__

#define CXXO_FOREACH(item,container)    \
if (::cxxomfort::impl::seq2iter< __typeof__(container) > const& bX = ::std::begin(container)) {} else \
if (::cxxomfort::impl::seq2iter< __typeof__(container) > const& eX = ::std::end(container))   {} else \
for (bool more=true; more && (bX._i != eX._i)                                     \
    ; more ? (void)++bX._i : (void)0 )                                               \
    if ((more=false)!=0) {} else                                            \
    for( item = *bX._i; !more; more=true)


#define CXXO_FOREACH_AUTO(name,container)    \
if (::cxxomfort::impl::seq2iter< __typeof__(container) > const& bX = ::std::begin(container)) {} else \
if (::cxxomfort::impl::seq2iter< __typeof__(container) > const& eX = ::std::end(container))   {} else \
for (bool more=true; more && (bX._i != eX._i)                                     \
    ; more ? (void)++bX._i : (void)0 )                                               \
    if ((more=false)!=0) {} else                                            \
    for( __typeof__(*bX._i) name = *bX._i; !more; more=true)


}} // cxxomfort::impl

Added cxxomfort/cxxomfort/impl/functionmeta.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
#ifndef CXXOMFORT_IMPL_FUNCTIONMETA_HPP
#define CXXOMFORT_IMPL_FUNCTIONMETA_HPP

namespace cxxomfort { namespace impl {

template <typename T> struct functiontype {};

template <typename Ret>
struct functiontype<Ret()> {
    typedef Ret (*pointer)();
};

#if (CXXOMFORT_CXX_STD >= 2011)
template <typename Ret, typename... Args>
struct functiontype<Ret(Args...)> {
    typedef Ret (*pointer)(Args...);
    typedef Ret (type)(Args...);
    typedef std::tuple<Args...> arguments;
    typedef Ret return_type;
};

#else

template <typename Ret, typename A1>
struct functiontype<Ret(A1)> {
    typedef Ret (*pointer)(A1);
    typedef Ret (type)(A1);
    typedef std::tuple<A1> arguments;
    typedef Ret return_type;
};
template <typename Ret, typename A1, typename A2>
struct functiontype<Ret(A1,A2)> {
    typedef Ret (*pointer)(A1,A2);
    typedef Ret (type)(A1,A2);
    typedef std::tuple<A1,A2> arguments;
    typedef Ret return_type;
};
template <typename Ret, typename A1, typename A2, typename A3>
struct functiontype<Ret(A1,A2,A3)> {
    typedef Ret (*pointer)(A1,A2,A3);
    typedef Ret (type)(A1,A2,A3);
    typedef std::tuple<A1,A2,A3> arguments;
    typedef Ret return_type;
};
template <typename Ret, typename A1, typename A2, typename A3, typename A4>
struct functiontype<Ret(A1,A2,A3,A4)> {
    typedef Ret (*pointer)(A1,A2,A3,A4);
    typedef Ret (type)(A1,A2,A3,A4);
    typedef Ret return_type;
};
template <typename Ret, typename A1, typename A2, typename A3, typename A4, typename A5>
struct functiontype<Ret(A1,A2,A3,A4,A5)> {
    typedef Ret (*pointer)(A1,A2,A3,A4,A5);
    typedef Ret (type)(A1,A2,A3,A4,A5);
    typedef Ret return_type;
};
#endif

template <size_t, typename Function>
struct fn_arg_t {};

template <typename R, typename A1>
struct fn_arg_t<0, R(A1)> {
    typedef A1 type;
};

template <typename R, typename A1, typename A2>
struct fn_arg_t<0, R(A1,A2)> {
    typedef A1 type;
};


} }

#endif

Added cxxomfort/cxxomfort/impl/hash.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
#ifndef CXXOMFORT_IMPL_HASH_HPP
#define CXXOMFORT_IMPL_HASH_HPP

#include CXXO_INCLUDE_SYS(functional)
#include <cxxomfort/functional.hpp>
#include <cxxomfort/util/type_traits.hpp> // is_enum

namespace cxxomfort {  namespace cxxostd {

/*
 *  A version of std::hash that allows for better specialization. 
 * When not specialized, it just delegates to std::hash.
 */
template <typename T, typename = void >
struct hash
: public ::std::hash<T> {
    enum { uses_std = true };
};

// specialize for enum
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

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

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
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
...
196
197
198
199
200
201
202

203
204
205
206

207
208
209
210
211
212
213
...
241
242
243
244
245
246
247

248
249
250
251
252
253
254
 *  
**/

#include <cxxomfort/base.hpp>
#include <iterator>
#include <stdexcept>
#include <array> // maybe do away with this

#include <cxxomfort/impl/metaprogramming.hpp>
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/system_error.hpp> // see way to get rid of this

#define CXXOMFORT_IMPLEMENTS_n3334 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_array_ref CXXOMFORT_IMPLEMENTS_n3334

................................................................................
 * an area of memory directly, iterators are raw pointer types.
 * 
 * This implementation is intended to be used for sequences of 
 * const elements (ie.: template argument is <code>T const</code>).
 * 
 * The utility function make_array_ref() helps create 
 * array_refs from contexts where they can be needed.
 * 

 * See also: <code>std::vector</code>, @c seq_ .











 * 
 * @c array_ref is based in the original publication "n3334" by 
 * Jeffrey Yasskin; @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html 
 * 
 */
template <typename T>
class array_ref {
    public:
    //! type of the data contained in the view.
    typedef T       value_type;
    typedef typename ct::compose<T,::std::add_pointer>::type   pointer;
    typedef typename ct::compose<T,::std::add_const, ::std::add_pointer>::type const_pointer;
    typedef typename ct::compose<T,std::add_reference>::type   reference;
    typedef typename ct::compose<T,std::add_const,std::add_reference>::type const_reference;
    typedef ptrdiff_t    difference_type;
    typedef size_t       size_type;
    typedef pointer           iterator;
    typedef const_pointer const_iterator;

    typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
    
    public:
    
    CXXO_CONSTEXPR array_ref () CXXO_NOEXCEPTNOTHROW 
    #if (CXXOMFORT_CXX_STD<2011)
    : ptr_(nullptr), len_(0) {}

    #else
    = default;
    #endif
    
    CXXO_CONSTEXPR array_ref (array_ref const& p) CXXO_NOEXCEPTNOTHROW 


    #if (CXXOMFORT_CXX_STD<2011)
    : ptr_(p.ptr_), len_(p.len_) {}
    #else
    = default;
    #endif
    
    ///! Initializes this to refer to a buffer of memory pointed by @a p and of size @a l .

    CXXO_CONSTEXPR array_ref (pointer p, size_t l) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(l) {}
    

    CXXO_CONSTEXPR array_ref (std::nullptr_t, T const* p, T const* q) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(static_cast<size_t>(q-p)) {}

    ///! Initialize this to refer to a C-style array.
    template <size_t N>

    explicit array_ref (T(&arr)[N]) CXXO_NOEXCEPTNOTHROW : ptr_(arr), len_(N) {}

    
    

    // view from related non-const view, only for const view, for C++11-onwards
#if (CXXOMFORT_CXX_STD >= 2011)
    template <bool B = std::is_const<T>::value, typename std::enable_if<B,int>::type=0 >
    array_ref (array_ref< typename std::remove_const<T>::type > const& av)
    : ptr_(av.ptr_), len_(av.len_) {}
#endif

    // view ref from array<>; should be a std::array conversion operator but can't in C++03, C++11
    template <size_t N>

    array_ref (std::array<T,N> const& arr) CXXO_NOEXCEPTNOTHROW
    : ptr_(arr.data()), len_(arr.size()) {}


    // an array_ref should be constructible from any object that is a sequence_type 
    // that looks contiguous
    
    
    // access to elements

    // nonconst should only be enabled if T is nonconst
    reference       at (size_t i) { check_range(i); return ptr_[i]; }
    //! Checked access to i-th element; throws if the index is out of range.
    const_reference at (size_t i) const { check_range(i); return ptr_[i]; }
    //! Checked access to i-th element; sets up an @c error_code if the index is out of range.
    const_reference at (size_t i, std::error_code& ec) const { check_range(i,ec); return ptr_[i]; }
    //! Unchecked(!) access to the i-th element.
    reference       operator[] (size_t i) CXXO_NOEXCEPT { return ptr_[i]; }
    //! Unchecked(!) access to the i-th element.

    const_reference operator[] (size_t i) const CXXO_NOEXCEPT { return ptr_[i]; }
    
    // view info


    //! @return size of the view as a @c size_t .
    size_t          size () const CXXO_NOEXCEPTNOTHROW { return len_; }
    //! @return @c bool .
    bool            empty () const CXXO_NOEXCEPTNOTHROW { return size() == 0; }
    //! @return pointer to the view's data.
    pointer         data () CXXO_NOEXCEPTNOTHROW { return ptr_; }
    //! @return pointer to the view's data.

    const_pointer   data () const CXXO_NOEXCEPTNOTHROW { return ptr_; }
    
    // iterators

    const_iterator  cbegin () const CXXO_NOEXCEPTNOTHROW { return ptr_; }

    const_iterator  cend () const CXXO_NOEXCEPTNOTHROW { return ptr_+len_; }
    iterator        begin () CXXO_NOEXCEPTNOTHROW { return ptr_; }
    iterator        end () CXXO_NOEXCEPTNOTHROW { return ptr_+len_; }
    const_iterator  begin () const CXXO_NOEXCEPTNOTHROW { return cbegin(); }
    const_iterator  end () const CXXO_NOEXCEPTNOTHROW { return cend(); }

    const_reverse_iterator    crbegin () const CXXO_NOEXCEPTNOTHROW { return const_reverse_iterator(ptr_+len_); }
    const_reverse_iterator    crend () const CXXO_NOEXCEPTNOTHROW { return const_reverse_iterator(ptr_); }
    const_reverse_iterator    rbegin () const CXXO_NOEXCEPTNOTHROW { return crbegin(); }
    const_reverse_iterator    rend () const CXXO_NOEXCEPTNOTHROW { return crend(); }

    const_iterator  front () const { return ptr_[0]; }
    const_iterator  back () const { return ptr_[len_-1]; }
    











    array_ref       slice (size_t skip) const {
        return (skip > len_) ? array_ref() : array_ref(ptr_+skip, len_-skip);
    }
    array_ref       slice (size_t skip, size_t n) const {
        return slice(skip);



    }
    










    private:
    void check_range (size_t i) const {
        if (i>=len_) throw std::out_of_range("array_ref: out of range");
    }
    void check_range (size_t i, std::error_code& ec) const {
        if (i>=len_) ec= std::make_error_code(EDOM, std::generic_category());

    }


    





















    pointer const   ptr_;
    size_t const    len_;




















}; // array_ref





///! Makes an @c array_ref view from a C-style array.
template <typename Ty, size_t N>
array_ref<Ty> make_array_ref(Ty(&arr)[N]) {
    return array_ref<Ty>(arr);
}

................................................................................
///! @overload make_array_ref
template <typename Ty, size_t N>
array_ref<Ty const> make_array_ref(std::array<Ty,N> const& a) {
    return array_ref<Ty const>(a);
}



template <typename Ty>
array_ref<Ty> make_array_ref(std::vector<Ty> const& v) {
    return array_ref<Ty>(v);
}


template <typename Ty>
array_ref<Ty> make_array_ref(std::valarray<Ty> const& v) {
    return array_ref<Ty>(v);
}


................................................................................
template <typename T> struct is_array_ref
: std::false_type {};

template <typename T> struct is_array_ref< array_ref<T> >
: std::true_type {};

} } } // cxxomfort::impl::array_ref



/*
 * @page cxxo:array_ref "Array view for sequences, from n3334"
 * @ingroup cxxo:library
 * 
 * Interfaces defined:







>







 








>

>
>
>
>
>
>
>
>
>
>
>












|
|




>



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


>
|


>
|

>


>
|
>

<
<









>



<
<
<
<










|

>
|


>
>

|

|



>



>

>













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


>
>
>
>
>
>
>
>
>
>




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







 







>




>







 







>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
...
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
 *  
**/

#include <cxxomfort/base.hpp>
#include <iterator>
#include <stdexcept>
#include <array> // maybe do away with this
#include <valarray> // maybe do away with this
#include <cxxomfort/impl/metaprogramming.hpp>
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/system_error.hpp> // see way to get rid of this

#define CXXOMFORT_IMPLEMENTS_n3334 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_array_ref CXXOMFORT_IMPLEMENTS_n3334

................................................................................
 * an area of memory directly, iterators are raw pointer types.
 * 
 * This implementation is intended to be used for sequences of 
 * const elements (ie.: template argument is <code>T const</code>).
 * 
 * The utility function make_array_ref() helps create 
 * array_refs from contexts where they can be needed.
 * 
 * 
 * See also: <code>std::vector</code>, @c seq_ .
 * 
 * Differences from the original proposal:
 * 
 * * Allows for a @c array_ref of non-const objects.
 * * Adds ( @c pointer , @c pointer ) constructor.
 * * Discards @c vector constructor for lower dependency overhead.
 * * Adds member functions @c front , @c back .
 * * Adds member functions @c leftmost , @c rightmost .
 * * Ally functions @c arrayref() and @c carrayref() provided as support.
 * 
 * 
 * 
 * @c array_ref is based in the original publication "n3334" by 
 * Jeffrey Yasskin; @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html 
 * 
 */
template <typename T>
class array_ref {
    public:
    //! type of the data contained in the view.
    typedef T       value_type;
    typedef typename ct::compose<T,::std::add_pointer>::type   pointer;
    typedef typename ct::compose<T,::std::add_const, ::std::add_pointer>::type const_pointer;
    typedef typename ct::compose<T,std::add_lvalue_reference>::type   reference;
    typedef typename ct::compose<T,std::add_const,std::add_lvalue_reference>::type const_reference;
    typedef ptrdiff_t    difference_type;
    typedef size_t       size_type;
    typedef pointer           iterator;
    typedef const_pointer const_iterator;
    typedef std::reverse_iterator<iterator> reverse_iterator;
    typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
    
    public:


#if (CXXOMFORT_CXX_STD>=2011)
    constexpr array_ref () noexcept = default;
    constexpr array_ref (array_ref const&) noexcept = default;
#else



    array_ref () CXXO_NOEXCEPTNOTHROW 
    : ptr_(nullptr), len_(0) 
    {}
    array_ref (array_ref const& a) CXXO_NOEXCEPTNOTHROW 
    : ptr_(a.ptr_), len_(a.len_) {}


#endif
    
    ///! Initializes this to refer to a buffer of memory pointed by @a p and of size @a l .
    CXXO_CONSTEXPR 
    array_ref (pointer p, size_t l) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(l) {}
    
    CXXO_CONSTEXPR 
    array_ref (std::nullptr_t, const_pointer p, const_pointer q) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(static_cast<size_t>(q-p)) {}

    ///! Initialize this to refer to a C-style array.
    template <size_t N>
    CXXO_CONSTEXPR 
    explicit array_ref (T(&arr)[N]) CXXO_NOEXCEPTNOTHROW 
    : ptr_(arr), len_(N) {}
    


    // view from related non-const view, only for const view, for C++11-onwards
#if (CXXOMFORT_CXX_STD >= 2011)
    template <bool B = std::is_const<T>::value, typename std::enable_if<B,int>::type=0 >
    array_ref (array_ref< typename std::remove_const<T>::type > const& av)
    : ptr_(av.ptr_), len_(av.len_) {}
#endif

    // view ref from array<>; should be a std::array conversion operator but can't in C++03, C++11
    template <size_t N>
    CXXO_CONSTEXPR 
    array_ref (std::array<T,N> const& arr) CXXO_NOEXCEPTNOTHROW
    : ptr_(arr.data()), len_(arr.size()) {}





    
    // access to elements

    // nonconst should only be enabled if T is nonconst
    reference       at (size_t i) { check_range(i); return ptr_[i]; }
    //! Checked access to i-th element; throws if the index is out of range.
    const_reference at (size_t i) const { check_range(i); return ptr_[i]; }
    //! Checked access to i-th element; sets up an @c error_code if the index is out of range.
    const_reference at (size_t i, std::error_code& ec) const { check_range(i,ec); return ptr_[i]; }
    //! Unchecked(!) access to the i-th element.
    reference       operator[] (size_t i) CXXO_NOEXCEPTNOTHROW { return ptr_[i]; }
    //! Unchecked(!) access to the i-th element.
    CXXO_CONSTEXPR 
    const_reference operator[] (size_t i) const CXXO_NOEXCEPTNOTHROW { return ptr_[i]; }
    
    // view info
    
    CXXO_CONSTEXPR size_t     max_size () const CXXO_NOEXCEPTNOTHROW { return len_; }
    //! @return size of the view as a @c size_t .
    CXXO_CONSTEXPR size_t     size () const CXXO_NOEXCEPTNOTHROW { return len_; }
    //! @return @c bool .
    CXXO_CONSTEXPR bool       empty () const CXXO_NOEXCEPTNOTHROW { return size() == 0; }
    //! @return pointer to the view's data.
    pointer         data () CXXO_NOEXCEPTNOTHROW { return ptr_; }
    //! @return pointer to the view's data.
    CXXO_CONSTEXPR 
    const_pointer   data () const CXXO_NOEXCEPTNOTHROW { return ptr_; }
    
    // iterators
    CXXO_CONSTEXPR
    const_iterator  cbegin () const CXXO_NOEXCEPTNOTHROW { return ptr_; }
    CXXO_CONSTEXPR
    const_iterator  cend () const CXXO_NOEXCEPTNOTHROW { return ptr_+len_; }
    iterator        begin () CXXO_NOEXCEPTNOTHROW { return ptr_; }
    iterator        end () CXXO_NOEXCEPTNOTHROW { return ptr_+len_; }
    const_iterator  begin () const CXXO_NOEXCEPTNOTHROW { return cbegin(); }
    const_iterator  end () const CXXO_NOEXCEPTNOTHROW { return cend(); }

    const_reverse_iterator    crbegin () const CXXO_NOEXCEPTNOTHROW { return const_reverse_iterator(ptr_+len_); }
    const_reverse_iterator    crend () const CXXO_NOEXCEPTNOTHROW { return const_reverse_iterator(ptr_); }
    const_reverse_iterator    rbegin () const CXXO_NOEXCEPTNOTHROW { return crbegin(); }
    const_reverse_iterator    rend () const CXXO_NOEXCEPTNOTHROW { return crend(); }

    const_iterator  front () const { return ptr_[0]; }
    const_iterator  back () const { return ptr_[len_-1]; }

    //! Returns a view to the @a count elements starting from @a pos .
    array_ref       substr (size_type pos, size_type count) const;
    //! @overload substr
    array_ref       substr (size_type pos) const;
    //! Returns a view to the leftmost (first @a n elements.
    array_ref       leftmost (size_type n) const;
    //! Returns a view to the rightmost (last) @a n elements.
    array_ref       rightmost (size_type n) const;
    //! Returns a view of sub-contents from position @a pos which can be negative, ala PHP, JS.
    array_ref       slice (difference_type pos, size_type count) const;
    //! @overload slice 
    array_ref       slice (difference_type pos) const;

    


    template <typename U>
    U          copy_to () const {
        return U(data(), size());
    }
    

    //! Returns a view wit the last element removed.
    array_ref  without_back () const;
    //! Returns a view with the first element removed.
    array_ref  without_front () const;
    //! Removes the last @a n elements.
    array_ref  without_back_n (size_type n) const;
    //! Removes the first @a n elements.
    array_ref  without_front_n (size_type n) const;

    private:
    void check_range (size_t i) const {
        if (i>=len_) throw std::out_of_range("array_ref: out of range");
    }
    //void check_range (size_t i, std::error_code& ec) const {
    //    if (i>=len_) ec= std::make_error_code(std::errc::EDOM /*, std::generic_category() */);
    //}
    
    pointer    ptr_;
    size_t     len_ CXXOMFORT_CXX11_CODE(= 0, ;);

}; // array_ref

//! Creates an array_ref view from a buffer and length.
template <typename T>
array_ref<T> arrayref(T*, size_t);
//! Creates an array_ref const view from a buffer and length.
template <typename T>
array_ref<T const> carrayref(T*, size_t);
//! Creates an array_ref const view from a non-const one.
template <typename T>
array_ref<T const> carrayref(array_ref<T> const&);


template <typename T>
array_ref<T> array_ref<T>::without_back () const {
    size_type newlen= (len_>1) ? len_-1 : len_;
    return array_ref(ptr_, newlen);
}

template <typename T>
array_ref<T> array_ref<T>::without_front () const {
    pointer const newbegin = (len_>1) ? ptr_+1 : ptr_;

    size_type const newlen= (len_>1) ? len_-1 : len_;
    return array_ref(newbegin,newlen);
}

template <typename T>
array_ref<T> array_ref<T>::leftmost (size_type n) const {
    return (n >= len_) ? *this : array_ref(ptr_,n);
}

template <typename T>
array_ref<T> array_ref<T>::rightmost (size_type n) const {
    return (n >= len_) ? *this : array_ref(ptr_+len_-n,n);
}

// Returns a view of the substring [pos, pos + rcount), 
// where rcount is the smaller of count and size() - pos
template <typename T>
array_ref<T> array_ref<T>::substr (size_type pos, size_type count) const {
    return (!empty() && (pos < len_) && (count < len_)) 
    ? array_ref(ptr_+pos, std::min(count, len_-pos))
    : array_ref(nullptr,0)
    ;
}



///! Makes an @c array_ref view from a C-style array.
template <typename Ty, size_t N>
array_ref<Ty> make_array_ref(Ty(&arr)[N]) {
    return array_ref<Ty>(arr);
}

................................................................................
///! @overload make_array_ref
template <typename Ty, size_t N>
array_ref<Ty const> make_array_ref(std::array<Ty,N> const& a) {
    return array_ref<Ty const>(a);
}


/*
template <typename Ty>
array_ref<Ty> make_array_ref(std::vector<Ty> const& v) {
    return array_ref<Ty>(v);
}
*/

template <typename Ty>
array_ref<Ty> make_array_ref(std::valarray<Ty> const& v) {
    return array_ref<Ty>(v);
}


................................................................................
template <typename T> struct is_array_ref
: std::false_type {};

template <typename T> struct is_array_ref< array_ref<T> >
: std::true_type {};

} } } // cxxomfort::impl::array_ref



/*
 * @page cxxo:array_ref "Array view for sequences, from n3334"
 * @ingroup cxxo:library
 * 
 * Interfaces defined:

Added cxxomfort/cxxomfort/impl/p1227r0-ssize.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_IMPL_p1227_HPP
#define CXXOMFORT_IMPL_p1227_HPP

/**
 * @file
 * @brief Implements proposal for a general (non-member) unsigned size function
 * */

#include <cxxomfort/cstddef.hpp>
#include <cxxomfort/iterator.hpp>

#define CXXO_IMPLEMENTS_p1227r0 CXXO_IMPLSTATUS_EMULATION()
#define CXXO_IMPLEMENTS_ssize CXXO_IMPLEMENTS_p1227r0

// see: https://wg21.link/p1048r0

namespace cxxomfort { namespace impl {

template <typename Container>
inline typename Container::difference_type 
ssize (Container const& c) {
    return c.size();
}

template <typename T, size_t N>
inline ptrdiff_t
ssize (T const(&arr)[N]) {
    return N;
}




}
}

#endif

Changes to cxxomfort/cxxomfort/impl/relationals.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
#ifndef CXXOMFORT_IMPL_RELATIONALS_HPP
#define CXXOMFORT_IMPL_RELATIONALS_HPP
/**
 * @file

 */

// automatic generation of relational operators

#define CXXO_GENERATE_RELATIONALS(T) \






inline bool operator!= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
inline bool operator>  (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
inline bool operator<= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
inline bool operator>= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \


#define CXXO_GENERATE_RELATIONALS_T(T,...) \
template <TPARAMS> \
inline bool operator!= (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
template <TPARAMS> \
inline bool operator>  (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
template <TPARAMS> \
inline bool operator<= (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
template <TPARAMS> \
inline bool operator>= (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \


#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
#ifndef CXXOMFORT_IMPL_RELATIONALS_HPP
#define CXXOMFORT_IMPL_RELATIONALS_HPP
/**
 * @file
 * @brief Macros for generating relational operators.
 */

// automatic generation of relational operators

#define CXXO_GENERATE_RELATIONALS(L,R) \
inline bool operator!= (L const& vl, R const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
inline bool operator>  (L const& vl, R const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
inline bool operator<= (L const& vl, R const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
inline bool operator>= (L const& vl, R const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \

#define CXXO_GENERATE_RELATIONALS0(T) \
inline bool operator!= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
inline bool operator>  (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
inline bool operator<= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
inline bool operator>= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \


#define CXXO_GENERATE_RELATIONALS0_T(T) \
template <TPARAMS> \
inline bool operator!= (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
template <TPARAMS> \
inline bool operator>  (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
template <TPARAMS> \
inline bool operator<= (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
template <TPARAMS> \
inline bool operator>= (T<TARGS> const& vl, T<TARGS> const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \


#endif

Changes to cxxomfort/cxxomfort/impl/seq_.hpp.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
84
85
86
87
88
89
90
91
92
93
94
95
// implementation of seq_<T>(), ...

#include <iterator>
#include <cxxomfort/base/iterator.hpp>
#include <valarray>

namespace cxxomfort {
namespace library {

template <typename Ty>
struct generate_seq_t {
    private:
    struct p_notype;
    
    public:
................................................................................
generate_seq_t<Ty> seq_() {
    return generate_seq_t<Ty>();
}

}

//! @deprecated 
using library::seq_;

} // cxxomfort

#endif







|







 







|




7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
84
85
86
87
88
89
90
91
92
93
94
95
// implementation of seq_<T>(), ...

#include <iterator>
#include <cxxomfort/base/iterator.hpp>
#include <valarray>

namespace cxxomfort {
namespace impl {

template <typename Ty>
struct generate_seq_t {
    private:
    struct p_notype;
    
    public:
................................................................................
generate_seq_t<Ty> seq_() {
    return generate_seq_t<Ty>();
}

}

//! @deprecated 
using impl::seq_;

} // cxxomfort

#endif

Changes to cxxomfort/cxxomfort/impl/to_basic_string_cxx03.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
344
345
346
347
348
349
350
351
352
353
#ifndef CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP
#define CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP


//#include "../extras/optional.hpp"

namespace cxxomfort { namespace library {
namespace string {

namespace detail_string {

const struct no_t {
    template <typename Ch, typename Tr, typename Alloc>
    friend std::basic_ostringstream<Ch,Tr,Alloc>& 
................................................................................
template <typename T0, typename T1>
std::string  to_string
(T0 const& t0, T1 const& t1) {
    return to_basic_string_defaults<char>(t0,t1);
}

} // string
}} // cxxomfort::library

#endif






|







 







|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
344
345
346
347
348
349
350
351
352
353
#ifndef CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP
#define CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP


//#include "../extras/optional.hpp"

namespace cxxomfort { namespace impl {
namespace string {

namespace detail_string {

const struct no_t {
    template <typename Ch, typename Tr, typename Alloc>
    friend std::basic_ostringstream<Ch,Tr,Alloc>& 
................................................................................
template <typename T0, typename T1>
std::string  to_string
(T0 const& t0, T1 const& t1) {
    return to_basic_string_defaults<char>(t0,t1);
}

} // string
}} // cxxomfort::impl

#endif

Changes to cxxomfort/cxxomfort/impl/to_basic_string_variadic.hpp.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 * char_traits<Ch> and allocator<Ch> from that.
 * * in c++11 onwards, both functions are equivalent
 * 
 */

#if (CXXOMFORT_CXX_STD >= 2011)

namespace cxxomfort { namespace library {
namespace string {

template<class Ch, class Tr = std::char_traits<Ch>, class Alloc = std::allocator<Ch>, class... Args>
std::basic_string<Ch,Tr,Alloc> 
to_basic_string(Args&&... args)
{
    using namespace std;
................................................................................
std::wstring to_wstring(Args&&... args)
{
    using std::forward;
    return to_basic_string<wchar_t>
    (forward<Args>(args)...);
}

} // cxxomfort::string
} } // cxxomfort::library

#else
#include "to_basic_string_cxx03.hpp"
#endif

#if defined(DOXYGEN_DOC)








|







 







|
|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 * char_traits<Ch> and allocator<Ch> from that.
 * * in c++11 onwards, both functions are equivalent
 * 
 */

#if (CXXOMFORT_CXX_STD >= 2011)

namespace cxxomfort { namespace impl {
namespace string {

template<class Ch, class Tr = std::char_traits<Ch>, class Alloc = std::allocator<Ch>, class... Args>
std::basic_string<Ch,Tr,Alloc> 
to_basic_string(Args&&... args)
{
    using namespace std;
................................................................................
std::wstring to_wstring(Args&&... args)
{
    using std::forward;
    return to_basic_string<wchar_t>
    (forward<Args>(args)...);
}

} // string
} } // cxxomfort::impl

#else
#include "to_basic_string_cxx03.hpp"
#endif

#if defined(DOXYGEN_DOC)

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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 library { namespace numeric {


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

    template <> struct to_signed_impl<char> {






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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 {};

    template <> struct to_signed_impl<char> {

Changes to cxxomfort/cxxomfort/impl/tuple_call.hpp.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

#include <cxxomfort/base.hpp>
#include <tuple>
#include <type_traits>
#include <functional>

namespace cxxomfort {
namespace library {
namespace tuple {

/*
 * returns 1 + the index of the first element of tt
 * for which p(get<>...) returns true
 */
template <typename P, typename Tuple>
................................................................................
Tuple tuple_visit (F f, Tuple t) {
    detail::tuple_visit_each_t<F,Tuple>(f,t);
    return t;
}


} // namespace tuple
} // namespace library
} // namespace cxxomfort


#endif // CXXOMFORT_EXTRAS_LOCALFN_HPP










|







 







<
|






7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
74
75
76
77
78
79
80

81
82
83
84
85
86
87

#include <cxxomfort/base.hpp>
#include <tuple>
#include <type_traits>
#include <functional>

namespace cxxomfort {
namespace impl {
namespace tuple {

/*
 * returns 1 + the index of the first element of tt
 * for which p(get<>...) returns true
 */
template <typename P, typename Tuple>
................................................................................
Tuple tuple_visit (F f, Tuple t) {
    detail::tuple_visit_each_t<F,Tuple>(f,t);
    return t;
}


} // namespace tuple

} } // namespace cxxomfort::impl


#endif // CXXOMFORT_EXTRAS_LOCALFN_HPP



Added cxxomfort/cxxomfort/impl/tuplemeta.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
#ifndef CXXOMFORT_IMPL_TUPLEMETA_HPP
#define CXXOMFORT_IMPL_TUPLEMETA_HPP

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

namespace cxxomfort { namespace impl {


/**
 * @brief type_traits that defines a @c value @c true if the type T is a @c std::tuple .
 */
template <typename T> struct is_tuple: traits::false_type {};

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

//! Inherits from @c true_type  if @p T  is a <code>std::tuple</code>.
template <typename... Args> struct is_tuple< std::tuple<Args...> >
: traits::true_type {};

#else // c++03

// assume implementation of tuple in tr1 and supports at least 10 elements


template <typename T1> struct is_tuple <std::tuple<T1> >
: traits::true_type {};
template <typename T1, typename T2> 
struct is_tuple <std::tuple<T1,T2> >
: traits::true_type {};
template <typename T1, typename T2, typename T3> 
struct is_tuple <std::tuple<T1,T2,T3> >
: traits::true_type {};
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_EMULATION_variadic==1)
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, 
 * if so, returns its index (0...N-1)
 * 
 * @tparam S = size of the tuple Tuple.
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_element2index_helper {
    enum { rec = (0 <= N && N < S) };
    static const size_t X = tuple_element2index_helper<C,N+1,S,Tuple>::value ;
    typedef typename std::enable_if<rec, bool>::type still_has_arguments_t;
    static const size_t value = 
    (std::is_same<C, typename std::tuple_element<N,Tuple>::type>::value
    ? N : X
    ) ;
};


template <typename C, size_t N, typename Tuple>
struct tuple_element2index_helper<C,N,N,Tuple> {
    enum { value = N+1 };
};



/*
 * Count the number of times type C appears in Tuple
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_count_type_helper {
    enum { value =
    std::is_same< C, typename std::tuple_element<N,Tuple>::type>::value 
    + tuple_count_type_helper<C,N+1,S,Tuple>::value
    };
};

template <typename C, size_t S, typename Tuple>
struct tuple_count_type_helper<C,S,S,Tuple> {
    enum { value = 0 };
};


// 
// tuple_index
// 


namespace detail {

/*
 * Check if an element of type T is already in Tuple, 
 * if so, returns its index (0...N-1)
 * 
 * @tparam S = size of the tuple Tuple.
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_element2index_helper {
    enum { rec = (0 <= N && N < S) };
    static const size_t X = tuple_element2index_helper<C,N+1,S,Tuple>::value ;
    typedef typename std::enable_if<rec, bool>::type still_has_arguments_t;
    static const size_t value = 
    (std::is_same<C, typename std::tuple_element<N,Tuple>::type>::value
    ? N : X
    ) ;
};


template <typename C, size_t N, typename Tuple>
struct tuple_element2index_helper<C,N,N,Tuple> {
    enum { value = N+1 };
};

template <typename T1,typename T2>
struct tuple_element2index_helper_pair {
    enum { value= (0==std::is_same<T1,T2>::value) };
    static_assert (value, "Tuple get<type> interface for pair requires pair of distinct types");
};

/*
 * Count the number of times type C appears in Tuple
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_count_type_helper {
    enum { value =
    std::is_same< C, typename std::tuple_element<N,Tuple>::type>::value 
    + tuple_count_type_helper<C,N+1,S,Tuple>::value
    };
};

template <typename C, size_t S, typename Tuple>
struct tuple_count_type_helper<C,S,S,Tuple> {
    enum { value = 0 };
};

} // namespace detail

/**
 * @brief Counts the number of times that type @a C appears in tuple @a Tuple.
 * @return The member @c value is defined as an integer = the number of times type C appears in Tuple.
 * @post 0 ≤ @a C ≤ tuple_size<Tuple>::value 
 * 
 */
template <typename C, typename Tuple>
struct tuple_count_type {
    enum { value = detail::tuple_count_type_helper<C,0,std::tuple_size<Tuple>::value,Tuple>::value };
};

/**
 * @brief Gives the index <code><0...S-1></code> at which type @a C appears in @a Tuple .
 * 
 * The member @c value defined as the number of times.
 * 
 * The member type @a Sentinel is an implementation-defined type.
 * 
 * @warning If @a C appears more than once, @c value is not defined, and @c Sentinel is the type @c void .
 * @warning If @a C does not appear in the tuple at all, compilation error.
 * 
 * 
 * */
template <typename C, typename Tuple>
struct tuple_index {
    private:
    typedef typename std::remove_reference<Tuple>::type T;
    static const size_t va= tuple_count_type<C,T>::value;
    
    static_assert ((va < 2), "Type (C in template) is repeated in tuple.");
    //static_assert ((va != 0), "Type (C in template) does not exist in tuple.");
    public:
    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 
    };
};


}}

#endif

Changes to cxxomfort/cxxomfort/impl/typesafe_enum-core.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























































#ifndef CXXOMFORT_IMPL_TYPESAFEENUM_CORE_HPP
#define CXXOMFORT_IMPL_TYPESAFEENUM_CORE_HPP







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

#include <cxxomfort/impl/relationals.hpp>















namespace cxxomfort { namespace library {

namespace detail_enum {
struct safe_enum_tag_core {};


} // detail_enum

/**
 * Minimalistic implementation of typesafe enum, 
 * right out of wikibooks.
 * 
 * @see https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 * 
 */
template<typename def, typename inner = typename def::type>
class typesafe_enum_simple : public def /*, public detail_enum::safe_enum_tag */ {


    typedef typename def::type enum_type;




    typedef inner underlying_type;
    inner val;

    public:
    CXXO_CONSTEXPR 


    typesafe_enum_simple () CXXO_NOEXCEPTNOTHROW 
    CXXOMFORT_CXX11_CODE( = default , {} );

    








    CXXO_CONSTEXPR explicit 
    typesafe_enum_simple (typename def::type v) CXXO_NOEXCEPTNOTHROW 

    : val(v) {}


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


    bool 
    equals (typesafe_enum_simple const& x) const CXXO_NOEXCEPTNOTHROW { return val==x.val; };
    
    friend bool 
    operator== (typesafe_enum_simple const& c1, typesafe_enum_simple const& c2) CXXO_NOEXCEPTNOTHROW {
        return c1.val==c2.val;




    }
    friend bool 
    operator< (typesafe_enum_simple const& c1, typesafe_enum_simple const& c2) CXXO_NOEXCEPTNOTHROW {
        return c1.val<c2.val;
    }








    

    private:
    struct disallowed_enum_conversion {};


};



#define TPARAMS typename def, typename inner
#define TARGS def,inner
































CXXO_GENERATE_RELATIONALS_T(typesafe_enum_simple);
#undef TARGS
#undef TPARAMS







}





}





















#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
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
#ifndef CXXOMFORT_IMPL_TYPESAFEENUM_HPP
#define CXXOMFORT_IMPL_TYPESAFEENUM_HPP

/**
 @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/11-underlying_type.hpp>
#include <cxxomfort/using.hpp>

/*
 * Usage is as follows:
 */
#if 0 

// example
//struct myenum_def { enum type { member1, member2, member3 }; };
//typedef typesafe_enum<myenum_def> myenum;
// quick and easy encapsulation

#endif

/* Section: declaration of safe_enum */

namespace cxxomfort { namespace impl {

namespace detail_enum {
struct safe_enum_tag {};


} // detail_enum








template<typename def, typename inner = typename def::type>
class typesafe_enum : public def /*, public detail_enum::safe_enum_tag */ {
    inner val;
    public: 
    typedef typename def::type enum_type;
    typedef inner inner_type;
    typedef typename std::conditional<
        std::is_enum<inner>::value
        , typename std::underlying_type< /*inner*/ typename def::type >::type , inner
    >::type underlying_type;

 
    public:

    CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(typesafe_enum);

    CXXO_CONSTEXPR typesafe_enum (inner_type e) CXXO_NOEXCEPTNOTHROW 

    : val(e) {}

/*
    typesafe_enum (::cxxomfort::detail::explicit_cast<typesafe_enum> const& e)
    : val (e)
    {}
*/

    /*
    template <typename Q>
    CXXO_CONSTEXPR explicit typesafe_enum (Q v

    , typename ::std::enable_if< false==::std::is_same<Q,underlying_type>::value, Q>::type* = nullptr) 
    : val(v) {}
    */


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

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

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






#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    template <typename I>
    CXXO_CONSTEXPR CXXO_EXPLICIT_OPERATOR(I) () const CXXO_NOEXCEPTNOTHROW { 
        return static_cast<I>(val); 
    }
#endif



    /*{
        enum { T_is_compatible_type = std::is_same<T, enum_type>::value };
        static_assert (T_is_compatible_type, "typesafe_enum construction invalid - not the enum's tags or the underlying type");
    };*/

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

};


// inequality (uses friend version of equality)
template<typename def, typename inner>

inline CXXO_CONSTEXPR 
bool operator!= (typesafe_enum<def,inner> const& e1, typesafe_enum<def,inner> const& e2) CXXO_NOEXCEPTNOTHROW {
    return !(e1==e2);
}

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC)
#else
// construct typesafe_enum from the underlying type (useful for "to-byte"-style helpers)
// usage: TSE e = from_underlying<TSE>(u)
template <typename TSE>
TSE from_underlying ( typename TSE::underlying_type c ) {
    return static_cast<typename TSE::enum_type>(c);
}
#endif



template <bool isenum, typename T>
struct is_typesafeenum_helper;

template <typename T> struct is_typesafeenum_helper<false,T> {
    // is_class == false
    enum { value= false };
};

template <typename T> struct is_typesafeenum_helper<true,T> {
    // is_class == true
    enum { value= std::is_base_of<detail_enum::safe_enum_tag,T>::value 
        && std::is_enum<typename T::type>::value };
};

template <typename T>
struct is_typesafe_enum 


: is_typesafeenum_helper <std::is_class<T>::value, T> {};

template <typename T, typename S>
struct is_typesafe_enum< ::cxxomfort::impl::typesafe_enum<T,S> > 
// : is_scoped_enum_helper < false, ::cxxomfort::extras::safe_enum<T,S> > {};
{ enum { value = true}; };


#if 0
/* An enumerator is scoped if 
 * it is a native enum but it's not convertible 
 * to its underlying type.
 */

template <bool B, typename T>
struct is_scoped_enum_helper;

template <typename T>
struct is_scoped_enum_helper<false, T> {
    // T is not an integral type
    static const bool value = 
    !std::is_convertible<T, typename std::underlying_type<T>::type>::value
    ;
};

template <typename T>
struct is_scoped_enum_helper<true, T> {
    // T is an integral type
    static const bool value = false;
};

template <typename T>
struct is_scoped_enum 
: is_scoped_enum_helper< std::is_integral<T>::value, T > {};

#endif

} // library
} // cxxomfort::

/* End section: safe_enum */


/* begin section: underlying type specialization */

namespace std {

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC)
#else
template <typename T, typename U>
struct underlying_type< cxxomfort::impl::typesafe_enum<T,U> > {
    typedef typename cxxomfort::impl::typesafe_enum<T,U>::underlying_type    type;
};
#endif


} // std::


/* end section: underlying_type */


#ifndef CXXOMFORT_CXX11_MODE
#define CXXO_ENUM_BEGIN(Name,Storage) struct Name##0_def { \
    typedef Storage storage_type; \
    enum type 
#define CXXO_ENUM_END(Name,Storage) ; \
}; \
template <typename T> \
typename std::enable_if< !std::is_same< Name##0_def::type, T>::value, bool>::type \
operator== (Name##0_def::type, T) { \
    enum { v= !std::is_same< Name##0_def::type, T>::value }; \
    typedef char enum_comparison_disallowed[-v];  \
    /* static_assert (!v, "Comparison of scoped enum value"); */ \
} \
typedef ::cxxomfort::extras::safe_enum< Name##0_def , Storage > Name ; \

#else
#define CXXO_ENUM_BEGIN(Name,Storage) enum class Name : Storage
#define CXXO_ENUM_END(Name,Storage) 

#endif // c++11

#define ENUM_ITERABLE(Name) \
std::enable_if< lpp::detail::is_scoped_enum< Name >::value, Name>::type  \
begin (Name) { return Name::First; }\
std::enable_if< lpp::detail::is_scoped_enum< Name >::value, Name>::type  \
end (Name) { return Name::Last; }\


#endif // SAFEENUM.HPP

Added cxxomfort/cxxomfort/impl/uchar.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
#ifndef CXXOMFORT_IMPL_UCHAR_HPP
#define CXXOMFORT_IMPL_UCHAR_HPP

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

/*
 * In GCC, in C++03 it is not possible to set char16_t as their own type because 
 * SSO (small-string-optimization) requires the char type to a 
 * std::basic_string to be usable in a union.
 * 
 * For most other compilers, so long as no storage optimizations are used, 
 * char16_t should be able to be its own type.
 * 
 * The library flag CXXOFLAG_MAKE_TYPEDEF_charn_t determines whether to 
 * set-up char16_t, char32_t as typedefs or as their own types.
 * 
 * */
//namespace cxxomfort { namespace cxxostd {

#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_charn_t == 0)
    #if defined(CXXOFLAG_MAKE_TYPEDEF_charn_t)

typedef uint16_t char16_t;
typedef uint32_t char32_t;

        #define CXXO_charn_t_typedefs 1

    #else

//! A character type with the same signedness and range as @c uint16_t .
struct char16_t {
    public:
    // trivial def-ctor
    // trivial copy-ctor
    // trivial assign
    CXXO_CONSTEXPR char16_t (uint16_t u) CXXO_NOEXCEPTNOTHROW 
    : v_(u) {}
    operator uint16_t const& () const CXXO_NOEXCEPTNOTHROW { return v_; }
    operator uint16_t& () CXXO_NOEXCEPTNOTHROW { return v_; }
    private:
    uint16_t v_;
};

//! A character type with the same signedness and range as @c uint32_t .
struct char32_t {
    public:
    // trivial def-ctor
    // trivial copy-ctor
    // trivial assign
    CXXO_CONSTEXPR char32_t (uint32_t u) CXXO_NOEXCEPTNOTHROW 
    : v_(u) {}
    operator uint32_t const& () const CXXO_NOEXCEPTNOTHROW { return v_; }
    operator uint32_t& () CXXO_NOEXCEPTNOTHROW { return v_; }
    private:
    uint32_t v_;
};

        #define CXXO_charn_t_typedefs 0

    #endif // charn_t is typedef
#endif // c++11

// } }

#endif

Changes to cxxomfort/cxxomfort/impl/unique_ptr.hpp.

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
 * is_const
 * enable_if (provided by meta.hpp)
 * is_empty
 */


namespace cxxomfort {
namespace memory {

//
// implementation details
//
namespace detail_unique_ptr {


................................................................................
}


} //~namespace memory
} //~namespace cxxomfort

namespace std {
    using ::cxxomfort::memory::unique_ptr;
}

#else
    // nothing to do, we're in C++11
#endif // impl.

#endif  // guard







|







 







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
 * is_const
 * enable_if (provided by meta.hpp)
 * is_empty
 */


namespace cxxomfort {
namespace cxxostd {

//
// implementation details
//
namespace detail_unique_ptr {


................................................................................
}


} //~namespace memory
} //~namespace cxxomfort

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

#else
    // nothing to do, we're in C++11
#endif // impl.

#endif  // guard

Added 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/library/iterator.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
#define CXXOMFORT_CXXO_ITERATOR_HPP
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <iterator>
#include <functional>
//#include <type_traits>




/**
 * @file
 */

namespace cxxomfort { namespace library { 
namespace iterator {

template <typename Integer, typename I>
size_t absdistance (I i1, I i2, Integer i, std::bidirectional_iterator_tag) {
    bool brk= false;
    for (i= 0; i1 != i2; ++i, ++i1, --i2) {
        if (next(i2,1)==i1) { brk=true; break; }
    }
    i*= 2;
    return i - size_t(1)*brk; 
}

template <typename Integer, typename I>
size_t absdistance (I i1, I i2, Integer i, std::forward_iterator_tag) {
    for (i= 0; i1 != i2; ++i, ++i1) {}
    return i; 
}








>
>
>







|
<
<
<
<
<
<
<
<







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
#define CXXOMFORT_CXXO_ITERATOR_HPP
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <iterator>
#include <functional>
//#include <type_traits>


#include <cxxomfort/impl/p1227r0.hpp> // ssize

/**
 * @file
 */

namespace cxxomfort { namespace library { 
namespace iterator {

using ::cxxomfort::impl::ssize;









template <typename Integer, typename I>
size_t absdistance (I i1, I i2, Integer i, std::forward_iterator_tag) {
    for (i= 0; i1 != i2; ++i, ++i1) {}
    return i; 
}

Changes to cxxomfort/cxxomfort/library/numeric.hpp.

30
31
32
33
34
35
36



37
38
39
40
41
42
43


#include "../impl/to_signed.hpp"

namespace cxxomfort { namespace library {
namespace numeric {





// integral constant 
// (reimplemented here for a simpler interface and to avoid a dependency on probably incomplete type_traits)

template <typename T, T v>
struct T_constant {
    typedef T value_type;







>
>
>







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46


#include "../impl/to_signed.hpp"

namespace cxxomfort { namespace library {
namespace numeric {

using cxxomfort::impl::numeric::to_signed;
using cxxomfort::impl::numeric::to_unsigned;


// integral constant 
// (reimplemented here for a simpler interface and to avoid a dependency on probably incomplete type_traits)

template <typename T, T v>
struct T_constant {
    typedef T value_type;

Changes to cxxomfort/cxxomfort/library/string.hpp.

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
...
338
339
340
341
342
343
344

345
346
347
348
349
350
namespace cxxomfort { namespace library {
/**
 * @ingroup cxxo-sup-string
 * @{
 */
namespace string {




template <typename T> struct is_std_basic_string : std::false_type {};

template <typename CharType>
struct is_std_basic_string< std::basic_string< CharType > > 
: cxxomfort::library::type_traits::is_character_type<CharType> {};


/**
 * @brief Returns a string representation of an ASCII ordinal.
 * @param ascii An ASCII ordinal in the range <code>0...255</code>.
 * @throw std::out_of_range if @a ascii is out of the valid ASCII range.
 * @return a 1-character string of type String.
 */
template <typename String>
String chr (uint16_t ascii) {
    if (ascii >= 0x100) throw std::out_of_range(
        cxxomfort::library::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    char q[]= "0";
    q[0]= ascii;
    return q;
}


// specialization for std::string and std::wstring using their special constructors.
static inline std::string chr (uint16_t ascii) {
    if (ascii >= 0x100) throw std::out_of_range(
        cxxomfort::library::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    return std::string(1, static_cast<char>(ascii));
}

static inline std::wstring wchr (uint32_t ascii) {
    if (ascii >= 0x100) throw std::out_of_range(
        cxxomfort::library::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    return std::wstring(1, static_cast<wchar_t>(ascii));
}

static inline std::string utf8chr (uint32_t cp) {
	using namespace std;
	char chu[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
................................................................................


} // string

/**
 * @}
 */


}} // cxxomfort::library



#endif







>
>





|











|










|






|







 







>






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
...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
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 > > 
: cxxomfort::impl::type_traits::is_character_type<CharType> {};


/**
 * @brief Returns a string representation of an ASCII ordinal.
 * @param ascii An ASCII ordinal in the range <code>0...255</code>.
 * @throw std::out_of_range if @a ascii is out of the valid ASCII range.
 * @return a 1-character string of type String.
 */
template <typename String>
String chr (uint16_t ascii) {
    if (ascii >= 0x100) throw std::out_of_range(
        cxxomfort::impl::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    char q[]= "0";
    q[0]= ascii;
    return q;
}


// specialization for std::string and std::wstring using their special constructors.
static inline std::string chr (uint16_t ascii) {
    if (ascii >= 0x100) throw std::out_of_range(
        cxxomfort::impl::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    return std::string(1, static_cast<char>(ascii));
}

static inline std::wstring wchr (uint32_t ascii) {
    if (ascii >= 0x100) throw std::out_of_range(
        cxxomfort::impl::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    return std::wstring(1, static_cast<wchar_t>(ascii));
}

static inline std::string utf8chr (uint32_t cp) {
	using namespace std;
	char chu[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
................................................................................


} // string

/**
 * @}
 */


}} // cxxomfort::library



#endif

Changes to cxxomfort/cxxomfort/library/tuple.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
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
...
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
 * @file
 * 
 * This file provides supplementary features for the tuple-related 
 * utilities present in <code><tuple></code>.
 * 
 * Interfaces defined here
 * 
 * * @c is_tuple
 * * @c tuple_index
 * * @c tuple_pop()
 * * @c tuple_shift()
 * * @c tuple2function_t
 * * @c function2tuple_t
 * * @c tuple_call()
 * 

 * 
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 * 
 */



#include <tuple>

#include "../impl/14-integer_sequence.hpp"

// note: for these to work correctly MSVC needs to define _VARIADIC_MAX to >= 9, 
// 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 {
//

/**


 * @brief type_traits that defines a @c value @c true if the type T is a @c std::tuple .
 */
template <typename T> struct is_tuple: traits::false_type {};

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

//! Inherits from @c true_type  if @p T  is a <code>std::tuple</code>.
template <typename... Args> struct is_tuple< std::tuple<Args...> >
: traits::true_type {};

#else // c++03

// assume implementation of tuple in tr1 and supports at least 10 elements


template <typename T1> struct is_tuple <std::tuple<T1> >
: traits::true_type {};
template <typename T1, typename T2> 
struct is_tuple <std::tuple<T1,T2> >
: traits::true_type {};
template <typename T1, typename T2, typename T3> 
struct is_tuple <std::tuple<T1,T2,T3> >
: traits::true_type {};
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_EMULATION_variadic==1)
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


//
// tuple2array
//

template <typename Tuple>
struct _tuple2array_cnv_t {
................................................................................

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_index
// 


namespace detail {

/*
 * Check if an element of type T is already in Tuple, 
 * if so, returns its index (0...N-1)
 * 
 * @tparam S = size of the tuple Tuple.
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_element2index_helper {
    enum { rec = (0 <= N && N < S) };
    static const size_t X = tuple_element2index_helper<C,N+1,S,Tuple>::value ;
    typedef typename std::enable_if<rec, bool>::type still_has_arguments_t;
    static const size_t value = 
    (std::is_same<C, typename std::tuple_element<N,Tuple>::type>::value
    ? N : X
    ) ;
};


template <typename C, size_t N, typename Tuple>
struct tuple_element2index_helper<C,N,N,Tuple> {
    enum { value = N+1 };
};

template <typename T1,typename T2>
struct tuple_element2index_helper_pair {
    enum { value= (0==std::is_same<T1,T2>::value) };
    static_assert (value, "Tuple get<type> interface for pair requires pair of distinct types");
};

/*
 * Count the number of times type C appears in Tuple
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_count_type_helper {
    enum { value =
    std::is_same< C, typename std::tuple_element<N,Tuple>::type>::value 
    + tuple_count_type_helper<C,N+1,S,Tuple>::value
    };
};

template <typename C, size_t S, typename Tuple>
struct tuple_count_type_helper<C,S,S,Tuple> {
    enum { value = 0 };
};

} // namespace detail

/**
 * @brief Counts the number of times that type @a C appears in tuple @a Tuple.
 * @return The member @c value is defined as an integer = the number of times type C appears in Tuple.
 * @post 0 ≤ @a C ≤ tuple_size<Tuple>::value 
 * 
 */
template <typename C, typename Tuple>
struct tuple_count_type {
    enum { value = detail::tuple_count_type_helper<C,0,std::tuple_size<Tuple>::value,Tuple>::value };
};

/**
 * @brief Gives the index <code><0...S-1></code> at which type @a C appears in @a Tuple .
 * 
 * The member @c value defined as the number of times.
 * 
 * The member type @a Sentinel is an implementation-defined type.
 * 
 * @warning If @a C appears more than once, @c value is not defined, and @c Sentinel is the type @c void .
 * @warning If @a C does not appear in the tuple at all, compilation error.
 * 
 * 
 * */
template <typename C, typename Tuple>
struct tuple_index {
    private:
    typedef typename std::remove_reference<Tuple>::type T;
    static const size_t va= tuple_count_type<C,T>::value;
    
    static_assert ((va < 2), "Type (C in template) is repeated in tuple.");
    //static_assert ((va != 0), "Type (C in template) does not exist in tuple.");
    public:
    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 
    };
};


/**
 * @brief Convert from tuple type to function signature.
 * @ingroup cxxo-sup-tuple
 * 
 * Given a tuple of the form T<T1,T2,...>,







<
<






>








>







 







<

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







 







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







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
...
236
237
238
239
240
241
242




























































































243
244
245
246
247
248
249
 * @file
 * 
 * This file provides supplementary features for the tuple-related 
 * utilities present in <code><tuple></code>.
 * 
 * Interfaces defined here
 * 


 * * @c tuple_pop()
 * * @c tuple_shift()
 * * @c tuple2function_t
 * * @c function2tuple_t
 * * @c tuple_call()
 * 
 * Interfaces brought from impl: @c is_tuple , @c tuple_count_type , @c tuple_index 
 * 
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 * 
 */



#include <tuple>
#include "../impl/tuplemeta.hpp"
#include "../impl/14-integer_sequence.hpp"

// note: for these to work correctly MSVC needs to define _VARIADIC_MAX to >= 9, 
// 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 {
................................................................................

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,...>,

Changes to cxxomfort/cxxomfort/library/type_name.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
..
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

#ifndef CXXOMFORT_SUPP_TYPE_NAME_HPP
#define CXXOMFORT_SUPP_TYPE_NAME_HPP
#include <cxxomfort/base.hpp>
#include <typeinfo>
#include <type_traits> // remove_reference, etc

/**
 * @file
 * @brief Implementation of type-naming utilities for cxxomfort.
 */





#include "../util/type_traits.hpp"
#include "../type_traits.hpp"
#include "../using.hpp"
#include <string>

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

namespace cxxomfort {
namespace library {
namespace detail_demangle {

// Thanks much to ′灵魂L.眼神 for making me notice this had to be made static!
static std::string job (const char* name) {
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || \
     CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    char buf[1024];
    size_t size=sizeof(buf);
    int status;
    char* res = abi::__cxa_demangle (name,
                                 buf,
                                 &size,
                                 &status);
................................................................................
}

/**
 * @brief Demangle a typename, recovering information about const / volatile too.
 * @ingroup cxxo-sup
 * @return A string containing a type name depending on the type @a T used to instantiate the function.
 */

template <typename T>
std::string type_name () CXXO_NOEXCEPTNOTHROW {

























    using namespace std;
    typedef typename remove_reference<T>::type TnR;
    std::string r( typeid_demangle(typeid(T)) );
#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
    #pragma warning (disable:4127) // conditional expression is constant
#endif
    if (is_const<TnR>::value) { r+= " const"; }
    if (is_volatile<TnR>::value) { r+= " volatile"; }
    if (is_lvalue_reference<T>::value) { r+= "&"; }
    if (is_rvalue_reference<T>::value) { r+= "&&"; }
#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
    #pragma warning (default:4127)
#endif
    return r;
}

} // library

// should this be deprecated in the future?
using library::type_name;
using library::typeid_demangle;

} // cxxomfort

#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
..
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
#ifndef CXXOMFORT_SUPP_TYPE_NAME_HPP
#define CXXOMFORT_SUPP_TYPE_NAME_HPP




/**
 * @file
 * @brief Implementation of type-naming utilities for cxxomfort.
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/config.hpp>
#include <typeinfo>
#include <type_traits> // remove_reference, etc
#include "../util/type_traits.hpp"
#include "../type_traits.hpp"
#include "../using.hpp"
#include <string>
#include "../string_view.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    #include <cxxabi.h>
#endif

namespace cxxomfort {
namespace library {
namespace detail_demangle {

// Thanks much to ′灵魂L.眼神 for making me notice this had to be made static!
static std::string job (const char* name) {
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)

    char buf[1024];
    size_t size=sizeof(buf);
    int status;
    char* res = abi::__cxa_demangle (name,
                                 buf,
                                 &size,
                                 &status);
................................................................................
}

/**
 * @brief Demangle a typename, recovering information about const / volatile too.
 * @ingroup cxxo-sup
 * @return A string containing a type name depending on the type @a T used to instantiate the function.
 */

template <typename T>
std::string_view type_name () CXXO_NOEXCEPTNOTHROW {
    using namespace std;
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
    string_view S (__FUNCSIG__);

    char const* pend= find(S.begin()+119, S.end(), '>');
    size_t nend= static_cast<size_t>(pend - S.begin() - 119);
    S= S.substr(119, nend);

#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    string_view S (__PRETTY_FUNCTION__);
    //std::cerr<< "["<< S<< "]"<< std::endl;
    size_t lpos = static_cast<size_t>(S.find("with T = ")+9UL);
    size_t rpos = static_cast<size_t>((S.end() - 80UL) - S.begin());
    S= S.substr(lpos, rpos-lpos);

#else
    string_view S (typeid(T).name());
#endif
    return S;
}



template <typename T>
std::string type_name_old () CXXO_NOEXCEPTNOTHROW {
    using namespace std;
    typedef typename remove_reference<T>::type TnR;
    std::string r( typeid_demangle(typeid(T)) );
//#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
//    #pragma warning (disable:4127) // conditional expression is constant
//#endif
    if (is_const<TnR>::value) { r+= " const"; }
    if (is_volatile<TnR>::value) { r+= " volatile"; }
    if (is_lvalue_reference<T>::value) { r+= "&"; }
    if (is_rvalue_reference<T>::value) { r+= "&&"; }
//#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
//    #pragma warning (default:4127)
//#endif
    return r;
}

} // library

// should this be deprecated in the future?
using library::type_name;
using library::typeid_demangle;

} // cxxomfort

#endif

Changes to cxxomfort/cxxomfort/library/type_traits.hpp.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
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
 * * @c has_operator_brackets
 * * @c Ic and @link impl/ic_types.hpp integral_constant shortcuts @endlink 
 *
 * 
 * */
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair

#include <array> // array
#include "sequences.hpp" 

#include "../impl/character.hpp"


namespace cxxomfort{ namespace library{ 
................................................................................
template <typename A, typename B> struct is_std_pair< std::pair<A,B> >: std::true_type {};

// is_fundamental_wrapper


// 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;

/**
 * @brief type_trait that identifies @c enum s , <code>enum class</code> es and typesafe_enums.
 */

template <typename T> struct is_enumeration_like
: std::integral_constant<bool, 
    std::is_enum<T>::value || is_typesafe_enum<T>::value
> {};



#if (0) // UNTESTED

// is_specialization_of
// from  https://stackoverflow.com/questions/11251376/how-can-i-check-if-a-type-is-an-instantiation-of-a-given-class-template

#if (CXXOMFORT_CXX_STD>=2011)







>







 







|

|




>




>
>







14
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
66
67
68
 * * @c has_operator_brackets
 * * @c Ic and @link impl/ic_types.hpp integral_constant shortcuts @endlink 
 *
 * 
 * */
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair
#include <cxxomfort/cstddef.hpp> // byte
#include <array> // array
#include "sequences.hpp" 

#include "../impl/character.hpp"


namespace cxxomfort{ namespace library{ 
................................................................................
template <typename A, typename B> struct is_std_pair< std::pair<A,B> >: std::true_type {};

// is_fundamental_wrapper


// 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;

/**
 * @brief type_trait that identifies @c enum s , <code>enum class</code> es and typesafe_enums.
 */
/*
template <typename T> struct is_enumeration_like
: std::integral_constant<bool, 
    std::is_enum<T>::value || is_typesafe_enum<T>::value
> {};
*/


#if (0) // UNTESTED

// is_specialization_of
// from  https://stackoverflow.com/questions/11251376/how-can-i-check-if-a-type-is-an-instantiation-of-a-given-class-template

#if (CXXOMFORT_CXX_STD>=2011)

Changes to cxxomfort/cxxomfort/library/typesafe_enum.hpp.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
/**
 @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 <type_traits>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp>
#include <cxxomfort/using.hpp>

/*
 * Usage is as follows:
 */
#if 0 

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

#endif

/* Section: declaration of safe_enum */

namespace cxxomfort { namespace library {

namespace detail_enum {
struct safe_enum_tag {};
} // detail_enum


template<typename def, typename inner = typename def::type>
class typesafe_enum : public def /*, public detail_enum::safe_enum_tag */ {
    inner val;
    public: 
    typedef typename def::type enum_type;
    typedef inner underlying_type;
 
    public:
#if (CXXOMFORT_CXX_STD < 2011)
    CXXO_CONSTEXPR typesafe_enum () CXXO_NOEXCEPTNOTHROW {}
#else
    constexpr typesafe_enum () noexcept = default;
#endif

    CXXO_CONSTEXPR typesafe_enum (typename def::type v) CXXO_NOEXCEPTNOTHROW : val(v) {}

    template <typename Q>
    explicit typesafe_enum (Q q) 
    : val (static_cast<typename def::type>(q))
    {}

    typesafe_enum (::cxxomfort::detail::explicit_cast<typesafe_enum> const& e)
    : val (e)
    {}

    /*
    template <typename Q>
    CXXO_CONSTEXPR explicit typesafe_enum (Q v
    , typename ::std::enable_if< false==::std::is_same<Q,underlying_type>::value, Q>::type* = nullptr) 
    : val(v) {}
    */
    CXXO_CONSTEXPR enum_type value() const CXXO_NOEXCEPTNOTHROW { return val; }
    CXXO_CONSTEXPR underlying_type underlying() const CXXO_NOEXCEPTNOTHROW { return val; }
    
    template <typename I>
    CXXO_CONSTEXPR CXXO_EXPLICIT_OPERATOR(I) () const CXXO_NOEXCEPTNOTHROW { return static_cast<I>(val); }

    /*{
        enum { T_is_compatible_type = std::is_same<T, enum_type>::value };
        static_assert (T_is_compatible_type, "typesafe_enum construction invalid - not the enum's tags or the underlying type");
    };*/

    CXXO_CONSTEXPR bool equals (typesafe_enum const& x) const CXXO_NOEXCEPT { return val == x.val; }
    
    private:
    struct disallowed_enum_conversion {};
    // we disallow other constructors
/*
    template <typename T> 
    typesafe_enum (T const&, 
     typename std::enable_if< 
        std::is_integral<T>::value , disallowed_enum_conversion 
        >::type * = 0 );
  */

    public:
/*
    template <typename E>
    typesafe_enum (E e
    , typename std::enable_if<std::is_enum<E>::value && !std::is_same<E,enum_type>::value
    , disallowed_enum_conversion>::type* = nullptr) {
        enum { is_different_enum= std::is_enum<E>::value && !std::is_same<E,enum_type>::value };
        static_assert( is_different_enum==false, "typesafe_enum can not construct from different enum types");
    }
*/

};

// equality
template<typename def, typename inner>
inline CXXO_CONSTEXPR 
bool operator== (typesafe_enum<def,inner> const& e1, typesafe_enum<def,inner> const& e2) CXXO_NOEXCEPTNOTHROW {
    return e1.equals(e2);
}

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

// construct typesafe_enum from the underlying type (useful for "to-byte"-style helpers)
// usage: TSE e = from_underlying<TSE>(u)
template <typename TSE>
TSE from_underlying ( typename TSE::underlying_type c ) {
    return static_cast<typename TSE::enum_type>(c);
}

/*
#if 0 && !defined( CXXOMFORT_CXX11_MODE )
// Global begin
template <typename def, typename inner> 
safe_enum<def,inner> begin (safe_enum<def,inner>) {
    typedef safe_enum<def,inner> Enum;
    //typedef typename Enum::type type;
    return Enum(Enum::First);
}

// Global end
template <typename def, typename inner> 
safe_enum<def,inner> end (safe_enum<def,inner>) {
    typedef safe_enum<def,inner> Enum;
    //typedef typename Enum::type type;
    return Enum(static_cast<typename Enum::enum_type>(Enum::Last+1));
}
#else

#endif // c++11
*/
// end of idiom impl


} // library
} // cxxomfort::


/* End section: safe_enum */

/* Begin section: is_scoped_enum */

namespace cxxomfort { namespace library {

template <bool isenum, typename T>
struct is_typesafeenum_helper;

template <typename T> struct is_typesafeenum_helper<false,T> {
    // is_class == false
    enum { value= false };
};

template <typename T> struct is_typesafeenum_helper<true,T> {
    // is_class == true
    enum { value= std::is_base_of<detail_enum::safe_enum_tag,T>::value 
        && std::is_enum<typename T::type>::value };
};

template <typename T>
struct is_typesafe_enum 
: is_typesafeenum_helper <std::is_class<T>::value, T> {};

template <typename T, typename S>
struct is_typesafe_enum< ::cxxomfort::library::typesafe_enum<T,S> > 
// : is_scoped_enum_helper < false, ::cxxomfort::extras::safe_enum<T,S> > {};
{ enum { value = true}; };


#if 0
/* An enumerator is scoped if 
 * it is a native enum but it's not convertible 
 * to its underlying type.
 */

template <bool B, typename T>
struct is_scoped_enum_helper;

template <typename T>
struct is_scoped_enum_helper<false, T> {
    // T is not an integral type
    static const bool value = 
    !std::is_convertible<T, typename std::underlying_type<T>::type>::value
    ;
};

template <typename T>
struct is_scoped_enum_helper<true, T> {
    // T is an integral type
    static const bool value = false;
};

template <typename T>
struct is_scoped_enum 
: is_scoped_enum_helper< std::is_integral<T>::value, T > {};

#endif

} // library
} // cxxomfort::

/* End section: safe_enum */

#if 0    
// let's try write a operator== that directly compares two different enums
// This adds type safety by triggering an error when two 
// enums of different types are compared.

template <typename E1, typename E2>
typename std::enable_if <
    (std::is_enum<E1>::value && std::is_enum<E2>::value)
    && (false==std::is_same<E1,E2>::value)
    , bool
    >::type
operator== (E1,E2)  {
    enum { value= (std::is_enum<E1>::value) && (std::is_enum<E2>::value) };
    static_assert(!value, "Attempt to compare two enums of different types");
}

template <typename E1, typename E2>
typename std::enable_if <
    (std::is_enum<E1>::value && std::is_enum<E2>::value)
    && (false==std::is_same<E1,E2>::value)
    , bool
    >::type
operator!= (E1, E2) {
    enum { value= (std::is_enum<E1>::value) && (std::is_enum<E2>::value) };
    static_assert(!value, "Attempt to compare two enums of different types");
}

#endif


/*
}//~namespace 
*/

/* begin section: underlying type specialization */

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

namespace std {

#if (CXXOMFORT_CXX_STD >= 2011)
template <typename T, typename U>
struct underlying_type< cxxomfort::library::typesafe_enum<T,U> > {
    private:
    typedef typename cxxomfort::library::typesafe_enum<T,U> EnumT;
    public:
    typedef typename std::underlying_type<typename EnumT::underlying_type>::type type;
    //typedef typename cxxomfort::extras::typesafe_enum<T,U>::underlying_type type;
};

#endif

} // std::


/* end section: underlying_type */


#ifndef CXXOMFORT_CXX11_MODE
#define CXXO_ENUM_BEGIN(Name,Storage) struct Name##0_def { \
    typedef Storage storage_type; \
    enum type 
#define CXXO_ENUM_END(Name,Storage) ; \
}; \
template <typename T> \
typename std::enable_if< !std::is_same< Name##0_def::type, T>::value, bool>::type \
operator== (Name##0_def::type, T) { \
    enum { v= !std::is_same< Name##0_def::type, T>::value }; \
    typedef char enum_comparison_disallowed[-v];  \
    /* static_assert (!v, "Comparison of scoped enum value"); */ \
} \
typedef ::cxxomfort::extras::safe_enum< Name##0_def , Storage > Name ; \

#else
#define CXXO_ENUM_BEGIN(Name,Storage) enum class Name : Storage
#define CXXO_ENUM_END(Name,Storage) 

#endif // c++11

#define ENUM_ITERABLE(Name) \
std::enable_if< lpp::detail::is_scoped_enum< Name >::value, Name>::type  \
begin (Name) { return Name::First; }\
std::enable_if< lpp::detail::is_scoped_enum< Name >::value, Name>::type  \
end (Name) { return Name::Last; }\


#endif // SAFEENUM.HPP







<

|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<

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

3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
..
23
24
25
26
27
28
29































































30















































































31

32














































































































33

34













35
/**
 @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 

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

#endif

/* Section: declaration of safe_enum */

namespace cxxomfort { namespace library {
































































    using ::cxxomfort::impl::typesafe_enum;















































































    using ::cxxomfort::impl::is_typesafe_enum;
















































































































} }















#endif // SAFEENUM.HPP

Changes to cxxomfort/cxxomfort/library/utility.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
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair


namespace cxxomfort { namespace library { 
namespace utility {

//
// 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; 
};

//
// v_in_place_type , v_in_place_index 
//
// c++<14 does not have variable templates, so we 
// add some shortcuts to eg.: in_place_type_t








<
<
<

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







10
11
12
13
14
15
16



17























18
19
20
21
22
23
24
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair


namespace cxxomfort { namespace library { 
namespace utility {





























//
// v_in_place_type , v_in_place_index 
//
// c++<14 does not have variable templates, so we 
// add some shortcuts to eg.: in_place_type_t

Changes to cxxomfort/cxxomfort/memory.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
...
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
#ifndef CXXOMFORT_MEMORY_HPP
#define CXXOMFORT_MEMORY_HPP
/**
 * @file
 * @brief Implementations and additions tied to Standard Header <memory>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c addressof() (C++11)
 * * Pointer traits and Allocator traits
 * * <code>@link aligned_storage @endlink </code> (C++11)
 * * <code>@link unique_ptr @endlink </code> (C++11)
 * * @c make_unique() (C++14)
 *
 * See also: 
 * <a href="https://en.cppreference.com/w/cpp/header/memory">\<memory\> \@cppreference</a>.
 * 
 */

#include "config.hpp"
#include "base/alignof.hpp"
#include CXXO_INCLUDE_SYS(memory)

#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
................................................................................
} // cxxomfort

//
// addressof
//
#include "impl/11-addressof.hpp"








//
// unique_ptr
//
#include "impl/unique_ptr.hpp"















#include "impl/14-make_unique.hpp"


#include "impl/17-destroy_at.hpp"


// -- set up needed things in std::
#if (CXXOMFORT_CXX_STD < 2011)
    #if (!defined(CXXOMFORT_NO_TR1) && !defined(NO_TR1))
//
// specialize std::tr1::hash for unique_ptr<>
// (this is allowed)
// define either NO_TR1 or CXXOMFORT_NO_TR1 to disable 
// using this TR1 extension in C++03
//
#include <functional> // std::hash, from Tr1
namespace std { namespace tr1 {
    template <typename T, typename D>
    struct hash< unique_ptr<T,D> > 
    : private hash< typename unique_ptr<T,D>::pointer > {
        private:
        typedef hash< typename unique_ptr<T,D>::pointer > base_type;
        public:
        typedef unique_ptr<T,D> argument_type;
        typedef size_t result_type;
        size_t operator() (argument_type const& t) const {
            //return static_cast<base_type>(*this).operator()(t.get());
            return static_cast<base_type const*>(this)->operator()(t.get());
        }
    };
} /* tr1 */ }
    #endif
#endif

#else

#endif // c++03/11




#endif // file





|

|






|

|







 







>
>
>
>
>
>






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

>



>

|




|



|

|











|



<
<
<
<
<
<
<

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
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
#ifndef CXXOMFORT_MEMORY_HPP
#define CXXOMFORT_MEMORY_HPP
/**
 * @file
 * @brief Implementations and additions tied to Standard Header <memory>.
 *
 * Interfaces defined in this file:
 *
 * * @c addressof() (C++11)
 * * Pointer traits and Allocator traits
 * * <code>@link aligned_storage @endlink </code> (C++11)
 * * <code>@link unique_ptr @endlink </code> (C++11)
 * * @c make_unique() (C++14)
 *
 * See also:
 * <a href="https://en.cppreference.com/w/cpp/header/memory">\<memory\> \@cppreference</a>.
 *
 */

#include "config.hpp"
#include "base/alignof.hpp"
#include CXXO_INCLUDE_SYS(memory)

#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
................................................................................
} // cxxomfort

//
// addressof
//
#include "impl/11-addressof.hpp"



#else

#endif // c++03/11


//
// unique_ptr
//
#include "impl/unique_ptr.hpp"

#if defined(CXXOMFORT_USING_unique_ptr)

#endif

// assist
namespace cxxomfort {
template <typename T>
bool to_bool (std::unique_ptr<T> const& p) CXXO_NOEXCEPTNOTHROW {
    return p.get() != nullptr;
}

}

#if defined(CXXOMFORT_USING_unique_ptr)
#include "impl/14-make_unique.hpp"
#endif

#include "impl/17-destroy_at.hpp"


// -- set up needed things in std::
#if (CXXOMFORT_CXX_STD < 2011 && defined(CXXOMFORT_USING_unique_ptr))
    #if (!defined(CXXOMFORT_NO_TR1) && !defined(NO_TR1))
//
// specialize std::tr1::hash for unique_ptr<>
// (this is allowed)
// define either NO_TR1 or CXXOMFORT_NO_TR1 to disable
// using this TR1 extension in C++03
//
#include <functional> // std::hash, from Tr1
CXXO_OPEN_STDTR1() //namespace std { namespace tr1 {
    template <typename T, typename D>
    struct hash< ::std::unique_ptr<T,D> >
    : private hash< typename unique_ptr<T,D>::pointer > {
        private:
        typedef hash< typename unique_ptr<T,D>::pointer > base_type;
        public:
        typedef unique_ptr<T,D> argument_type;
        typedef size_t result_type;
        size_t operator() (argument_type const& t) const {
            //return static_cast<base_type>(*this).operator()(t.get());
            return static_cast<base_type const*>(this)->operator()(t.get());
        }
    };
CXXO_CLOSE_STDTR1() // } /* tr1 */ }
    #endif
#endif








#endif // file

Changes to cxxomfort/cxxomfort/string.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
#define CXXOMFORT_STRING_HPP
/**
 * @file cxxomfort/string.hpp
 * @brief Implementations and additions tied to <code><string></code>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c to_string() (C++11)
 * * @c strtoll() , @c strtoull() function family (C++11)
 * 
 * Future / potential interfaces:
 * 
 * * @c string user-defined literal
 * 
 * @see https://en.cppreference.com/w/cpp/header/string
................................................................................
 *
 */



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



#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/14-string_literal.hpp"

#if (CXXOMFORT_CXX_STD < 2011)





    // GCC already has a specialization for string, wstring
    #if (CXXOMFORT_COMPILER_ID != CXXO_COMPILERID_GCC)
namespace std {

    template<typename Char> 
    struct hash< ::std::basic_string<Char> > {
        typedef ::std::basic_string<Char> 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(Char) + 1) * CHAR_BIT;
            size_t r= s.length();
            size_t wi= 1;
            cout<< "[hash<basic_string> MS="<< MS<< " for string of size:"<< r<< "]"<< flush;
            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; }
            }
            cout<< "[hash::return "<< r<< "]"<< flush;




















            return r;
        }    
    };
    











}







    #endif // gcc
#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
#define CXXOMFORT_STRING_HPP
/**
 * @file cxxomfort/string.hpp
 * @brief Implementations and additions tied to <code><string></code>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c to_string() (@ref std_to_string )(C++11)
 * * @c strtoll() , @c strtoull() function family (C++11)
 * 
 * Future / potential interfaces:
 * 
 * * @c string user-defined literal
 * 
 * @see https://en.cppreference.com/w/cpp/header/string
................................................................................
 *
 */



#include "base.hpp"
#include <iostream>
#include <string>
#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>

    // GCC already has a specialization for string, wstring
    #if (CXXOMFORT_COMPILER_ID != CXXO_COMPILERID_GCC)
namespace std {

    template<typename Char> 
    struct hash< ::std::basic_string<Char> > {
        typedef ::std::basic_string<Char> 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(Char) + 1) * CHAR_BIT;
            size_t r= s.length();
            size_t 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;
        }    
    };
    
}
    #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


#endif

Added cxxomfort/cxxomfort/string_view.hpp.





































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

#if (CXXOMFORT_CXX_STD < 2017)
#include "impl/17-string_view.hpp"

namespace std {
    using cxxomfort::cxxostd::basic_string_view;
    using cxxomfort::cxxostd::string_view;
    using cxxomfort::cxxostd::wstring_view;
#if (CXXOMFORT_CXX_STD >= 2011)
    using cxxomfort::cxxostd::u16string_view;
    using cxxomfort::cxxostd::u32string_view;
#endif
}

#endif
#endif

Changes to cxxomfort/cxxomfort/system_error.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
78
79









































































































80
81
82
83
84
85
86
..
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
...
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
...
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












 * * @c #errc
 * * @c error_category , @c generic_eror() , @c system_error()
 * * @c error_condition
 * 
 * 
 */















#if (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
#include CXXO_INCLUDE_SYS(system_error)
#endif




#include "library/typesafe_enum.hpp"

#include "impl/11-addressof.hpp"
#include "impl/11-to_string.hpp"
#include <functional> // std::less
#include <stdexcept>
#include <string>
#include <cstring> // strerror
#include <cerrno>


#if (defined(DOXIGEN_DOC) || (CXXOMFORT_CXX_STD < 2011))

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








namespace cxxomfort {
namespace cxxostd {

class error_category;
class error_code;
class error_condition;

const error_category& generic_category() CXXO_NOEXCEPT;
const error_category& system_category() CXXO_NOEXCEPT;


//
// errc and helpers
//


namespace {
struct myerrc{ enum type { 

#if 0
#elif defined(POSIX)
    #include "impl/errc-posix.hpp"
#elif defined(__MSC_VER)
    #include "impl/errc-win.hpp"


#endif

};
};

} // ~anonymous

/**
 * @brief Enumerated type that saves the various POSIX error values
 * @see https://en.cppreference.com/w/cpp/error/errc
 */
typedef cxxomfort::library::typesafe_enum<myerrc,int> errc;

template <typename T> struct is_error_code_enum 
: public std::false_type {};

template<> struct is_error_code_enum <errc>



: public std::true_type {};


//
// error_condition and helpers
//











































































































// std::error_condition is a platform-independent error code. 
/**
 * @brief C++ provided platform-independent error code.
 * 
 * An @c error_condition encapsulates an error code as 
................................................................................
 * Standard Library; cxxomfort provides them only for header 
 * compatibility but in C++03 mode they are not used, 
 * with the exception of @c errc .
 * 
 * */
class error_condition {
    public:



    


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

    #if (CXXOMFORT_CXX_STD < 2011)
    : v_error(e.v_error), p_category(e.p_category) {}
    #else
    = default
    #endif
    ;


    int value () const CXXO_NOEXCEPTNOTHROW { return v_error; }
    error_category const& category () const CXXO_NOEXCEPTNOTHROW { return *p_category; }
    std::string message () const;


    friend bool operator== (error_condition const& l, error_condition const& r) CXXO_NOEXCEPTNOTHROW;
    friend bool operator< (error_condition const& l, error_condition const& r) CXXO_NOEXCEPTNOTHROW;


    private:
    int v_error;
    error_category const* p_category;
};


bool operator==( const error_condition& lhs, const error_condition& rhs ) CXXO_NOEXCEPTNOTHROW {
    return (lhs.v_error == rhs.v_error) && (lhs.p_category == rhs.p_category);
}

bool operator!=( const error_condition& lhs, const error_condition& rhs ) CXXO_NOEXCEPTNOTHROW {
    return !(lhs==rhs);
}


//
// error_category and helpers
//

/**
 * @brief Describes an error category (a classification of sources for errors).
 * @see https://en.cppreference.com/w/cpp/error/error_category
 * 
 * The objects of @c error_category classes are treated as singletons, passed by reference. 
 */


class error_category {

    public:
    
    CXXO_CONSTEXPR error_category() CXXO_NOEXCEPTNOTHROW
    :in_name("error_category")
    {};



    #if (CXXOMFORT_CXX_STD<2011)
    private:
    error_category (error_category const&); 
    public:
    #else
    error_category( error_category const& ) = delete;
	#endif
    
    virtual ~error_category () {};
    
    #if (CXXOMFORT_CXX_STD<2011)
    private:
    error_category& operator= (error_category const&);
    public:
    #else
    error_category& operator= (error_category const&) = delete;
    #endif
    
    virtual const char* name () const CXXO_NOEXCEPTNOTHROW = 0;

    virtual std::string message (int condition ) const = 0;
    
    virtual error_condition default_error_condition (int code ) const CXXO_NOEXCEPT {
        return error_condition(code, *this);

    }



    virtual bool equivalent (int code, error_condition const& condition ) const CXXO_NOEXCEPT {
        return default_error_condition(code) == condition;
    };



    friend bool operator== (error_category const&, error_category const&) CXXO_NOEXCEPT;
    friend bool operator< (error_category const&, error_category const&) CXXO_NOEXCEPT;

    private:
    const char* const in_name;

};

bool operator== (error_category const& e1, error_category const& e2) CXXO_NOEXCEPT {
    return std::addressof(e1)==std::addressof(e2);
}

bool operator< (error_category const& e1, error_category const& e2) CXXO_NOEXCEPT {
    return std::less<error_category const*>()(std::addressof(e1), std::addressof(e2));
}


struct generic_category_t 

: public error_category{
    ~generic_category_t () {}

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


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

struct system_category_t 
: public error_category{
    ~system_category_t () {}



    const char* name () const CXXO_NOEXCEPTNOTHROW {
        return "system";

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

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




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

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

























    //! Returns the value of the error code.
    int value () const CXXO_NOEXCEPTNOTHROW { return V; }
    //! Returns the category of the error code.
    error_category const& category () const CXXO_NOEXCEPTNOTHROW { return *C; }
    //! Returns the composed message for the error code.
    std::string message () const { return category().message(value()); }
    //! Checks if the error value is set.
    operator bool () const { return value() != 0; }
    
    //! Assigns a new value.
    void assign (int err, error_category const& ecat ) CXXO_NOEXCEPTNOTHROW {
        V= err;
        C= &ecat;
    }
    
    //! Sets the error code to @c 0  in @c system_category .
    void clear () CXXO_NOEXCEPTNOTHROW {
        V= 0;
        C= &system_category();
    }

    error_condition default_error_condition () const CXXO_NOEXCEPTNOTHROW {
        return category().default_error_condition(value());
    }


    
    // comparison operators
    
    friend bool operator== (error_code const& e1, error_code const& e2) CXXO_NOEXCEPTNOTHROW ;
    friend bool operator< (error_code const& e1, error_code const& e2) CXXO_NOEXCEPTNOTHROW ;






    private:
    int V;
    error_category const* C;
    
};

bool operator== (error_code const& e1, error_code const& e2) CXXO_NOEXCEPTNOTHROW {
    return e1.C==e2.C && e1.V==e2.V; 
}




bool operator!= (error_code const& e1, error_code const& e2) CXXO_NOEXCEPTNOTHROW {
    return !(e1==e2);









}





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

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





//
// exceptions
//

class system_error
................................................................................
}}

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

#endif // c++11


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

    #if (CXXOMFORT_CXX_STD>=2011)
    #elif (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
    #else
        
        
namespace std {

    using cxxomfort::cxxostd::errc;
    using cxxomfort::cxxostd::make_error_code;
    using cxxomfort::cxxostd::is_error_code_enum;

    using cxxomfort::cxxostd::error_category;
    using cxxomfort::cxxostd::system_category;
    using cxxomfort::cxxostd::generic_category;

    using cxxomfort::cxxostd::error_condition;

    
    using cxxomfort::cxxostd::error_code;
    
    using cxxomfort::cxxostd::system_error;
    
}
    #endif // std

#endif // using std















#endif



















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


|

>
>
>

>


<




>






>
>
>
>
>
>
>




<

<
<
<
<
<





<
<



|

|

>
>


|
<

<










|
>
>
>
|

>



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







 







>
>
>
|
>
>
|
|


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

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

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


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

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







 







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

|







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



>
>



|
|
>
>
>
>








<
<
|
>
>
>

<
|
>
>
>
>
>
>
>
>
>



>
>
>







>
>
>







 







>










>









>







|


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

>
>
>
>
>
>
>
>
>
>
>
>
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
...
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
...
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
...
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
 * * @c #errc
 * * @c error_category , @c generic_eror() , @c system_error()
 * * @c error_condition
 * 
 * 
 */


/*
 * MSVC 2010 has a broken <system_error> that defines errc inside a 
 * namespace also called errc, making it impossible to 
 * declare variables of type std::errc.
 * 
 * Because of this, in the case of MSVC 2010 specifically, 
 * we probably should be overriding the native <system_error> in config/msc.hpp
 * 
 * */
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && defined(_SYSTEM_ERROR_) && !defined(CXXO_MSVC_PATCH_system_error))
//    #error "oopsie! Patch <system_error> or add cxxomfort/config/msc/ to include path"
#endif

#if (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
#include CXXO_INCLUDE_SYS(system_error)
#else


#include <cxxomfort/base.hpp>
#include <cxxomfort/base/explicit_cast.hpp>
#include "library/typesafe_enum.hpp"
#include "impl/relationals.hpp"
#include "impl/11-addressof.hpp"
#include "impl/11-to_string.hpp"

#include <stdexcept>
#include <string>
#include <cstring> // strerror
#include <cerrno>
#include <utility> // make_pair, operator<

#if (defined(DOXIGEN_DOC) || (CXXOMFORT_CXX_STD < 2011))

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

#if defined(__linux__) || defined(__unix__)
    #include <unistd.h> // POSIX
#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
    #include <errno.h>
    #include "impl/errno-msvc.hpp"
#endif

namespace cxxomfort {
namespace cxxostd {


class error_code;






//
// errc and helpers
//



struct myerrc{ enum type { 

#if 0
#elif defined(_POSIX_VERSION)
    #include "impl/errc-posix.hpp"
#elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
    #include "impl/errc-win.hpp"
#else
    #error "Can not find definitions for std::errc codes."
#endif

};  };




/**
 * @brief Enumerated type that saves the various POSIX error values
 * @see https://en.cppreference.com/w/cpp/error/errc
 */
typedef cxxomfort::library::typesafe_enum<myerrc,int> errc;

template <typename T> struct is_error_code_enum 
: public std::false_type {};

template<> struct is_error_code_enum <errc> : public std::true_type {};
// Here we need to specialize for myerrc::type as well
// because the constructors for error_condition and error_code below 
// use SFINAE to match the exact type, before conversion.
template<> struct is_error_code_enum<typename myerrc::type> : public std::true_type {};


//
// error_condition and helpers
//

class error_condition;

template <typename T> struct is_error_condition_enum
: public std::false_type {};

template<> struct is_error_condition_enum<errc> : public std::true_type {};
//See above note
template<> struct is_error_condition_enum<typename myerrc::type> : public std::true_type {};


//
// error_category and helpers
//

class error_category;

static error_category const& generic_category() CXXO_NOEXCEPTNOTHROW;
static error_category const& system_category() CXXO_NOEXCEPTNOTHROW;

//
// declare helpers
//
static error_code make_error_code( errc e ) CXXO_NOEXCEPTNOTHROW;
static error_code make_error_code( errc e , error_category const& ec) CXXO_NOEXCEPTNOTHROW;

//
// error_category and helpers
//

/**
 * @brief Describes an error category (a classification of sources for errors).
 * @see https://en.cppreference.com/w/cpp/error/error_category
 * 
 * The objects of @c error_category classes are treated as singletons, passed by reference. 
 */
class error_category {

    public:

    CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(error_category);
    CXXO_DELETED_COPY_CONSTRUCTOR(error_category);
    virtual ~error_category () {};
    CXXO_DELETED_COPY_ASSIGN(error_category);
    
    virtual const char* name () const CXXO_NOEXCEPTNOTHROW = 0;
    virtual std::string message (int condition ) const = 0;
    
    virtual error_condition 
    default_error_condition (int code ) const CXXO_NOEXCEPTNOTHROW;

    virtual bool 
    equivalent (int code, error_condition const& condition ) const CXXO_NOEXCEPTNOTHROW;
    
    virtual bool 
    equivalent (error_code const& ec, int condition) const CXXO_NOEXCEPTNOTHROW;

    friend bool operator== (error_category const& vl, error_category const& vr) CXXO_NOEXCEPT {
        return &vl == &vr;
    }
    friend bool operator< (error_category const& vl, error_category const& vr) CXXO_NOEXCEPT {
        return &vl < & vr;
    }

    private:

};

CXXO_GENERATE_RELATIONALS0(error_category);

struct generic_category_t : public error_category {
    ~generic_category_t () {}

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

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

struct system_category_t  : public error_category {
    ~system_category_t () {}

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

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




// std::error_condition is a platform-independent error code. 
/**
 * @brief C++ provided platform-independent error code.
 * 
 * An @c error_condition encapsulates an error code as 
................................................................................
 * Standard Library; cxxomfort provides them only for header 
 * compatibility but in C++03 mode they are not used, 
 * with the exception of @c errc .
 * 
 * */
class error_condition {
    public:
    error_condition () CXXO_NOEXCEPTNOTHROW 
    : v_error(0), p_category( &generic_category() ) 
    {}

    CXXO_DEFAULT_COPY_CONSTRUCTOR(error_condition, CXXO_NOTHROW, 
    v_error(v.v_error), p_category(v.p_category) );

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


    // DMC does not support SFINAE-esques in member template it seems
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_DMC)






    template <typename EnumE>
    error_condition (EnumE e) CXXO_NOEXCEPTNOTHROW {
        *this= make_error_condition(e);

    }
#else
    #define CXXO_SIGCONDITION (is_error_condition_enum<EnumE>::value)
    template <typename EnumE CXXO_ENABLEIF_TEMPLATE()>
    error_condition (EnumE e CXXO_ENABLEIF_FUNCTION() ) CXXO_NOEXCEPTNOTHROW 
    {

        // this is fine to do so long as we don't add bases to error_condition
        new (this) error_condition (make_error_condition(e));

    }
    #undef CXXO_SIGCONDITION
#endif


















    void       assign (int val, error_category const& cat ) CXXO_NOEXCEPTNOTHROW {
        v_error= val;
        p_category= &cat;
    }


    void       clear () CXXO_NOEXCEPTNOTHROW {


        v_error= 0;
        p_category= &generic_category();
    }







    










    int        value () const CXXO_NOEXCEPTNOTHROW { return v_error; }
    error_category const& category () const CXXO_NOEXCEPTNOTHROW { return *p_category; }
    std::string message () const;
    


    CXXO_EXPLICIT_OPERATOR(bool) () const CXXO_NOEXCEPT { return v_error; }

    friend bool operator== (error_condition const& l, error_condition const& r) CXXO_NOEXCEPTNOTHROW {
        return (l.p_category == r.p_category && l.v_error == r.v_error);
    }



    friend bool operator< (error_condition const& l, error_condition const& r) CXXO_NOEXCEPTNOTHROW {
        return std::make_pair(l.p_category, l.v_error) < std::make_pair(r.p_category, r.v_error);
    }



    private:

    












    int v_error;
    error_category const* p_category;

    


};




CXXO_GENERATE_RELATIONALS0(error_condition);











//! Creates an @c error_condition of generic category.
static inline 
error_condition make_error_condition ( errc e ) CXXO_NOEXCEPTNOTHROW {

    return error_condition( explicit_cast<int>(e), generic_category() );
}














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

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

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

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

    void       assign (int err, error_category const& ecat) CXXO_NOEXCEPTNOTHROW {
        V= err; C= &ecat;
    }
    
    void       clear () CXXO_NOEXCEPTNOTHROW {
        *this = error_code(0, system_category());
    }
    
    //! Returns the value of the error code.
    int        value () const CXXO_NOEXCEPTNOTHROW { return V; }
    //! Returns the category of the error code.
    error_category const& category () const CXXO_NOEXCEPTNOTHROW { return *C; }
    //! Returns the composed message for the error code.
    std::string message () const { return category().message(value()); }
    //! Checks if the error value is set.
    operator bool () const { return value() != 0; }
    












    error_condition default_error_condition () const CXXO_NOEXCEPTNOTHROW {
        return category().default_error_condition(value());
    }

    CXXO_EXPLICIT_OPERATOR(bool) () const CXXO_NOEXCEPTNOTHROW { return value(); }
    
    // comparison operators
    
    friend bool operator== (error_code const& vl, error_code const& vr) CXXO_NOEXCEPTNOTHROW {
        return vl.category()==vr.category() && vl.value()==vr.value();
    }
    friend bool operator<  (error_code const& vl, error_code const& vr) CXXO_NOEXCEPTNOTHROW {
        return std::make_pair(&(vl.category()),vl.value()) < std::make_pair(&(vr.category()),vr.value());
    }


    private:
    int V;
    error_category const* C;
    
};




//
// virtuals
//


error_condition error_category::default_error_condition (int code ) const CXXO_NOEXCEPTNOTHROW {
	return error_condition(code, *this);
}

bool error_category::equivalent (int code, error_condition const& condition ) const CXXO_NOEXCEPTNOTHROW {
	return default_error_condition(code) == condition;
};

bool error_category::equivalent (error_code const& ec, int condition) const CXXO_NOEXCEPTNOTHROW {
	return *this == ec.category() && ec.value() == condition;
}


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

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

static error_condition make_error_condition ( errc ) CXXO_NOEXCEPTNOTHROW;



//
// exceptions
//

class system_error
................................................................................
}}

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

#endif // c++11


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

    #if (CXXOMFORT_CXX_STD>=2011)
    #elif (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
    #else
        
        
namespace std {
    
    using cxxomfort::cxxostd::errc;
    using cxxomfort::cxxostd::make_error_code;
    using cxxomfort::cxxostd::is_error_code_enum;

    using cxxomfort::cxxostd::error_category;
    using cxxomfort::cxxostd::system_category;
    using cxxomfort::cxxostd::generic_category;

    using cxxomfort::cxxostd::error_condition;
    using cxxomfort::cxxostd::is_error_condition_enum;
    
    using cxxomfort::cxxostd::error_code;
    
    using cxxomfort::cxxostd::system_error;
    
}
    #endif // std
    
#endif // using std

#endif // system_error



//
// helper function
//

namespace cxxomfort {

#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1600) && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, <1800))
using ::std::errc::errc;
#else
using ::std::errc;
#endif

static inline errc to_errc(int E) {
#if (CXXO_COMPILER_SUPPORT_cstd_system_error==0)
    return static_cast<cxxomfort::cxxostd::myerrc::type>(E);
#else
    return static_cast<errc>(E);
#endif
}

} // cxxomfort

#endif

Changes to cxxomfort/cxxomfort/tuple.hpp.

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "impl/14-tuple_get_type.hpp" // std::get<T> (tuple<>)
#include "impl/17-tuple_apply.hpp" // std::apply (Function, tuple<>)
#include "impl/17-make_from_tuple.hpp" // std::make_from_tuple<T>(tuple<>)

namespace cxxomfort {
namespace cxxostd {

namespace {
    using cxxomfort::library::tuple::is_tuple;
    using cxxomfort::library::tuple::tuple_index;
}


} //cxxomfort::cxxostd
} //

#endif








<
<
<
<
<






27
28
29
30
31
32
33





34
35
36
37
38
39
#include "impl/14-tuple_get_type.hpp" // std::get<T> (tuple<>)
#include "impl/17-tuple_apply.hpp" // std::apply (Function, tuple<>)
#include "impl/17-make_from_tuple.hpp" // std::make_from_tuple<T>(tuple<>)

namespace cxxomfort {
namespace cxxostd {







} //cxxomfort::cxxostd
} //

#endif

Changes to cxxomfort/cxxomfort/various.hpp.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 * 
 * ==No other base cxxomfort feature should depend on these utilities==
 * 
 * Interfaces defined in this file:
 * 
 * * is_any
 * * is_pair
 * * integer_of_size
 * * static_and, static_or
 * * function_arity
 * * result_of_function
 * * invoke_tuple_t
 * 
 */








<







8
9
10
11
12
13
14

15
16
17
18
19
20
21
 * 
 * ==No other base cxxomfort feature should depend on these utilities==
 * 
 * Interfaces defined in this file:
 * 
 * * is_any
 * * is_pair

 * * static_and, static_or
 * * function_arity
 * * result_of_function
 * * invoke_tuple_t
 * 
 */