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

Overview
Comment:Commit 2017-12-19 - Transparent headers and typesafe enum.
  • cxxomfort: Added cstddef.hpp and its transparent header mirror.
  • cxxomfort: Added random.hpp and its transparent header mirror.
  • cxxomfort: Corrected CXXOMFORT_NOTICES in various headers.
  • config: Improved detection of MSVC 2015 (ver 1900) C++ support.
  • config: Improved detection of C++17 mode.
  • library: Added typesafe_enum.
  • random: Renames of the functors in C++03 according to C++11.
  • PENDING: cstddef: Adding std::byte from C++17.
  • PENDING: functional: Fixes to functors, adding not_fn.
  • PENDING: in_place tag for experimental::optional.
  • PENDING: library: strsprintf.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d2fcaba9dee2d82c521d3cd27f31243d83a13189
User & Date: luismachuca 2017-12-19 03:32:12
Context
2017-12-24
20:55
Commit 2017-12-24 - Multuple [sic] improvements with a byte of Saturnalia.
  • cxxomfort: Added <algorithm>, <functional>, <iterator>, <utility> cstd forward headers.
  • cxxomfort: Added <cstdint> cstd forward header.
  • cstddef: Added byte from c++17.
  • library: Added the count_frequencies algorithms.
  • library: Fixed the 7-, 8-, and 9-argument c++03 signatures for to_string.
  • library: Library Utilities in <tuple.hpp> moved to the proper <library/tuplefn.hpp> header.
  • library: Added 6-, 7- and 8- tuple arguments overloads to tuple_pop, tuple_shift.
  • library: Added tuple_visit(function, tuple) (aka foreach for tuples).
  • tuple: Fixed tuple_apply(function,tuple) to correspond as a c++17 backport.
  • tuple: Added make_from_tuple from c++17 (it only works on actual tuples in c++03, c++11).
  • PENDING: library: Add tuple_if
check-in: 0c1dc33f user: luismachuca tags: trunk
2017-12-19
03:32
Commit 2017-12-19 - Transparent headers and typesafe enum.
  • cxxomfort: Added cstddef.hpp and its transparent header mirror.
  • cxxomfort: Added random.hpp and its transparent header mirror.
  • cxxomfort: Corrected CXXOMFORT_NOTICES in various headers.
  • config: Improved detection of MSVC 2015 (ver 1900) C++ support.
  • config: Improved detection of C++17 mode.
  • library: Added typesafe_enum.
  • random: Renames of the functors in C++03 according to C++11.
  • PENDING: cstddef: Adding std::byte from C++17.
  • PENDING: functional: Fixes to functors, adding not_fn.
  • PENDING: in_place tag for experimental::optional.
  • PENDING: library: strsprintf.
check-in: d2fcaba9 user: luismachuca tags: trunk
2017-08-11
18:12
Commit 2017-08-11 - Emulation detection fixes (c++0x, c++1y).
  • cxxomfort: Implement a listing of CXXOMFORT_IMPLEMENTS_nxxxx macros.
  • cxxomfort: General fixes to ensure GCC 4.6 compatibility.
  • cxxomfort: Improvements to detection of "c++1y" support (__cplusplus == 2013 or similar).
  • algorithm: Correction to transform_inplace (wrong typename).
  • algorithm: Fixed detection of all_of algorithms in C++0x emulation mode.
  • functional: move functional's fixes for MSVC C++03 to its own header.
  • memory: Fixed detection of required backports in MSVC 2010 (which provides __alignof but doesn't announce it).
  • string: Fixed detection of required backports in MSVC 2010 (which provides a borked to_string).
  • string: Added r_trim, l_trim, trim generics for basic_strings.
  • type_traits: Fixed detection of common_type support.
  • utility: Fixed detection of declval support.
  • extras: Added observer_ptr proposal (n3840).
  • extras: Reimplemented extras::optional, more in line with std::experimental proposal status.
  • tags: Added tags for some free functions made available.
check-in: ef968a6c user: luismachuca tags: trunk
Changes

Changes to cxxomfort/cxxomfort/LICENSE.txt.

1
2
3
4
5
6
7
8
9
cxxcomfort Library for C++
Copyright (c) 2012,2013 Luis Machuca Bezzaza and various authors

Permission is hereby granted, free of charge, to any person obtaining 
a copy of this software and associated documentation 
files (the "Software"), to deal in the Software without restriction, 
including without limitation the rights to use, copy, modify, merge, 
publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, 

|







1
2
3
4
5
6
7
8
9
cxxcomfort Library for C++
Copyright (c) 2012,2017 Luis Machuca Bezzaza and various authors

Permission is hereby granted, free of charge, to any person obtaining 
a copy of this software and associated documentation 
files (the "Software"), to deal in the Software without restriction, 
including without limitation the rights to use, copy, modify, merge, 
publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, 

Changes to cxxomfort/cxxomfort/README.txt.

1
2
3
4
5
6
7
8
9
10
11
..
33
34
35
36
37
38
39



















40
41
42
43
cxxcomfort Library for C++
--------------------------

C++ backports of nifty C++11 utilities (and more)
by Luis Machuca Bezzaza

Cxxomfort is a small, header-only library that backports features from more recent C++ Standards to previous ones, for example C++11 features are backported to C++03.

It was written to facilitate my working with the evolving C++ standard as I was getting back into the language, but it evolved to fulfill a more general purpose. 

It is intended to reduce the amount and stress of code rewrite while at the same time assisting in backwards and forwards portability of code.
................................................................................
Check the repository's web page as well as the 
C++ Reference wiki for information of various features that this 
library can provide:

* cxxomfort -- http://ryan.gulix.cl/fossil.cgi/cxxomfort/
* C++ Reference -- http://en.cppreference.com/




















License
-------

Read LICENSE.txt



|







 







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




1
2
3
4
5
6
7
8
9
10
11
..
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
cxxcomfort Library for C++
--------------------------

C++ backports of the nifty utilities from C++11 and onwards
by Luis Machuca Bezzaza

Cxxomfort is a small, header-only library that backports features from more recent C++ Standards to previous ones, for example C++11 features are backported to C++03.

It was written to facilitate my working with the evolving C++ standard as I was getting back into the language, but it evolved to fulfill a more general purpose. 

It is intended to reduce the amount and stress of code rewrite while at the same time assisting in backwards and forwards portability of code.
................................................................................
Check the repository's web page as well as the 
C++ Reference wiki for information of various features that this 
library can provide:

* cxxomfort -- http://ryan.gulix.cl/fossil.cgi/cxxomfort/
* C++ Reference -- http://en.cppreference.com/

Implementations
--------

Among other implemented features, the following can be found:

* nullptr (C++11)
* static_assert (C++11)
* unique_ptr (C++11)
* declval (C++11)
* four-argument equal, mismatch (C++14)
* transparent functors like plus<void> (C++14)
* get<type>(std::tuple) (C++14)
* as_const (C++17)
* observer_ptr (C++17)
* foreach emulation
* brace initialization for containers emulation

More information is available at the official website.

License
-------

Read LICENSE.txt

Changes to cxxomfort/cxxomfort/VERSION.txt.

1
cxxomfort 0.52 2017-07-30
|
1
cxxomfort 0.54 2017-12-19

Changes to cxxomfort/cxxomfort/config.hpp.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
 * @author Luis Machuca Bezzaza
 *
 * This file contains configuration macros used by the cxxomfort library
 * and it is not intended to be directly used.
 */

//! Library version and release date as YYYYMM
#define CXXOMFORT_DATE 201707
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 52

#define CXXO_STRINGIZE_IMPL(x) #x
#define CXXO_STRINGIZE(x) CXXO_STRINGIZE_IMPL(x)
#define CXXO_JOIN(x,y) x##y

//
// Standard Mode
................................................................................
//! If compiler provides support for @c nullptr  and @c std::nullptr_t .
#define CXXO_COMPILER_SUPPORT_nullptr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c T&& .
#define CXXO_COMPILER_SUPPORT_rvref (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c static_assert .
#define CXXO_COMPILER_SUPPORT_static_assert (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for the new C++11 std algorithms.
#define CXXO_COMPILER_SUPPORT_std_cxx11_algorithms 0
//! If compiler provides support for the new C++11 helpers std::begin, std::end.
#define CXXO_COMPILER_SUPPORT_std_iterator_helpers 0
//! If compiler provides support for std::next, std::prev.
#define CXXO_COMPILER_SUPPORT_std_iterator_helpers_next_prev 0
//! If compiler provides support for the new C++11 helpers std::enable_if, std::conditional.
#define CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers 0
//! If compiler provides support for the <code>std::is_[trivially|nothrow]_...</code> traits.
#define CXXO_COMPILER_SUPPORT_std_is_trivially 0
//! If compiler provides support for C++11's 'common_type'.
#define CXXO_COMPILER_SUPPORT_std_cxx11_common_type 0
//! If compiler provides support for the "is_constructible", "is_assignable", and similar traits.
#define CXXO_COMPILER_SUPPORT_std_cxx11_constructible_traits 0
//! If compiler provides support for trailing return types.
#define CXXO_COMPILER_SUPPORT_trailing_returns (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c unique_ptr<T> .
#define CXXO_COMPILER_SUPPORT_unique_ptr 0
//! If compiler provides support for variadic templates.
#define CXXO_COMPILER_SUPPORT_variadic (CXXOMFORT_CXX_STD>=2011)

//! If compiler provides support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)
//! If compiler supports <functional> 's transparent functors.
#define CXXO_COMPILER_SUPPORT_functional_transparent (CXXOMFORT_CXX_STD >= 2014)
................................................................................
    #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 (CXXOMFORT_CXX_STD == 2014)
        #pragma message CXXO_NOTICE("detected C++14 or above mode")
    #elif (CXXOMFORT_CXX_STD == 2011)
        #pragma message CXXO_NOTICE("detected C++11 mode")
    #elif (CXXOMFORT_CXX_STD > 1 && CXXOMFORT_CXX_STD < 2011)
        #pragma message CXXO_NOTICE("detected C++03 or basic mode")
    #endif

................................................................................
    #define CXXOMFORT_CXX14_CODE(cxx14,none) none

#elif (CXXOMFORT_CXX_STD == 2011)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) cxx11
    #define CXXOMFORT_CXX14_CODE(cxx14,none) none


#elif (CXXOMFORT_CXX_STD == 2014)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) none
    #define CXXOMFORT_CXX14_CODE(cxx14,none) cxx14

#endif

//
// Set the local arch name from a series of recognized values







|

|







 







|

|

|

|

|







|







 







|







 







|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
 * @author Luis Machuca Bezzaza
 *
 * This file contains configuration macros used by the cxxomfort library
 * and it is not intended to be directly used.
 */

//! Library version and release date as YYYYMM
#define CXXOMFORT_DATE 201712
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 54

#define CXXO_STRINGIZE_IMPL(x) #x
#define CXXO_STRINGIZE(x) CXXO_STRINGIZE_IMPL(x)
#define CXXO_JOIN(x,y) x##y

//
// Standard Mode
................................................................................
//! If compiler provides support for @c nullptr  and @c std::nullptr_t .
#define CXXO_COMPILER_SUPPORT_nullptr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c T&& .
#define CXXO_COMPILER_SUPPORT_rvref (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c static_assert .
#define CXXO_COMPILER_SUPPORT_static_assert (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for the new C++11 std algorithms.
#define CXXO_COMPILER_SUPPORT_std_cxx11_algorithms (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for the new C++11 helpers std::begin, std::end.
#define CXXO_COMPILER_SUPPORT_std_iterator_helpers (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for std::next, std::prev.
#define CXXO_COMPILER_SUPPORT_std_iterator_helpers_next_prev (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for the new C++11 helpers std::enable_if, std::conditional.
#define CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for the <code>std::is_[trivially|nothrow]_...</code> traits.
#define CXXO_COMPILER_SUPPORT_std_is_trivially (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for C++11's 'common_type'.
#define CXXO_COMPILER_SUPPORT_std_cxx11_common_type 0
//! If compiler provides support for the "is_constructible", "is_assignable", and similar traits.
#define CXXO_COMPILER_SUPPORT_std_cxx11_constructible_traits 0
//! If compiler provides support for trailing return types.
#define CXXO_COMPILER_SUPPORT_trailing_returns (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 C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)
//! If compiler supports <functional> 's transparent functors.
#define CXXO_COMPILER_SUPPORT_functional_transparent (CXXOMFORT_CXX_STD >= 2014)
................................................................................
    #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 (CXXOMFORT_CXX_STD >= 2014)
        #pragma message CXXO_NOTICE("detected C++14 or above mode")
    #elif (CXXOMFORT_CXX_STD == 2011)
        #pragma message CXXO_NOTICE("detected C++11 mode")
    #elif (CXXOMFORT_CXX_STD > 1 && CXXOMFORT_CXX_STD < 2011)
        #pragma message CXXO_NOTICE("detected C++03 or basic mode")
    #endif

................................................................................
    #define CXXOMFORT_CXX14_CODE(cxx14,none) none

#elif (CXXOMFORT_CXX_STD == 2011)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) cxx11
    #define CXXOMFORT_CXX14_CODE(cxx14,none) none


#elif (CXXOMFORT_CXX_STD >= 2014)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) none
    #define CXXOMFORT_CXX14_CODE(cxx14,none) cxx14

#endif

//
// Set the local arch name from a series of recognized values

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

137
138
139
140
141
142
143


144
145
146
147
148
149
150
    #endif
#endif

#if (CXXOMFORT_COMPILER_VERSION >= 407)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        #undef  CXXO_COMPILER_SUPPORT_constexpr
        #define CXXO_COMPILER_SUPPORT_constexpr 1


    #endif
#endif

// GCC 4.8 onwards set up support for C++14 (--std=c++1y or --std=c++14)

#if (CXXOMFORT_CXX_STD == 2013)
    #define CXXOMFORT_CXX_EMULATION 2014







>
>







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    #endif
#endif

#if (CXXOMFORT_COMPILER_VERSION >= 407)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        #undef  CXXO_COMPILER_SUPPORT_constexpr
        #define CXXO_COMPILER_SUPPORT_constexpr 1
        #undef  CXXO_COMPILER_SUPPORT_integer_sequence
        #define CXXO_COMPILER_SUPPORT_integer_sequence 1
    #endif
#endif

// GCC 4.8 onwards set up support for C++14 (--std=c++1y or --std=c++14)

#if (CXXOMFORT_CXX_STD == 2013)
    #define CXXOMFORT_CXX_EMULATION 2014

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

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85






















86
87
    #define CXXO_COMPILER_SUPPORT_std_cxx11_algorithms 1
    #undef  CXXO_COMPILER_SUPPORT_std_cxx11_constructible_traits
    #define CXXO_COMPILER_SUPPORT_std_cxx11_constructible_traits 1
    #undef  CXXO_COMPILER_SUPPORT_std_iterator_helpers
    #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_alignof
//    #define CXXO_COMPILER_SUPPORT_alignof 1
    #undef  CXXO_COMPILER_SUPPORT_unique_ptr
    #define CXXO_COMPILER_SUPPORT_unique_ptr 1
    
#endif

// -- TODO -- get my claws on a MSVC 2012























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







|
|





|

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


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
    #define CXXO_COMPILER_SUPPORT_std_cxx11_algorithms 1
    #undef  CXXO_COMPILER_SUPPORT_std_cxx11_constructible_traits
    #define CXXO_COMPILER_SUPPORT_std_cxx11_constructible_traits 1
    #undef  CXXO_COMPILER_SUPPORT_std_iterator_helpers
    #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

#if (CXXOMFORT_COMPILER_VERSION >= 190) // VC 2015 or higher
    #undef  CXXO_COMPILER_SUPPORT_alignment_tools
    #define CXXO_COMPILER_SUPPORT_alignment_tools 1
    #undef  CXXO_COMPILER_SUPPORT_alignof 
    #define CXXO_COMPILER_SUPPORT_alignof 1
    #undef  CXXO_COMPILER_SUPPORT_attribute
    #define CXXO_COMPILER_SUPPORT_attribute 1
    #undef  CXXO_COMPILER_SUPPORT_constexpr
    #define CXXO_COMPILER_SUPPORT_constexpr 1
    #undef  CXXO_COMPILER_SUPPORT_explicit_operator
    #define CXXO_COMPILER_SUPPORT_explicit_operator 1
    #undef  CXXO_COMPILER_SUPPORT_integer_sequence
    #define CXXO_COMPILER_SUPPORT_integer_sequence 1
    #undef  CXXO_COMPILER_SUPPORT_variadic
    #define CXXO_COMPILER_SUPPORT_variadic 1
    
    
    

#endif


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

Changes to cxxomfort/cxxomfort/cstd/cstddef.

1
2
3
4
5
6

7
8
9

10
#ifndef CXXOMFORT_STD_CSTDDEF
#define CXXOMFORT_STD_CSTDDEF
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"

#include CXXO_INCLUDE_SYS(cstddef)
#include "../base/nullptr.hpp"
#include "../base/static_assert.hpp"

#endif






>

|
|
>

1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_STD_CSTDDEF
#define CXXOMFORT_STD_CSTDDEF
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../cstddef.hpp"
#include CXXO_INCLUDE_SYS(cstddef)
//#include "../base/nullptr.hpp"
//#include "../base/static_assert.hpp"
//#include "../impl/17-byte.hpp"
#endif

Added cxxomfort/cxxomfort/cstd/random.



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
#ifndef CXXOMFORT_STD_RANDOM
#define CXXOMFORT_STD_RANDOM
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../random.hpp"
#include CXXO_INCLUDE_SYS(random)
#endif

Added cxxomfort/cxxomfort/cstddef.hpp.



































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef CXXOMFORT_CSTDDEF_HPP
#define CXXOMFORT_CSTDDEF_HPP
/**
 * @file cxxomfort/cstddef.hpp
 * @brief <cstddef> wrapper
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 *
 */

#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include "base/nullptr.hpp"
#include "base/static_assert.hpp"
//#include "impl/17-byte.hpp" // c++17's "byte"
#include CXXO_INCLUDE_SYS(cstddef)
#endif

Changes to cxxomfort/cxxomfort/cxxomfort.hpp.

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
#include "config.hpp"

//
// Main Features
//
// (pending minor reorganization as of v0.49)
#include "base.hpp"

#include "algorithm.hpp" // <algorithm> additions (copy_if, minmax, etc...)

#include "cstdint.hpp" // <cstdint> wrapper (integer types)

#include "functional.hpp" // <functional> additions (transparent functors, etc)
#include "limits.hpp" // compile-time integral limits
#include "memory.hpp" // <memory> additions (pointer_traits, alignof, unique_ptr, etc...)
#include "util/type_traits.hpp" // basic type_traits
#include "impl/regex-esc.hpp" // CXXO_R for raw regex patterns
#include "utility.hpp" // declval, exchange, pair...

#include "string.hpp" // string function helpers (eg.: to_string)

#include "type_traits.hpp" // common_type, decay, is_literal, is_null_pointer, ...

#include "library.hpp" // cxxomfort library features
#include "sequences.hpp" // sequence helpers, seq_<T>()
#include "using.hpp"





/**
 * @page cxx03-backports
 * @brief Features that are backported to C++03.
 */

/**
 * @page cxx11-backports
 * @brief Features that are backported to C++11.
 */

#endif








>

>

>
|


<
<
<
>

>
|
>


<
<
<
>
>













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
#include "config.hpp"

//
// Main Features
//
// (pending minor reorganization as of v0.49)
#include "base.hpp"
#include "using.hpp"
#include "algorithm.hpp" // <algorithm> additions (copy_if, minmax, etc...)
#include "cstddef.hpp" // <cstddef> additions (byte, nullptr, etc...)
#include "cstdint.hpp" // <cstdint> wrapper (integer types)
#include "forward_list.hpp" // <forward_list>
#include "functional.hpp" // <functional> additions (transparent functors, etc...)
#include "limits.hpp" // compile-time integral limits
#include "memory.hpp" // <memory> additions (pointer_traits, alignof, unique_ptr, etc...)



#include "random.hpp" // <random> additions (rename fixes, std::random_device, etc...)
#include "string.hpp" // string function helpers (eg.: to_string)
#include "tuple.hpp" // tuple helpers, tuple get<type>, ...
#include "type_traits.hpp" // common_type, decay, is_literal, is_null_pointer, etc...
#include "utility.hpp" // declval, exchange, pair...
#include "library.hpp" // cxxomfort library features
#include "sequences.hpp" // sequence helpers, seq_<T>()



#include "util/type_traits.hpp" // basic type_traits
#include "impl/regex-esc.hpp" // CXXO_R for raw regex patterns

/**
 * @page cxx03-backports
 * @brief Features that are backported to C++03.
 */

/**
 * @page cxx11-backports
 * @brief Features that are backported to C++11.
 */

#endif

Changes to cxxomfort/cxxomfort/forward_list.hpp.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


33
34
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
..
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
...
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
...
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
 * @file cxxomfort/extras/forward_list.hpp
 * @brief Implements C++11's "forward_list" in C++03.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
 * * forward_list (from C++11)
 * 
 * This header contains a partial implementation of C++11's 
 * "forward_list" sequence container based off my old code for a former 
 * "ListaEnlazada" class.
 * 
 * To invoke this in a standard manner, the header @c <forward_list> is 
 * provided in cstd/ directory.
 * 
 * 
**/
// An implementation of forward_list<> based off 
// my former ListaEnlazada class.
//
// Dependencies:
//  * cxxomfort
//  * allocator_traits en TR1

#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <stdexcept>
#include <iterator>
#include <memory>



namespace cxxomfort {

namespace detail_fwlist {
    struct sl_node_base { 
        sl_node_base *next;
        sl_node_base () : next(nullptr) {}
        sl_node_base (sl_node_base * p) : next(p) {}
    };
    template <typename T> struct sl_node;
    template <typename T, bool> class iterator_base;
}

/**
 * @brief Implementation of C++11's forward_list , made compatible with C++03.
 * @addtogroup forward_list
 * 
 * Differences from the standard's provided:
 * 
 * * Operator move-assignment is not available.
 * * Members merge, sort, unique and resize are not yet available.
 * * A member push_back is provided, which allows for tail insertion in O(1) time.
 * * Relational operators other than (in)equality are not provided.
 * 
 */

template <typename T, typename A = std::allocator<T> >
class forward_list {
    private:
    typedef detail_fwlist::sl_node_base   node_t;
    typedef detail_fwlist::sl_node<T>     nodeT_t;
................................................................................
    typedef typename std::allocator_traits<A>::pointer pointer;
    typedef typename std::allocator_traits<A>::const_pointer const_pointer;
    typedef detail_fwlist::iterator_base<T,false>    iterator;
    typedef detail_fwlist::iterator_base<T,true>     const_iterator;

    private:
    CXXO_COPYABLE_MOVABLE(forward_list);
    
    public:
    forward_list () CXXO_NOEXCEPT;                //< default-ctor
    forward_list (forward_list const&);           //< copy-ctor
    forward_list (forward_list const&, A const&); //< realloc copy constructor
    explicit forward_list 
    (size_t, T const& t= T(), A const& a = A());  //< element-ctor
    template <typename I> forward_list 
    (I, I, A const& a = A());                     //< sequence-ctor
    forward_list (CXXO_RV_REF(forward_list));     //< move-ctor
#if defined(CXXOMFORT_CXX11_MODE)
    explicit forward_list (std::initializer_list<T> const&);          //< init-list-ctor
#endif
    ~forward_list ();                             //< destructor

    forward_list& operator= 
    (CXXO_COPY_ASSIGN_REF(forward_list));                   //< copy-assignment
    forward_list& operator= (CXXO_RV_REF(forward_list));    //< move-assignment
#if defined(CXXOMFORT_CXX11_MODE)
    forward_list& operator= (init_list_t);        //< init-list assignment
#endif

    void  assign (size_type, T const&); //< assign multiple copies of a value
    template <typename Iterator>
    void  assign (Iterator,Iterator);   //< assign a sequence
#if defined(CXXOMFORT_CXX11_MODE)
    void  assign (std::initializer_list<T> const&);    //< assign a init-list
#endif
    
    allocator_type  get_allocator () const;  //< direct access to allocator
    
    bool       empty () const;          //< check if empty
    //size_t     size () const;           //< current size; not in std
    size_type  max_size () const;       //< max size

    const_reference front () const;     //< direct access to front
    reference       front ();           //< direct access to front
    
    const_iterator  cbegin () const CXXO_NOEXCEPT;     //< read-only iteration from begin
    const_iterator  begin ()  const CXXO_NOEXCEPT { return cbegin(); }
    const_iterator  cend ()   const CXXO_NOEXCEPT;     //< read-only iteration mark end
    const_iterator  end ()    const CXXO_NOEXCEPT { return cend(); }
    iterator        begin () CXXO_NOEXCEPT;            //< mutating iteration from begin
    iterator        end ()   CXXO_NOEXCEPT;            //< mutating iteration mark end
    
    //const_iterator  cbefore_begin () const;  //< read-only iteration mark before begin
    const_iterator  before_begin () const CXXO_NOEXCEPT;    //< read-only iteration mark before begin
    iterator        before_begin () CXXO_NOEXCEPT;          //< mutating iteration mark before begin

    void  push_front (T const&);        //< insert at begin
    void  push_front (CXXO_RV_REF(T));  //< insert at begin (by move)
    void  push_back (T const&);         //< insert at end, constant time; not in std
................................................................................

    void       clear ();                //< erase everything - return to defaulted state
    void       swap (forward_list&);    //< swap contents with another list

#if 0 // pending
    void       resize (size_type);
    void       resize (size_type, T const&);
    
    void  merge (forward_list&);
    void  merge (CXXO_RV_REF(forward_list));
    template <typename Compare>
    void  merge (forward_list&, Compare);
    template <typename Compare>
    void  merge (CXXO_RV_REF(forward_list), Compare);
    
    void  splice (const_iterator, forward_list&);
    void  splice (const_iterator, forward_list&, const_iterator src);
    void  splice (const_iterator, forward_list&, const_iterator ini, const_iterator fin); 
#endif

    void       splice_after (const_iterator, forward_list &); // 1
    void       splice_after (const_iterator, forward_list &, const_iterator); // 2
    
    void       remove (T const&);
    template <typename Cond>
    void       remove_if (Cond c);

#if 0 // pending
    void  sort ();  
    template <typename Compare>
    void  sort (Compare);

    void  reverse ();
    
    void  unique ();
    template <typename Compare>
    void  unique (Compare);
#endif    

    private:
    node_t          _p_bb, *_p_last;
    node_alloc_t    alloc;

    static nodeT_t *N (node_t* p) { return static_cast<nodeT_t*>(p); }
    static node_t  *U (nodeT_t *p) { return static_cast<node_t*>(p); }
................................................................................

    template <typename I> void in_uninitialized_copy(I,I);

    void            in_uninitialized_fill_n (size_t, T const&);
    void            in_link_after (node_t*, node_t*);
    void            in_readjust_last ();
    node_t*    in_destroy (nodeT_t*);
    
} /* forward_list */ ;

template <typename T1, typename A1, typename T2, typename A2>
bool operator== (forward_list<T1,A1> const& a, forward_list<T2,A2> const& b);

template <typename T1, typename A1, typename T2, typename A2>
bool operator!= (forward_list<T1,A1> const& a, forward_list<T2,A2> const& b);







|
|
|

|
|

|
|

|











>
>




|











|

|




|







 







|




|

|


|




|


|






|


|

|

<




|






|







 







|






|


|




|





|




|



|







 







|







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
..
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
...
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
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
 * @file cxxomfort/extras/forward_list.hpp
 * @brief Implements C++11's "forward_list" in C++03.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
 * * forward_list (from C++11)
 *
 * This header contains a partial implementation of C++11's
 * "forward_list" sequence container based off my old code for a former
 * "ListaEnlazada" class.
 *
 * To invoke this in a standard manner, the header @c <forward_list> is
 * provided in cstd/ directory.
 *
 *
**/
// An implementation of forward_list<> based off
// my former ListaEnlazada class.
//
// Dependencies:
//  * cxxomfort
//  * allocator_traits en TR1

#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <stdexcept>
#include <iterator>
#include <memory>
#include "memory.hpp"
#include "util/memtraits.hpp"

namespace cxxomfort {

namespace detail_fwlist {
    struct sl_node_base {
        sl_node_base *next;
        sl_node_base () : next(nullptr) {}
        sl_node_base (sl_node_base * p) : next(p) {}
    };
    template <typename T> struct sl_node;
    template <typename T, bool> class iterator_base;
}

/**
 * @brief Implementation of C++11's forward_list , made compatible with C++03.
 * @addtogroup forward_list
 *
 * Differences from the standard's provided:
 *
 * * Operator move-assignment is not available.
 * * Members merge, sort, unique and resize are not yet available.
 * * A member push_back is provided, which allows for tail insertion in O(1) time.
 * * Relational operators other than (in)equality are not provided.
 *
 */

template <typename T, typename A = std::allocator<T> >
class forward_list {
    private:
    typedef detail_fwlist::sl_node_base   node_t;
    typedef detail_fwlist::sl_node<T>     nodeT_t;
................................................................................
    typedef typename std::allocator_traits<A>::pointer pointer;
    typedef typename std::allocator_traits<A>::const_pointer const_pointer;
    typedef detail_fwlist::iterator_base<T,false>    iterator;
    typedef detail_fwlist::iterator_base<T,true>     const_iterator;

    private:
    CXXO_COPYABLE_MOVABLE(forward_list);

    public:
    forward_list () CXXO_NOEXCEPT;                //< default-ctor
    forward_list (forward_list const&);           //< copy-ctor
    forward_list (forward_list const&, A const&); //< realloc copy constructor
    explicit forward_list
    (size_t, T const& t= T(), A const& a = A());  //< element-ctor
    template <typename I> forward_list
    (I, I, A const& a = A());                     //< sequence-ctor
    forward_list (CXXO_RV_REF(forward_list));     //< move-ctor
#if (CXXOMFORT_CXX_STD >= 2011)
    explicit forward_list (std::initializer_list<T> const&);          //< init-list-ctor
#endif
    ~forward_list ();                             //< destructor

    forward_list& operator=
    (CXXO_COPY_ASSIGN_REF(forward_list));                   //< copy-assignment
    forward_list& operator= (CXXO_RV_REF(forward_list));    //< move-assignment
#if (CXXOMFORT_CXX_STD >= 2011)
    forward_list& operator= (init_list_t);        //< init-list assignment
#endif

    void  assign (size_type, T const&); //< assign multiple copies of a value
    template <typename Iterator>
    void  assign (Iterator,Iterator);   //< assign a sequence
#if (CXXOMFORT_CXX_STD >= 2011)
    void  assign (std::initializer_list<T> const&);    //< assign a init-list
#endif

    allocator_type  get_allocator () const;  //< direct access to allocator

    bool       empty () const;          //< check if empty

    size_type  max_size () const;       //< max size

    const_reference front () const;     //< direct access to front
    reference       front ();           //< direct access to front

    const_iterator  cbegin () const CXXO_NOEXCEPT;     //< read-only iteration from begin
    const_iterator  begin ()  const CXXO_NOEXCEPT { return cbegin(); }
    const_iterator  cend ()   const CXXO_NOEXCEPT;     //< read-only iteration mark end
    const_iterator  end ()    const CXXO_NOEXCEPT { return cend(); }
    iterator        begin () CXXO_NOEXCEPT;            //< mutating iteration from begin
    iterator        end ()   CXXO_NOEXCEPT;            //< mutating iteration mark end

    //const_iterator  cbefore_begin () const;  //< read-only iteration mark before begin
    const_iterator  before_begin () const CXXO_NOEXCEPT;    //< read-only iteration mark before begin
    iterator        before_begin () CXXO_NOEXCEPT;          //< mutating iteration mark before begin

    void  push_front (T const&);        //< insert at begin
    void  push_front (CXXO_RV_REF(T));  //< insert at begin (by move)
    void  push_back (T const&);         //< insert at end, constant time; not in std
................................................................................

    void       clear ();                //< erase everything - return to defaulted state
    void       swap (forward_list&);    //< swap contents with another list

#if 0 // pending
    void       resize (size_type);
    void       resize (size_type, T const&);

    void  merge (forward_list&);
    void  merge (CXXO_RV_REF(forward_list));
    template <typename Compare>
    void  merge (forward_list&, Compare);
    template <typename Compare>
    void  merge (CXXO_RV_REF(forward_list), Compare);

    void  splice (const_iterator, forward_list&);
    void  splice (const_iterator, forward_list&, const_iterator src);
    void  splice (const_iterator, forward_list&, const_iterator ini, const_iterator fin);
#endif

    void       splice_after (const_iterator, forward_list &); // 1
    void       splice_after (const_iterator, forward_list &, const_iterator); // 2

    void       remove (T const&);
    template <typename Cond>
    void       remove_if (Cond c);

#if 0 // pending
    void  sort ();
    template <typename Compare>
    void  sort (Compare);

    void  reverse ();

    void  unique ();
    template <typename Compare>
    void  unique (Compare);
#endif

    private:
    node_t          _p_bb, *_p_last;
    node_alloc_t    alloc;

    static nodeT_t *N (node_t* p) { return static_cast<nodeT_t*>(p); }
    static node_t  *U (nodeT_t *p) { return static_cast<node_t*>(p); }
................................................................................

    template <typename I> void in_uninitialized_copy(I,I);

    void            in_uninitialized_fill_n (size_t, T const&);
    void            in_link_after (node_t*, node_t*);
    void            in_readjust_last ();
    node_t*    in_destroy (nodeT_t*);

} /* forward_list */ ;

template <typename T1, typename A1, typename T2, typename A2>
bool operator== (forward_list<T1,A1> const& a, forward_list<T2,A2> const& b);

template <typename T1, typename A1, typename T2, typename A2>
bool operator!= (forward_list<T1,A1> const& a, forward_list<T2,A2> const& b);

Changes to cxxomfort/cxxomfort/impl/03-random_renames.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
..
39
40
41
42
43
44
45
46
47
#ifndef CXXOMFORT_IMPL_RANDOM_RENAMES_HPP
#define CXXOMFORT_IMPL_RANDOM_RENAMES_HPP

#include "./base.hpp"
#include CXXO_INCLUDE_SYS(random)

// fix renamed functors in <random> between C++03 TR1 and C++11
#if (CXXOMFORT_CXX_STD < 2011)
namespace std {
namespace tr1 {

// These are only "good enough to work" fixes.
................................................................................
};


} // namespace tr1
} // namespace std

#endif // fix

#endif



|
|







 







<

1
2
3
4
5
6
7
8
9
10
11
12
..
39
40
41
42
43
44
45

46
#ifndef CXXOMFORT_IMPL_RANDOM_RENAMES_HPP
#define CXXOMFORT_IMPL_RANDOM_RENAMES_HPP

#include "../base.hpp"
//#include CXXO_INCLUDE_SYS(random)

// fix renamed functors in <random> between C++03 TR1 and C++11
#if (CXXOMFORT_CXX_STD < 2011)
namespace std {
namespace tr1 {

// These are only "good enough to work" fixes.
................................................................................
};


} // namespace tr1
} // namespace std

#endif // fix

#endif

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

8
9
10
11
12
13
14

15

16
17
18
19
20
21
22
 * Interfaces defined in this header:
 * 
 * * std::apply (function_type, tuple<...>)
 * 
 */

#if (defined(CXXOMFORT_NOTICES))

    #pragma message CXXO_NOTICE("enabled tuple apply(fn,tuple) implementation")

#endif

#include <cxxomfort/base.hpp>
#include <cxxomfort/utility.hpp> // index_sequence
#include <cxxomfort/various.hpp> // is_tuple
#include <tuple> // ...duh








>

>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * Interfaces defined in this header:
 * 
 * * std::apply (function_type, tuple<...>)
 * 
 */

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled tuple apply(fn,tuple) implementation")
    #endif
#endif

#include <cxxomfort/base.hpp>
#include <cxxomfort/utility.hpp> // index_sequence
#include <cxxomfort/various.hpp> // is_tuple
#include <tuple> // ...duh

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

16
17
18
19
20
21
22

23

24
25
26
27
28
29
30
#define CXXOMFORT_IMPLEMENTS_n3584 CXXO_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n3670 CXXO_EMULATION()

#include <type_traits>
#include <tuple>

#if (defined(CXXOMFORT_NOTICES))

    #pragma message CXXO_NOTICE("enabled tuple get<type> implementation")

#endif


//#define CXXO_TI_STRI0(x) #x
//#define CXXO_TI_STRI(x) CXXO_TI_STRI0(x)

namespace cxxomfort {







>

>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#define CXXOMFORT_IMPLEMENTS_n3584 CXXO_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n3670 CXXO_EMULATION()

#include <type_traits>
#include <tuple>

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


//#define CXXO_TI_STRI0(x) #x
//#define CXXO_TI_STRI(x) CXXO_TI_STRI0(x)

namespace cxxomfort {

Changes to cxxomfort/cxxomfort/impl/forward_list-impl.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
...
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
#ifndef CXXOMFORT_IMPL_FORWARD_LIST_IMPL_HPP
#define CXXOMFORT_IMPL_FORWARD_LIST_IMPL_HPP

#include "../config.hpp"
#include <stdexcept>
#include <iterator>
#include <utility>
#include <memory>
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <cassert>
#include <new>



#define LDEBUG(msg) if (!LDEBUG_ENABLED) {} \
                   else std::cerr << "[forward_list::"<< msg<< " ]"<< std::endl;
#ifndef LDEBUG_ENABLED
    #define LDEBUG_ENABLED 0

#endif

namespace cxxomfort {
namespace detail_fwlist {


template <typename T> struct sl_node
................................................................................
        x= x->next;
    }
}

template <typename T, typename A>
void forward_list<T,A>::remove (T const& t) {
    using namespace std;
    //const std::equal_to<T> eq;
    remove ( bind(equal_to<T>(), placeholders::_1, t) );
}

/*
template <typename T, typename A>
template<typename Comparison>
void forward_list<T,A>::unique (Comparison p) {
    // No need to unique a list with at most one element







|
|





<
>


|
|
>







 







|
|







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
...
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
#ifndef CXXOMFORT_IMPL_FORWARD_LIST_IMPL_HPP
#define CXXOMFORT_IMPL_FORWARD_LIST_IMPL_HPP

#include "../config.hpp"
#include <stdexcept>
#include <iterator>
#include <utility>
#include <functional>
#include <memory>
#include <algorithm>
#include <stdexcept>
#include <cassert>
#include <new>


#ifdef LDEBUG_ENABLED
#define LDEBUG(msg) if (!LDEBUG_ENABLED) {} \
                   else std::cerr << "[forward_list::"<< msg<< " ]"<< std::endl;
#else
#define LDEBUG(msg) 

#endif

namespace cxxomfort {
namespace detail_fwlist {


template <typename T> struct sl_node
................................................................................
        x= x->next;
    }
}

template <typename T, typename A>
void forward_list<T,A>::remove (T const& t) {
    using namespace std;
    const std::equal_to<T> eq;
    remove ( bind(eq, std::placeholders::_1, t) );
}

/*
template <typename T, typename A>
template<typename Comparison>
void forward_list<T,A>::unique (Comparison p) {
    // No need to unique a list with at most one element

Changes to cxxomfort/cxxomfort/library.hpp.

39
40
41
42
43
44
45


46
47
48
49
50
51
52
#include "library/pair03.hpp"
// extra string extensions (join, trim, etc)
#include "library/stringfn.hpp"
// extra tuple extensions (tuple_pop, etc)
#include "library/tuplefn.hpp"
// typename to string helpers - typeid_demangle, type_name
#include "library/type_name.hpp"



/*
 * is_pair
 */
namespace cxxomfort {

}







>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "library/pair03.hpp"
// extra string extensions (join, trim, etc)
#include "library/stringfn.hpp"
// extra tuple extensions (tuple_pop, etc)
#include "library/tuplefn.hpp"
// typename to string helpers - typeid_demangle, type_name
#include "library/type_name.hpp"
// typesafe_enum
#include "library/typesafe_enum.hpp"

/*
 * is_pair
 */
namespace cxxomfort {

}

Changes to cxxomfort/cxxomfort/library/algorithmfn.hpp.

29
30
31
32
33
34
35

36

37
38
39
40
41
42
43
..
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
        if (f(*t)) { return t; }
    }
    return ret;
}

} // .detail::


//! Finds the last item that fulfills @c f .

template <typename Iter, typename Pred>
Iter find_last_if (Iter ini, Iter fin, Pred f) {
    typedef const typename std::iterator_traits<Iter>::iterator_category cat;
    return detail::find_last_if(ini, fin, f, cat());
}


................................................................................
    while (first!=last && pred(*first)) {
        ++ret;
        ++first;
    }
    return ret;
}

//! transform_inplace


template <typename FIter, typename F>
FIter transform_inplace (FIter ini, FIter fin, F f) {
    for (; ini != fin; ++ini) {
        *ini= f(*ini);
    }
    return ini;
}

//! transform elements up to n times
template <typename IIterator, typename OIterator, typename Op, typename Integer>
inline OIterator transform_n (IIterator ini, Integer n, OIterator dest, Op g) {
    for (Integer i(0); i < n; ++i) { *dest= g(*ini); }
    return dest;
}


/**
 * count_frequencies
 * */

} // .algorithm::
}

#endif







>
|
>







 







|
>
>
|
|

|





|
|
|












29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
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
        if (f(*t)) { return t; }
    }
    return ret;
}

} // .detail::

/**
 * @brief Finds the last item that fulfills @c f .
 */
template <typename Iter, typename Pred>
Iter find_last_if (Iter ini, Iter fin, Pred f) {
    typedef const typename std::iterator_traits<Iter>::iterator_category cat;
    return detail::find_last_if(ini, fin, f, cat());
}


................................................................................
    while (first!=last && pred(*first)) {
        ++ret;
        ++first;
    }
    return ret;
}

/**
 * @brief Transform elements in the range in-place via the transformation @a tf .
 */
template <typename FIter, typename TF>
FIter transform_inplace (FIter ini, FIter fin, TF tf) {
    for (; ini != fin; ++ini) {
        *ini= tf(*ini);
    }
    return ini;
}

//! transform elements up to n times
template <typename IIterator, typename OIterator, typename TF, typename Integer>
inline OIterator transform_n (IIterator ini, Integer n, OIterator dest, TF tf) {
    for (Integer i(0); i < n; ++i) { *dest= tf(*ini); }
    return dest;
}


/**
 * count_frequencies
 * */

} // .algorithm::
}

#endif

Changes to cxxomfort/cxxomfort/library/i12n.hpp.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    #pragma message CXXO_NOTICE ("enabled container initialization helper")
    #endif

#include <iterator>
#include <valarray>

namespace cxxomfort {

namespace i12n_detail {

template <typename Container> struct I12N_for {
    typename Container::value_type const* starter;
    typename Container::value_type const* ender;
    template <size_t N>
    explicit I12N_for (typename Container::value_type const (&arr)[N]) 







<







20
21
22
23
24
25
26

27
28
29
30
31
32
33
    #pragma message CXXO_NOTICE ("enabled container initialization helper")
    #endif

#include <iterator>
#include <valarray>

namespace cxxomfort {

namespace i12n_detail {

template <typename Container> struct I12N_for {
    typename Container::value_type const* starter;
    typename Container::value_type const* ender;
    template <size_t N>
    explicit I12N_for (typename Container::value_type const (&arr)[N]) 

Changes to cxxomfort/cxxomfort/library/iteratorfn.hpp.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
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
..
65
66
67
68
69
70
71

72

73
74
75
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <iterator>
#include <functional>
//#include <type_traits>

namespace cxxomfort {


/**
 * constant_iterator
 * iterates over nothing, it just stays "pointing" to the same place
 */
template <typename T>
struct constant_iterator {
................................................................................
    typedef T value_type;
    typedef size_t difference_type;
    typedef T* pointer;
    typedef T& reference;
    
    // "end" state
    constant_iterator () CXXO_NOEXCEPT : v(), b(false) {}
    explicit constant_iterator (T const& t): v(t), b(true) {}
    T const& operator* () const {
        return v.get();
    }
    
    constant_iterator& operator++() { return *this; }
    constant_iterator operator++(int) { return *this; }

    constant_iterator& operator--() { return *this; }
    constant_iterator operator--(int) { return *this; }

    friend bool operator== (constant_iterator const& c1, constant_iterator const& c2) CXXO_NOEXCEPT {
        return (c1.b==c2.b==false) or (c1.b==c2.b==true and c1.v==c2.v);
    }

    friend bool operator!= (constant_iterator const& c1, constant_iterator const& c2) CXXO_NOEXCEPT {
        return !(c1==c2);
    }

    private:
................................................................................
};


template <typename I, typename F>
struct function_iterator {
};




}

#endif







|







 







|




|
|

|
|


|







 







>
|
>



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
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
..
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <iterator>
#include <functional>
//#include <type_traits>

namespace cxxomfort {
namespace iterator {

/**
 * constant_iterator
 * iterates over nothing, it just stays "pointing" to the same place
 */
template <typename T>
struct constant_iterator {
................................................................................
    typedef T value_type;
    typedef size_t difference_type;
    typedef T* pointer;
    typedef T& reference;
    
    // "end" state
    constant_iterator () CXXO_NOEXCEPT : v(), b(false) {}
    explicit constant_iterator CXXO_NOEXCEPT (T const& t): v(t), b(true) {}
    T const& operator* () const {
        return v.get();
    }
    
    constant_iterator& operator++() CXXO_NOEXCEPT { return *this; }
    constant_iterator operator++(int) CXXO_NOEXCEPT { return *this; }

    constant_iterator& operator--() CXXO_NOEXCEPT { return *this; }
    constant_iterator operator--(int) CXXO_NOEXCEPT { return *this; }

    friend bool operator== (constant_iterator const& c1, constant_iterator const& c2) CXXO_NOEXCEPT {
        return (c1.b==false and c2.b==false) or (c1.b==true and c2.b==true and c1.v==c2.v);
    }

    friend bool operator!= (constant_iterator const& c1, constant_iterator const& c2) CXXO_NOEXCEPT {
        return !(c1==c2);
    }

    private:
................................................................................
};


template <typename I, typename F>
struct function_iterator {
};

// iterator
}
// cxxomfort
}

#endif

Added cxxomfort/cxxomfort/library/typesafe_enum.hpp.



























































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#ifndef CXXOMFORT_EXTRAS_SAFEENUM_HPP
#define CXXOMFORT_EXTRAS_SAFEENUM_HPP
/**
 @file cxxomfort/library/safeenum.hpp
 @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>

/*
 * Usage is as follows:
 */
#if 0 // example
struct myenum_def { enum type { member1, member2, member3 }; };
typedef safe_enum<myenum_def> myenum;
// quick and easy encapsulation
#endif

/* Section: declaration of safe_enum */

namespace cxxomfort {

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:
    CXXO_CONSTEXPR typesafe_enum () CXXO_NOEXCEPT {}
    CXXO_CONSTEXPR typesafe_enum(underlying_type v) : val(v) {}
    CXXO_CONSTEXPR inner underlying() const CXXO_NOEXCEPT { return val; }
    CXXO_EXPLICIT_OPERATOR(underlying_type)() const CXXO_NOEXCEPT { return val; }

    friend bool operator == (typesafe_enum const& L, typesafe_enum const& R) CXXO_NOEXCEPT { 
        return R.val == L.val; 
    }
    
    private:
    struct disallowed_enum_conversion {};
    
    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");
    }

};



/*
#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



} // cxxomfort::


/* End section: safe_enum */

/* Begin section: is_scoped_enum */

namespace cxxomfort {

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::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

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

#if 0 && !defined(CXXOMFORT_CXX11_MODE)
namespace std {

template <typename T, typename U>
struct underlying_type< cxxomfort::extras::typesafe_enum<T,U> > {
    private:
    typedef typename cxxomfort::extras::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;
};
} // std::

#endif

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

Changes to cxxomfort/cxxomfort/memory.hpp.

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
#include "impl/make_unique.hpp"




// -- set up needed things in std::

#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC && CXXOMFORT_COMPILER_VERSION<404)
namespace std {namespace tr1 {
    using ::cxxomfort::aligned_storage;
}}
#endif


#if (defined(_MSC_VER) && CXXOMFORT_COMPILER_VERSION<160)
namespace std {namespace tr1 {
    //using ::cxxomfort::aligned_storage;
}}
#endif

#else
#include <memory>
namespace cxxomfort {
    //using std::addressof;
    using std::uninitialized_copy_n;
    using std::aligned_storage;







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







156
157
158
159
160
161
162












163
164
165
166
167
168
169
#include "impl/make_unique.hpp"




// -- set up needed things in std::














#else
#include <memory>
namespace cxxomfort {
    //using std::addressof;
    using std::uninitialized_copy_n;
    using std::aligned_storage;

Added cxxomfort/cxxomfort/random.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
#ifndef CXXOMFORT_RANDOM_HPP
#define CXXOMFORT_RANDOM_HPP
/**
 * @file cxxomfort/random.hpp
 * @brief Fixes and backports from <random>.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
 *
 */

#include "./config.hpp"
#include "./base.hpp"
#include <limits>
#include <random>

//#include <type_traits>
#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
#pragma message CXXO_NOTICE("enabled <random> support.")
#endif

// Fixes for the C++03 names of utilities in <random>
#include "impl/03-random_renames.hpp"
// C++03 approach to random_device
//#include "impl/11-random_device.hpp"


#endif

Changes to cxxomfort/cxxomfort/string.hpp.

10
11
12
13
14
15
16




17
18
19
20
21
22
23
24
25
26
 */


/**
 * @addtogroup string
 * @{
 */





#include "impl/11-to_string.hpp"
#include "impl/to_basic_string_variadic.hpp"
// #include "impl/string.hpp" // custom string functions

/**
 * @}
 */

#endif







>
>
>
>










10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 */


/**
 * @addtogroup string
 * @{
 */

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

#include "impl/11-to_string.hpp"
#include "impl/to_basic_string_variadic.hpp"
// #include "impl/string.hpp" // custom string functions

/**
 * @}
 */

#endif