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

Overview
Comment:Commit 2018-09-22 - Static Library in the Upload
  • random: Added backport for shuffle_order_engine, knuth_b.
  • random: Fixed subtract_with_carry_engine to compile with MSVC.
  • system_error: Added header with minimum capabilities (errc and error_category).
  • type_traits: Moved decay, underlying_type, common_type to their own headers.
  • cstd: Added <system_error> forwarder header.
  • library: Added static math templates to numericfn (static_{min/max/minmax}, etc).
  • library: Added begin, end members to seq_<>, for interoperability.
  • library: Moved non-std functions from cxxomfort::tuple to this set (tuple_pop etc).
  • library: Moved sequence utilities (seq_, etc) to library namespace.
  • library: Moved array_ref from extras.
  • impl/metaprogramming.hpp: Added compose, make_and, make_or.
  • docs: Added lots of comment blocks in the hopes of setting up Doxygen documentation for the future.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2f656bdcbebf5466481d30803d0d1d3d35cc3f57
User & Date: luismachuca 2018-09-23 01:16:40
Context
2018-09-23
05:07
Commit 2018-09-23 - Avoid decay (but not std::decay)
  • config: Fixed detection of MSVC 2008 (wrong version minor).
  • random: Fixed a bug reintroducing the c++03 renames in GCC c++0x mode.
  • type_traits: Fixed an introduced bug in GCC c++0x mode with std::decay already declared.
  • tags: More readability on CXXO_(feature) tags.
check-in: 96a39395 user: luismachuca tags: trunk
01:16
Commit 2018-09-22 - Static Library in the Upload
  • random: Added backport for shuffle_order_engine, knuth_b.
  • random: Fixed subtract_with_carry_engine to compile with MSVC.
  • system_error: Added header with minimum capabilities (errc and error_category).
  • type_traits: Moved decay, underlying_type, common_type to their own headers.
  • cstd: Added <system_error> forwarder header.
  • library: Added static math templates to numericfn (static_{min/max/minmax}, etc).
  • library: Added begin, end members to seq_<>, for interoperability.
  • library: Moved non-std functions from cxxomfort::tuple to this set (tuple_pop etc).
  • library: Moved sequence utilities (seq_, etc) to library namespace.
  • library: Moved array_ref from extras.
  • impl/metaprogramming.hpp: Added compose, make_and, make_or.
  • docs: Added lots of comment blocks in the hopes of setting up Doxygen documentation for the future.
check-in: 2f656bdc user: luismachuca tags: trunk
2018-08-22
04:58
Commit 2018-08-21 - Minmax: Min corrections and Max namespacing
  • config: Introduced namespace 'library' for cxxomfort library extensions.
  • config: Added detection of old-style <functional> binders in preparation for C++20.
  • config: Fixed detection of features in GCC (typeof, enable_if, etc).
  • algorithm: Fixed move minmax, minmax_element to their own header.
  • iterator: Fixed size to be moved to own file and re-implemented as per C++17 std::size.
  • type_traits: Added std::endian support (but unused in this release).
  • type_traits: Added std::bool_constant support.
  • type_traits: Added std::type_identity support.
  • library: Fixed namespacing for CXXO_FOREACH, I12N, variadic to_string, type_name utils, typesafe enum (minor).
  • tags: Updated with library string, algorithm functions.
check-in: d22509b5 user: luismachuca tags: trunk
Changes

Changes to cxxomfort/cxxomfort/algorithm.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
...
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
...
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
#ifndef CXXOMFORT_ALGORITHM_HPP
#define CXXOMFORT_ALGORITHM_HPP
/**
 * @file algorithm.hpp
 * @brief Header file for the <algorithm>-related backports.
 * @ingroup std:algorithm
 */

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


namespace cxxomfort {
/**
 * @namespace
 * @brief Namespace for the <algorithm>-related backports.
 * @sa @ref cxxo:sup:algorithm
 */
namespace algorithm {

/**
 * @ingroup cxx11-backports
 * @ingroup std:algorithm
 * @{
 */

/**
 * @brief Copy elements conditionally to @a dest if they fulfill @a f .
 * @return the advanced @a dest iterator.
 * @anchor copy_if
 * @ref cxx11-backports
 */
template <typename InpI, typename OutI, typename Predicate>
inline OutI copy_if (InpI ini, InpI fin, OutI dest, Predicate f) {
    if (ini != fin) {
        for (; ini != fin; ++ini) {
            if (f(*ini)) { *dest++= *ini; }
        } // for
        
    }
    return dest;
}


//! copy a given amount of elements to @a dest .
//! @return the iterated @a dest iterator.


template <typename InpI, typename Integral, typename OutI>
inline OutI copy_n (InpI ini, Integral n, OutI dest) {
    for (; n --> 0; ++ini, ++dest) {
        *dest= *ini;
    }
    return dest;
}


//! Conditionally copy from sequence <var>[ini,fin)</var> to either sequence starting at @p Dtrue or @p Dfalsef .
//! @return the advanced <code>std::pair</code> (@a Dtrue , @a Dfalse ).


template <typename InpI, typename OutI1, typename OutI2, typename Predicate>
std::pair<OutI1,OutI2> partition_copy (InpI ini, InpI const fin, OutI1 Dtrue, OutI2 Dfalse, Predicate f) {
    for (; ini != fin; ++ini) {
        if (f(*ini)) *Dtrue++= *ini; 
        else *Dfalse++= *ini;
    } // end for
    return std::pair<OutI1,OutI2>(Dtrue,Dfalse);
}


//! Copy like @c copy_if with inverted predicate (for symmetry with @c find_if_not ).


template <typename OutI, typename InpI, typename Pred> inline 
OutI copy_if_not (InpI ini, InpI fin, OutI dest, Pred p) {
    for (; ini != fin; ++ini) { 
        if (!p(*ini)) { *dest= *ini; ++dest; }
    }
}


//! Finds like @c find_if but the predicate is reversed.


template<class It, class Pred>
It find_if_not(It ini, It fin, Pred f) {
    for (; ini != fin; ++ini) {
        if (!f(*ini)) {
            return ini;
        }
    }
................................................................................
    return fin; // < all the elements fulfill f
}

/**
 * @brief Determines if a sequence is sorted according to a given criteria.
 * @param less Criteria for sorting, a binary function f(x,y) that returns @c true if <code>x<y</code>.
 * @return A bool response about if the sequence is sorted.

 */
template <typename Iterator, typename Compare>
inline bool is_sorted (Iterator ini, Iterator fin, Compare less) {
    if (ini == fin) return true;
    Iterator prev= ini++;
    for (; ini != fin; ++ini, ++prev) {
        if (!less(*prev,*ini)) return false;
................................................................................
template <typename Iterator>
inline bool is_sorted (Iterator ini, Iterator fin) {
    std::less<typename std::iterator_traits<Iterator>::value_type> less;
    return is_sorted(ini,fin,less);
}




// detail helpers for shuffle

namespace detail_algorithm {

    template <typename URNG, typename E>
    E uniform_in (URNG& u, E m1, E m2) {
        //typedef typename std::result_of<URNG>::type T;
        E output = m1 + (u() % (E)(m2 - m1 + 1));
        return output;
    }

} // detail_algorithm


/*
 * Shuffles a sequence according to a generator call g().

 * Requires support from <random>.
 * @anchor shuffle
 */

template< class RAIterator, class URNG >
void shuffle( RAIterator ini, RAIterator fin, URNG& g ) {
    typedef typename std::iterator_traits<RAIterator>::difference_type diff_t;
    diff_t n = fin - ini; // guaranteed for RAIterator
    for (diff_t i = n-1; i > 0; --i) {
        using std::swap;
        //swap(ini[i], ini[D(g, param_t(0, i))]);
        swap (ini[i], ini[ detail_algorithm::uniform_in(g, 0, i) ]);
    }

}

// for_each_n, introduced in C++17









template<class II, class Size, class UnaryFunction>
II for_each_n (II first, Size n, UnaryFunction f) {
    for (Size i = 0; i < n; ++first, (void) ++i) {
        f(*first);
    }
    return first;
}

/**
 * @}
 */

} //~namespace algorithm
} //~namespace cxxomfort


#define CXXOMFORT_IMPLEMENTS_n1990 CXXO_BACKPORT()

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

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


#if (CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_std_cxx11_algorithms == 0)
#if (!defined(CXXOMFORT_NO_STD_USING))



namespace std {

    //! using copy_if and others when in C++03.

    using ::cxxomfort::algorithm::copy_if;

    using ::cxxomfort::algorithm::copy_n;


    using ::cxxomfort::algorithm::partition_copy;


    using ::cxxomfort::algorithm::find_if_not;
    //using ::cxxomfort::algorithm::iota;

    using ::cxxomfort::algorithm::is_sorted;
    using ::cxxomfort::algorithm::shuffle;
    
    using ::cxxomfort::algorithm::for_each_n;
    
}
#endif // std using

#endif // using emulation

/**
 * @page algorithm
 * @brief Implementations and additions tied to <algorithm>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c [all,any,none]_of
 * * @c copy_if(), @c copy_n(), @c partition_copy()
 * * @c @ref equal() (C++14)
 * * @c @ref find_if_not()
 * * @c is_permutation(), @c next_permutation(), @c prev_permutation()
 * * @c @ref is_sorted()
 * * @c @ref minmax() , @c minmax_element()



 * 
 * Pending:
 * 
 * * @c shuffle





 *
 */

#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
...
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
...
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
#ifndef CXXOMFORT_ALGORITHM_HPP
#define CXXOMFORT_ALGORITHM_HPP
/**
 * @file algorithm.hpp


 */

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


namespace cxxomfort {

namespace cxxostd {





/**
 * @ingroup cxx11-backports
 * @refitem std0algorithm
 * @{
 * */

/**
 * @brief Copy elements conditionally to @a dest if they fulfill @a f .
 * @return the advanced @a dest iterator.
 * @refitem std0algorithm

 */
template <typename InpI, typename OutI, typename Predicate>
inline OutI copy_if (InpI ini, InpI fin, OutI dest, Predicate f) {
    if (ini != fin) {
        for (; ini != fin; ++ini) {
            if (f(*ini)) { *dest++= *ini; }
        } // for
        
    }
    return dest;
}

/**
 * @brief Copy a given amount of elements to @a dest .
 * @return the iterated @a dest iterator.
 * @xrefitem std0algorithm "" ""
 **/
template <typename InpI, typename Integral, typename OutI>
inline OutI copy_n (InpI ini, Integral n, OutI dest) {
    for (; n --> 0; ++ini, ++dest) {
        *dest= *ini;
    }
    return dest;
}

/**
 * @brief Conditionally copy from sequence <var>[ini,fin)</var> to either sequence starting at @p Dtrue or @p Dfalsef .
 * @return the advanced <code>std::pair</code> (@a Dtrue , @a Dfalse ).
 * @xrefitem std0algorithm "" ""
 **/
template <typename InpI, typename OutI1, typename OutI2, typename Predicate>
std::pair<OutI1,OutI2> partition_copy (InpI ini, InpI const fin, OutI1 Dtrue, OutI2 Dfalse, Predicate f) {
    for (; ini != fin; ++ini) {
        if (f(*ini)) *Dtrue++= *ini; 
        else *Dfalse++= *ini;
    } // end for
    return std::pair<OutI1,OutI2>(Dtrue,Dfalse);
}

/**
 * @brief Copy like @c copy_if with inverted predicate (for symmetry with @c find_if_not ).
 * @xrefitem std0algorithm "" ""
 */
template <typename OutI, typename InpI, typename Pred> inline 
OutI copy_if_not (InpI ini, InpI fin, OutI dest, Pred p) {
    for (; ini != fin; ++ini) { 
        if (!p(*ini)) { *dest= *ini; ++dest; }
    }
}

/**
 * @brief Finds like @c find_if but the predicate is reversed.
 * @xrefitem std0algorithm "" ""
 **/
template<class It, class Pred>
It find_if_not(It ini, It fin, Pred f) {
    for (; ini != fin; ++ini) {
        if (!f(*ini)) {
            return ini;
        }
    }
................................................................................
    return fin; // < all the elements fulfill f
}

/**
 * @brief Determines if a sequence is sorted according to a given criteria.
 * @param less Criteria for sorting, a binary function f(x,y) that returns @c true if <code>x<y</code>.
 * @return A bool response about if the sequence is sorted.
 * @xrefitem std0algorithm "" ""
 */
template <typename Iterator, typename Compare>
inline bool is_sorted (Iterator ini, Iterator fin, Compare less) {
    if (ini == fin) return true;
    Iterator prev= ini++;
    for (; ini != fin; ++ini, ++prev) {
        if (!less(*prev,*ini)) return false;
................................................................................
template <typename Iterator>
inline bool is_sorted (Iterator ini, Iterator fin) {
    std::less<typename std::iterator_traits<Iterator>::value_type> less;
    return is_sorted(ini,fin,less);
}




// detail helpers for shuffle
//! @internal
namespace detail_algorithm {

    template <typename URNG, typename E>
    E uniform_in (URNG& u, E m1, E m2) {
        //typedef typename std::result_of<URNG>::type T;
        E output = m1 + (u() % (E)(m2 - m1 + 1));
        return output;
    }

} // detail_algorithm


/**
 * @brief Shuffles a sequence according to a generator call g().
 * @param[in,out] g An object that acts like a (P)RNG and returns a value via <code>operator()</code>.
 * @warning Requires support from <random>.

 * @xrefitem std0algorithm "" ""
 * */
template< class RAIterator, class URNG >
void shuffle( RAIterator ini, RAIterator fin, URNG& g ) {
    typedef typename std::iterator_traits<RAIterator>::difference_type diff_t;
    diff_t n = fin - ini; // guaranteed for RAIterator
    for (diff_t i = n-1; i > 0; --i) {
        using std::swap;
        //swap(ini[i], ini[D(g, param_t(0, i))]);
        swap (ini[i], ini[ detail_algorithm::uniform_in(g, 0, i) ]);
    }

}

/**
 * @}
 */

/**
 * @brief Executes a function once for each element in a sequence, using it as an argument.
 * @ingroup cxx17-backports
 * @refitem std0algorithm
 * @param f A function object that is executed as <code>f(i)</code> for each @a i in the sequence.
 * */
template<class II, class Size, class UnaryFunction>
II for_each_n (II first, Size n, UnaryFunction f) {
    for (Size i = 0; i < n; ++first, (void) ++i) {
        f(*first);
    }
    return first;
}





} //~namespace algorithm
} //~namespace cxxomfort


#define CXXOMFORT_IMPLEMENTS_n1990 CXXO_BACKPORT()

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

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


#if (CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_std_cxx11_algorithms == 0) 


    #if (defined( CXXOFLAG_NO_STD_USING ) && CXXOFLAG_NO_STD_USING>0)
    #else
namespace std {


    //! copy_if
    using ::cxxomfort::cxxostd::copy_if;
    //! copy_n
    using ::cxxomfort::cxxostd::copy_n;
    using ::cxxomfort::cxxostd::partition_copy;

    using ::cxxomfort::cxxostd::find_if_not;

    //! is_sorted
    using ::cxxomfort::cxxostd::is_sorted;
    using ::cxxomfort::cxxostd::shuffle;
    

    using ::cxxomfort::cxxostd::for_each_n;
    
    using ::cxxomfort::cxxostd::equal;
    
}
    #endif // std using

#endif // using emulation

/**
 * @page std0algorithm

 * 
 * Interfaces defined in this file:
 * 
 * * @c all_of [all,any,none]_of  (C++11)
 * * @c copy_if(), @c copy_n(), @c partition_copy() (C++11)

 * * @c find_if_not() (C++11)
 * * @c is_permutation(), @c next_permutation(), @c prev_permutation() (C++11)
 * * @c is_sorted() (C++11)
 * * @c minmax() , @c minmax_element() (C++11)
 * * @c equal() overloads (C++14)
 * * @c clamp() (C++17)
 * * @c for_each_n() (C++17)
 * 
 * Pending:
 * 
 * * @c shuffle
 * 
 * @secreflist
 * Lista de contenidos.
 * @endsecreflist 
 * 
 *
 */

#endif

cxxomfort/cxxomfort/algorithms.hpp became a regular file.

Changes to cxxomfort/cxxomfort/base.hpp.

21
22
23
24
25
26
27
28
29
30
31
32
33








34
#include "./base/explicit_cast.hpp" // explicit cast operator
#include "./base/move.hpp" // move emulation
#include "./library/i12n.hpp" // { sequence } initialization emulation

#endif

/**
 * @page base-features
 * 
 * The set of basic features of cxxomfort. 
 * These features are included automatically when 
 * <code>#include <cxxomfort/base.hpp></code> is included 
 * or any of the cxxomfort headers are included.








 */







|





>
>
>
>
>
>
>
>

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "./base/explicit_cast.hpp" // explicit cast operator
#include "./base/move.hpp" // move emulation
#include "./library/i12n.hpp" // { sequence } initialization emulation

#endif

/**
 * @page cxxomfort-base
 * 
 * The set of basic features of cxxomfort. 
 * These features are included automatically when 
 * <code>#include <cxxomfort/base.hpp></code> is included 
 * or any of the cxxomfort headers are included.
 * 
 * * @c #nullptr 
 * * @c #static_assert
 * * @link cxxo:explicit_cast @c explicit_cast<> @endlink
 * * Move operations
 * * rvalue-reference emulation
 * * @c begin() , @c end() accesors
 * 
 */

cxxomfort/cxxomfort/base/alignof.hpp became a regular file.

Changes to cxxomfort/cxxomfort/base/cstdint.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
51
52
53
54
55
56
57
58
59
..
64
65
66
67
68
69
70


71
72
73
74
75
    #define CXXOMFORT_USING_NATIVE_stdint
#else
    #if 0
        #error ("Unreachable.");
    #elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_CLANG)
    // GCC and clang have a <stdlib.h>
        #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("cstdint forwarded to tr1/ <cstdint> [clang]")
        #endif
        #define __STDC_LIMIT_MACROS
        #include <tr1/cstdint>
        #define CXXOMFORT_USING_NATIVE_stdint

    #elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_GCC)
        #if (CXXOMFORT_COMPILER_VERSION >= 406)
            #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
            #pragma message CXXO_NOTICE("cstdint forwarded to tr1/ <cstdint> [gcc]")
            #endif
            #define __STDC_LIMIT_MACROS
            #include <tr1/cstdint>
            #define CXXOMFORT_USING_NATIVE_stdint
        #else
            #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
            #pragma message CXXO_NOTICE("cstdint forwardrd to <stdint.h> [gcc]")
            #endif
            #define __STDC_LIMIT_MACROS
            #include <stdint.h>
            #define CXXOMFORT_USING_NATIVE_stdint
        #endif
    #elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC)
        #if (CXXOMFORT_COMPILER_VERSION>150)
            #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
            #pragma message CXXO_NOTICE("cstdint forwarded to MSVC:<cstdint>")
            #define __STDC_LIMIT_MACROS
            #include <cstdint>
            #define CXXOMFORT_USING_NATIVE_stdint
            #endif
        #else
            //#include <stdint.h>
        #endif
................................................................................
#if (!defined(CXXOMFORT_USING_NATIVE_stdint))
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("cstdint forwarded to portable-stdint")
    #endif
    //#define __STDC_LIMIT_MACROS
    #include "../impl/pstdint.h"
    #define CXXOMFORT_USING_PSTDINT_stdint


#endif // using pstdint

#include <climits>
#endif // header








|








|






|








|







 







>
>





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
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    #define CXXOMFORT_USING_NATIVE_stdint
#else
    #if 0
        #error ("Unreachable.");
    #elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_CLANG)
    // GCC and clang have a <stdlib.h>
        #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
            #pragma message CXXO_NOTICE("cstdint forwarded to tr1/ <cstdint> [clang]")
        #endif
        #define __STDC_LIMIT_MACROS
        #include <tr1/cstdint>
        #define CXXOMFORT_USING_NATIVE_stdint

    #elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_GCC)
        #if (CXXOMFORT_COMPILER_VERSION >= 406)
            #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
                #pragma message CXXO_NOTICE("cstdint forwarded to tr1/ <cstdint> [gcc]")
            #endif
            #define __STDC_LIMIT_MACROS
            #include <tr1/cstdint>
            #define CXXOMFORT_USING_NATIVE_stdint
        #else
            #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
                #pragma message CXXO_NOTICE("cstdint forwardrd to <stdint.h> [gcc]")
            #endif
            #define __STDC_LIMIT_MACROS
            #include <stdint.h>
            #define CXXOMFORT_USING_NATIVE_stdint
        #endif
    #elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC)
        #if (CXXOMFORT_COMPILER_VERSION>150)
            #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
                #pragma message CXXO_NOTICE("cstdint forwarded to MSVC:<cstdint>")
            #define __STDC_LIMIT_MACROS
            #include <cstdint>
            #define CXXOMFORT_USING_NATIVE_stdint
            #endif
        #else
            //#include <stdint.h>
        #endif
................................................................................
#if (!defined(CXXOMFORT_USING_NATIVE_stdint))
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
        #pragma message CXXO_NOTICE("cstdint forwarded to portable-stdint")
    #endif
    //#define __STDC_LIMIT_MACROS
    #include "../impl/pstdint.h"
    #define CXXOMFORT_USING_PSTDINT_stdint
    // use up the macro guard of stdint.h to prevent a collission
    #define _MSC_STDINT_H_ // win32
#endif // using pstdint

#include <climits>
#endif // header

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

19
20
21
22
23
24
25










26
27
28
29
30


31







32
33
34
35
36
37
38
39

#if (CXXOMFORT_CXX_STD < 2011 /* && CXXO_COMPILER_SUPPORT_explicit_operator==0 */)
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
        #pragma message CXXO_NOTICE("enabled 'explicit operator' emulation")
    #endif
namespace cxxomfort {
namespace detail_explicit_cast {











    template <typename T>
    struct explicit_cast {
        T value;
        explicit_cast (T const& t) CXXO_NOEXCEPT : value(t) {}


        //explicit_cast ( CXXO_RV_REF(T) p) : value(std::move(p)) {}







        operator T () const CXXO_NOEXCEPT { return value; }
    };

    #define CXXO_EXPLICIT_OPERATOR(T) operator ::cxxomfort::detail_explicit_cast::explicit_cast<T> 


}
} // cxxomfort::







>
>
>
>
>
>
>
>
>
>



|

>
>
|
>
>
>
>
>
>
>
|







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

#if (CXXOMFORT_CXX_STD < 2011 /* && CXXO_COMPILER_SUPPORT_explicit_operator==0 */)
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 2)
        #pragma message CXXO_NOTICE("enabled 'explicit operator' emulation")
    #endif
namespace cxxomfort {
namespace detail_explicit_cast {

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

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

    template <typename T>
    struct explicit_cast {
        T const& value;
        explicit_cast (T const& t) CXXO_NOEXCEPT : value(t) {}
        operator T const& () const CXXO_NOEXCEPT { return value; }
        private:
        explicit_cast ();
        explicit_cast& operator= (explicit_cast const&);
    };

    template <typename T>
    struct explicit_cast<T&> {
        T& value;
        explicit_cast (T& t) CXXO_NOEXCEPT : value(t) {}
        operator T & () const CXXO_NOEXCEPT { return value; }
    };

    #define CXXO_EXPLICIT_OPERATOR(T) operator ::cxxomfort::detail_explicit_cast::explicit_cast<T> 


}
} // cxxomfort::

Changes to cxxomfort/cxxomfort/base/iterator.hpp.

1
2
3
4
5
6
7
8
9
...
127
128
129
130
131
132
133
134

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169

170
171
172
173
174
175
176
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
301
302
303
304
305
306
307
308
309
310
#ifndef CXXOMFORT_ITERATOR_HPP
#define CXXOMFORT_ITERATOR_HPP
/**
 * @file
 * @brief Implements some C++11 functions in C++03 from the "iterator" header.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
................................................................................
//! C++14 "overload" of begin to always return const-iterator
//! @ref cxx14-backports
template <typename C> inline
typename C::const_iterator
cbegin (C const& c)  {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return cxxomfort::iterator::begin(c);

}

//! @overload cxxomfort::begin 
template <typename T, std::size_t N> inline
T* begin (T(&arr)[N]) { return arr; }

//! @overload cbegin
template <typename T, std::size_t N> inline
T const* cbegin (T const(&arr)[N]) { return arr; }

//! Returns the "end" iterator for a container-like object.
//! @ref cxx11-backports
template <typename C> inline
typename C::iterator
end (C & c) {
................................................................................

//! @overload cxxomfort::end 
template <typename C> inline
typename C::const_iterator
end (C const& c) {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");

    return c.end();
}

//! C++14 "overload" to always return const-iterator
//! @ref cxx14-backports
template <typename C> inline
typename C::const_iterator
cend (C const& c)  {
    return cxxomfort::iterator::end(c);

}

//! @overload end
template <typename T, size_t N> inline
T* end (T(&arr)[N]) { return arr+N; }

//! @overload cend
................................................................................
rend (C & c) {
    static_assert(sizeof(typename C::reverse_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.rend();
}

//! @overload cxxomfort::rbegin 
template <typename T, std::size_t N> inline
std::reverse_iterator<T*> rbegin (T(&arr)[N]) { return std::reverse_iterator<T*>(arr+N); }

//! @overload cxxomfort::rend 
template <typename T, std::size_t N> inline
std::reverse_iterator<T*> rend (T(&arr)[N]) { return std::reverse_iterator<T*>(arr); }


/**
 * @brief Moves an iterator forwards an amount of steps, returning the result.
 * @ingroup iterator
 * @ref cxx03-backports
 *
................................................................................

#else
	using ::cxxomfort::iterator::cbegin;
	using ::cxxomfort::iterator::cend;
#endif
}

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

#endif
|
|







 







|
>



|



|







 







>








|
>







 







|
|


|
|







 







<
<

1
2
3
4
5
6
7
8
9
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
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
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
304
305
306
307
308
309
310


311
#ifndef CXXOMFORT_BASE_ITERATOR_HPP
#define CXXOMFORT_BASE_ITERATOR_HPP
/**
 * @file
 * @brief Implements some C++11 functions in C++03 from the "iterator" header.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
................................................................................
//! C++14 "overload" of begin to always return const-iterator
//! @ref cxx14-backports
template <typename C> inline
typename C::const_iterator
cbegin (C const& c)  {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    using namespace std;
    return begin(c);
}

//! @overload cxxomfort::begin 
template <typename T, ::std::size_t N> inline
T* begin (T(&arr)[N]) { return arr; }

//! @overload cbegin
template <typename T, ::std::size_t N> inline
T const* cbegin (T const(&arr)[N]) { return arr; }

//! Returns the "end" iterator for a container-like object.
//! @ref cxx11-backports
template <typename C> inline
typename C::iterator
end (C & c) {
................................................................................

//! @overload cxxomfort::end 
template <typename C> inline
typename C::const_iterator
end (C const& c) {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    using namespace std;
    return c.end();
}

//! C++14 "overload" to always return const-iterator
//! @ref cxx14-backports
template <typename C> inline
typename C::const_iterator
cend (C const& c)  {
    using namespace std;
    return begin(c);
}

//! @overload end
template <typename T, size_t N> inline
T* end (T(&arr)[N]) { return arr+N; }

//! @overload cend
................................................................................
rend (C & c) {
    static_assert(sizeof(typename C::reverse_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.rend();
}

//! @overload cxxomfort::rbegin 
template <typename T, ::std::size_t N> inline
::std::reverse_iterator<T*> rbegin (T(&arr)[N]) { return ::std::reverse_iterator<T*>(arr+N); }

//! @overload cxxomfort::rend 
template <typename T, ::std::size_t N> inline
::std::reverse_iterator<T*> rend (T(&arr)[N]) { return ::std::reverse_iterator<T*>(arr); }


/**
 * @brief Moves an iterator forwards an amount of steps, returning the result.
 * @ingroup iterator
 * @ref cxx03-backports
 *
................................................................................

#else
	using ::cxxomfort::iterator::cbegin;
	using ::cxxomfort::iterator::cend;
#endif
}



#endif

cxxomfort/cxxomfort/base/move-03.hpp became a regular file.

cxxomfort/cxxomfort/base/move-11.hpp became a regular file.

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

1
2
3
4
5
6
7
8
9
10
11
12
13
..
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
#ifndef CXXOMFORT_UTIL_MOVE_HPP
#define CXXOMFORT_UTIL_MOVE_HPP

/**
 * @file
 * @brief Implements movable objects functionality in C++03 .
 *
 */


/*
 * Usage example
 *
................................................................................
// end c++11 / c++03
#endif

namespace cxxomfort {

/**
 * @brief Move-assigns the objects from sequence <var>[ini,fin)</var> to sequence at @e dest .
 * @ingroup base-features
 * @ref cxx03-backports
 * @ref algorithm
 */
template<class IIt, class OIt>
OIt move(IIt ini, IIt fin, OIt dest) {
    while (ini != fin) {
        *dest++ = ::cxxomfort::move(*ini++);
    }
    return dest;
}






template<class IIt, class OIt>
OIt move_backward(IIt ini, IIt fin, OIt dest) {
    while (ini != fin) {
        *dest-- = ::cxxomfort::move(*fin--);
    }
    return dest;
}





<







 







|
<
|









>
>
>
>
>







1
2
3
4
5

6
7
8
9
10
11
12
..
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
#ifndef CXXOMFORT_UTIL_MOVE_HPP
#define CXXOMFORT_UTIL_MOVE_HPP

/**
 * @file

 *
 */


/*
 * Usage example
 *
................................................................................
// end c++11 / c++03
#endif

namespace cxxomfort {

/**
 * @brief Move-assigns the objects from sequence <var>[ini,fin)</var> to sequence at @e dest .
 * @ingroup cxx11-backports

 * @xrefitem std0algorithm "" ""
 */
template<class IIt, class OIt>
OIt move(IIt ini, IIt fin, OIt dest) {
    while (ini != fin) {
        *dest++ = ::cxxomfort::move(*ini++);
    }
    return dest;
}

/**
 * @brief Move-assigns the objects from sequence <var>[ini,fin)</var> to sequence at @e dest , in reverse order.
 * @ingroup cxx11-backports
 * @xrefitem std0algorithm "" ""
 */
template<class IIt, class OIt>
OIt move_backward(IIt ini, IIt fin, OIt dest) {
    while (ini != fin) {
        *dest-- = ::cxxomfort::move(*fin--);
    }
    return dest;
}

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

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
71
72
73
74
75
76
77


78
79
80
81
82
83
84
85
86
87
88

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

/**
 * @class nullptr_t
 * @brief Null pointer literal type.
 * @ingroup cxx11-backports
 * @ref base-features
 * 
 * @attention No variables of this type can be created.
 *
 * @c nullptr_t is defined in the C++0x Standard as the type of the
 * keyword "@c nullptr ", via decltype. In C++98 / C++03,
 * an emulation is provided and recommended by the Standard.
 *
................................................................................


} //~namespace std

/**
 * @brief Null pointer literal (backport)
 * @ingroup cxx11-backports


 * @see http://stackoverflow.com/questions/8747005/backporting-nullptr-to-c-pre-c0x-programs
 * @ref base-features
 * @ref cstddef
 */
const std::nullptr_t nullptr = {};



#endif // using emulation

#endif // file







|







 







>
>

<
<








41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
71
72
73
74
75
76
77
78
79
80


81
82
83
84
85
86
87
88

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

/**
 * @class nullptr_t
 * @brief Null pointer literal type.
 * @ingroup cxx11-backports
 * @xrefitem cxxomfort-base "" ""
 * 
 * @attention No variables of this type can be created.
 *
 * @c nullptr_t is defined in the C++0x Standard as the type of the
 * keyword "@c nullptr ", via decltype. In C++98 / C++03,
 * an emulation is provided and recommended by the Standard.
 *
................................................................................


} //~namespace std

/**
 * @brief Null pointer literal (backport)
 * @ingroup cxx11-backports
 * @xrefitem std:cstddef "<cstddef>" ""
 * @xrefitem cxxomfort-base "" ""
 * @see http://stackoverflow.com/questions/8747005/backporting-nullptr-to-c-pre-c0x-programs


 */
const std::nullptr_t nullptr = {};



#endif // using emulation

#endif // file

Changes to cxxomfort/cxxomfort/base/static_assert.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef CXXOMFORT_SASSERT_HPP
#define CXXOMFORT_SASSERT_HPP
/**
 * @file
 * @brief Implements @c static_assert (n1720) as a comfort utility for C++03.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * @license MIT License (see LICENSE.txt)
 *
 * Interfaces defined in this file:
 * 
 * * @c static_assert
 */

#include "../config.hpp"
................................................................................

/*
 * This is marked as a system header 
 * as it uses the name of a C++11 reserved word as an identifier.
 */
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC \
    && CXXOMFORT_COMPILER_VERSION >= 406)
#pragma GCC system_header
#endif


/**
 * @def static_assert
 * @ingroup cxx11-backports
 * @ref base-features
 * @ref cstddef
 * @brief Provides an assertion at compile-time
 * @param test The boolean test to run, must be computable at compile-time
 * @param msg The string literal to provide as a compiler error message if the assertion does not hold
 */
//    #define static_assert(test,msg) enum { CXXOMFORT_JOINX(sassert_e_,__COUNTER__) = (int)(msg[0])/(test) }
    #if defined(_MSC_VER)
    #define static_assert(test,msg) typedef void* CXXOMFORT_JOINX(sassert_expr_,__COUNTER__)[(test)?1:-1]




<

<







 







|






|
<







1
2
3
4

5

6
7
8
9
10
11
12
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
#ifndef CXXOMFORT_SASSERT_HPP
#define CXXOMFORT_SASSERT_HPP
/**
 * @file

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>

 *
 * Interfaces defined in this file:
 * 
 * * @c static_assert
 */

#include "../config.hpp"
................................................................................

/*
 * This is marked as a system header 
 * as it uses the name of a C++11 reserved word as an identifier.
 */
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC \
    && CXXOMFORT_COMPILER_VERSION >= 406)
//#pragma GCC system_header
#endif


/**
 * @def static_assert
 * @ingroup cxx11-backports
 * @xrefitem cxxomfort-base "" ""

 * @brief Provides an assertion at compile-time
 * @param test The boolean test to run, must be computable at compile-time
 * @param msg The string literal to provide as a compiler error message if the assertion does not hold
 */
//    #define static_assert(test,msg) enum { CXXOMFORT_JOINX(sassert_e_,__COUNTER__) = (int)(msg[0])/(test) }
    #if defined(_MSC_VER)
    #define static_assert(test,msg) typedef void* CXXOMFORT_JOINX(sassert_expr_,__COUNTER__)[(test)?1:-1]

Changes to cxxomfort/cxxomfort/config.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
...
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
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
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
...
369
370
371
372
373
374
375
376


377

378

379
380
381

382
383
384
385
386
387
388
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419

420
421

422




423
#ifndef CXXOMFORT_CONFIG_HPP
#define CXXOMFORT_CONFIG_HPP
/**
 * @file
 * @brief Configuration file for cxxomfort-library.
 * @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 YYYYMMDD
#define CXXOMFORT_DATE 20180821UL
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 72

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

//
// Standard Mode
................................................................................
//

#define CXXO_VALUE_COMPILER_GCC 101
#define CXXO_VALUE_COMPILER_DIGITALMARS 102
#define CXXO_VALUE_COMPILER_MSC 103
#define CXXO_VALUE_COMPILER_CLANG 104

//
// Set different flags according to the features 
// supported by the compiler



//




//! 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 alignment tools (@c alignas , 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 support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)

//! 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_default_delete (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for endianness tag (std::endian)
#define CXXO_COMPILER_SUPPORT_endian (CXXOMFORT_CXX_STD>=2020)
//! If compiler provides support for scoped enumerations ie.: <code>enum class...</code>.
#define CXXO_COMPILER_SUPPORT_enum_class (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code>explicit operator ...</code> casts.
#define CXXO_COMPILER_SUPPORT_explicit_operator (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for range-for.
#define CXXO_COMPILER_SUPPORT_foreach (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <functional>'s classical binders.
#define CXXO_COMPILER_SUPPORT_functional_oldstyle (CXXOMFORT_CXX_STD<2017)
//! If compiler supports <functional> 's transparent functors.
#define CXXO_COMPILER_SUPPORT_functional_transparent (CXXOMFORT_CXX_STD >= 2014)
//! If compiler provides support for @c std::initializer_list .
#define CXXO_COMPILER_SUPPORT_initializer_list (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for "integer_sequence".
#define CXXO_COMPILER_SUPPORT_integer_sequence (CXXOMFORT_CXX_STD >= 2014)
//! If compiler provides support for local and unnamed types as template arguments.
#define CXXO_COMPILER_SUPPORT_local_types (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c noexcept *AND* is_noexcept-traits.
#define CXXO_COMPILER_SUPPORT_noexcept (CXXOMFORT_CXX_STD>=2011)
//! 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 __typeof__ in C++03.
#define CXXO_COMPILER_SUPPORT_typeof 0
//! 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 variadic macros (<code>__VA_ARG__</code>).
#define CXXO_COMPILER_SUPPORT_va_args 0





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





// Detect CXX_STD and operation mode (initial)

/*
#if (__cplusplus >= 201103L && __cplusplus < 201402L)
    #undef  CXXOMFORT_CXX_STD
    #define CXXOMFORT_CXX_STD 2011
................................................................................
    #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


    #if (CXXOMFORT_CXX_EMULATION == 2011) 
        #pragma message CXXO_NOTICE("running in emulation / c++0x mode (c++11)")
    #elif (CXXOMFORT_CXX_EMULATION == 2014)
        #pragma message CXXO_NOTICE("running in emulation / c++1y mode (c++14)")


    #endif
    
    #endif // friendly notices

#endif

//
// Macros that conditionally generate code for C++11, C++14


#if (CXXOMFORT_CXX_STD < 2011)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) none
    #define CXXOMFORT_CXX14_CODE(cxx14,none) none

#elif (CXXOMFORT_CXX_STD == 2011)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) cxx11
................................................................................
#define CXXO_VALUE_ARCH_i586    10586
#define CXXO_VALUE_ARCH_i486    10486
#define CXXO_VALUE_ARCH_i386    10386
#define CXXO_VALUE_ARCH_ia64    11064
#define CXXO_VALUE_ARCH_amd64   13064


#  if defined(__i686__) || (defined(_M_IX86) && (_M_IX86==600))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i686
#elif defined(__i586__) || (defined(_M_IX86) && (_M_IX86==500))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i586
#elif defined(__i486__) || (defined(_M_IX86) && (_M_IX86==400))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i486
#elif defined(__i386__) || (defined(_M_IX86) && (_M_IX86==300))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i586
................................................................................

// Macros to conditionally generate keywords

//
// CXXO_CONSTEXPR
// Evaluates to constexpr where constexpr is supported
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_constexpr == 0)
#define CXXO_CONSTEXPR
#else
#define CXXO_CONSTEXPR constexpr
#endif

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

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

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

/*
................................................................................
}
*/

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

//! Namespace @c cxxomfort holds most features of the library.


namespace cxxomfort {

namespace cxxostd {}

namespace library {}

//! Information about the library support

const struct info { 
    enum {
    //! library version
    version = CXXOMFORT_VERSION , 
    date = CXXOMFORT_DATE, 
    //! compiler identification code
    compilerid = CXXOMFORT_COMPILER_ID ,
................................................................................
    };
    
    /* struct */ 
} $ = {};

template <typename SS> 
static void output_info (SS& os) {
    os<< "(cxxomfort="<< $.version<< " date="<< $.date<< " compilerid="<< $.compilerid<< " compilerversion="<< $.compilerversion
      << " cplusplus="<< $.cplusplus<< " std="<< $.cxx_std<< " emulation="<< $.cxx_emulation<< " )";
    //return os;
}

#if 0 // uncomment only for diagnostics and wiki work
template <typename SS> 
static void output_info_row (SS& os) {
    using namespace std;
    os<< "    <code>"<< setw(3)<< setfill(' ')<< $.compilerid<< "</code>";
    os<< " <code>"<< setw(4)<< setfill('0')<< $.compilerversion<< setfill(' ')<< "</code>";
    os<< "  </td><td>  <code>"<< setw(4)<< $.cxx_std<< "</code>  </td><td>  <code>"<< setw(4)<< $.cxx_emulation<< "</code>  </td>"
    ;
    //return os;
}
#endif


// ~::cxxomfort
}






#endif




<







|

|







 







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

>

>


>
>
>
>







 







>
>
>
>
|
|
|
|
|
|
|

>
|
|
|
|
>
>
|
|






>







 







|







 







|

|






|

|






|

|






|

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







 







|
>
>

>

>



>







 







|




|
<
<
<
<
<
<
<
<

<

>
|
<
>
|
>
>
>
>

1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
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
...
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
...
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
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
...
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
...
372
373
374
375
376
377
378
379
380
381
382
383
384








385

386
387
388

389
390
391
392
393
394
395
#ifndef CXXOMFORT_CONFIG_HPP
#define CXXOMFORT_CONFIG_HPP
/**
 * @file

 * @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 YYYYMMDD
#define CXXOMFORT_DATE 20180902UL
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 74

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

//
// Standard Mode
................................................................................
//

#define CXXO_VALUE_COMPILER_GCC 101
#define CXXO_VALUE_COMPILER_DIGITALMARS 102
#define CXXO_VALUE_COMPILER_MSC 103
#define CXXO_VALUE_COMPILER_CLANG 104

/*
 * Behaviour macros

 */

#if defined(DOXYGEN_DOC)
/**
 * @def CXXOFLAG_NO_STD_USING
 * @brief Disables adding names to <code>namespace std</code>
 * @warning Using this configuration is @e not supported.
 * 





 * If this macro is defined and has a value <code>>=0</code>, 
 * cxxomfort headers will @e not add their backports to 
 * namespace @c std (eg.: "<code>std::as_const</code>). This option 
 * does not affect utilities defined as "base" (eg.: @c nullptr_t ).

 */
#define CXXOFLAG_NO_STD_USING 0


/**
 * @def CXXOFLAG_SHADOW_KEYWORD_constexpr
 * @brief Makes the compiler ignore @c constexpr keyword in standard where not supported (C++03).

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

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


#include "config/_support.hpp"


// Detect CXX_STD and operation mode (initial)

/*
#if (__cplusplus >= 201103L && __cplusplus < 201402L)
    #undef  CXXOMFORT_CXX_STD
    #define CXXOMFORT_CXX_STD 2011
................................................................................
    #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
        #elif (CXXOMFORT_CXX_STD >= 2017)
            #pragma message CXXO_NOTICE("detected C++17 or above mode")
        #elif (CXXOMFORT_CXX_STD >= 2014)
            #pragma message CXXO_NOTICE("detected C++14 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

        #if 0
        #elif (CXXOMFORT_CXX_EMULATION == 2011) 
            #pragma message CXXO_NOTICE("running in emulation / c++0x mode (c++11)")
        #elif (CXXOMFORT_CXX_EMULATION == 2014)
            #pragma message CXXO_NOTICE("running in emulation / c++1y mode (c++14)")
        #elif (CXXOMFORT_CXX_EMULATION >= 2017)
            #pragma message CXXO_NOTICE("running in emulation / c++1z mode (c++17)")
        #endif
        
    #endif // friendly notices

#endif

//
// Macros that conditionally generate code for C++11, C++14
//

#if (CXXOMFORT_CXX_STD < 2011)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) none
    #define CXXOMFORT_CXX14_CODE(cxx14,none) none

#elif (CXXOMFORT_CXX_STD == 2011)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) cxx11
................................................................................
#define CXXO_VALUE_ARCH_i586    10586
#define CXXO_VALUE_ARCH_i486    10486
#define CXXO_VALUE_ARCH_i386    10386
#define CXXO_VALUE_ARCH_ia64    11064
#define CXXO_VALUE_ARCH_amd64   13064


#if defined(__i686__) || (defined(_M_IX86) && (_M_IX86==600))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i686
#elif defined(__i586__) || (defined(_M_IX86) && (_M_IX86==500))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i586
#elif defined(__i486__) || (defined(_M_IX86) && (_M_IX86==400))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i486
#elif defined(__i386__) || (defined(_M_IX86) && (_M_IX86==300))
    #define CXXOMFORT_ARCHITECTURE CXXO_VALUE_ARCH_i586
................................................................................

// Macros to conditionally generate keywords

//
// CXXO_CONSTEXPR
// Evaluates to constexpr where constexpr is supported
#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_constexpr == 0)
    #define CXXO_CONSTEXPR
#else
    #define CXXO_CONSTEXPR constexpr
#endif

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

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

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

/*
................................................................................
}
*/

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

//! 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 {}
//! Namespace that holds the library's own implementations, emulations and supplements.
namespace library {}

//! Information about the library support
//! @ingroup cxxomfort-config
const struct info { 
    enum {
    //! library version
    version = CXXOMFORT_VERSION , 
    date = CXXOMFORT_DATE, 
    //! compiler identification code
    compilerid = CXXOMFORT_COMPILER_ID ,
................................................................................
    };
    
    /* struct */ 
} $ = {};

template <typename SS> 
static void output_info (SS& os) {
    os<< "(cxxomfort="<< $.version<< " date="<< $.date<< " compiler="<< $.compilerid<< ":"<< $.compilerversion
      << " cplusplus="<< $.cplusplus<< " std="<< $.cxx_std<< " emulation="<< $.cxx_emulation<< " )";
    //return os;
}

// ~::cxxomfort








}


/**
 * @page cxxomfort-config

 * @brief Configuration macros
 * 
 *
 * 
 */

#endif

Changes to cxxomfort/cxxomfort/config/_has.hpp.




1
2
3
4
5
6
7



#ifndef CXXOMFORT_CONFIG_C_HAS_HPP
#define CXXOMFORT_CONFIG_C_HAS_HPP

/*
 * Starting with cxxomfort 0.6, headers also provide a macro describing the 
 * support of feature they implement. 
 */
>
>
>







1
2
3
4
5
6
7
8
9
10
#ifndef CXXOMFORT_CONFIG_HPP
    #error "This file should only be #included via <cxxomfort/config.hpp>"
#endif
#ifndef CXXOMFORT_CONFIG_C_HAS_HPP
#define CXXOMFORT_CONFIG_C_HAS_HPP

/*
 * Starting with cxxomfort 0.6, headers also provide a macro describing the 
 * support of feature they implement. 
 */

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

/**
 * @ingroup cxxomfort-config
 * @{
 * */
//! 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 alignment tools (@c alignas , 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 support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)
//! 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_default_delete (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for endianness tag (std::endian)
#define CXXO_COMPILER_SUPPORT_endian (CXXOMFORT_CXX_STD>=2020)
//! If compiler provides support for scoped enumerations ie.: <code>enum class...</code>.
#define CXXO_COMPILER_SUPPORT_enum_class (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code>explicit operator ...</code> casts.
#define CXXO_COMPILER_SUPPORT_explicit_operator (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for range-for.
#define CXXO_COMPILER_SUPPORT_foreach (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code><functional></code>'s classical binders.
#define CXXO_COMPILER_SUPPORT_functional_oldstyle (CXXOMFORT_CXX_STD<2017)
//! If compiler supports <code><functional></code>'s transparent functors.
#define CXXO_COMPILER_SUPPORT_functional_transparent (CXXOMFORT_CXX_STD >= 2014)
//! If compiler provides support for @c std::initializer_list .
#define CXXO_COMPILER_SUPPORT_initializer_list (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for "integer_sequence".
#define CXXO_COMPILER_SUPPORT_integer_sequence (CXXOMFORT_CXX_STD >= 2014)
//! If compiler provides support for local and unnamed types as template arguments.
#define CXXO_COMPILER_SUPPORT_local_types (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c noexcept *AND* is_noexcept-traits.
#define CXXO_COMPILER_SUPPORT_noexcept (CXXOMFORT_CXX_STD>=2011)
//! 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 __typeof__ in C++03.
#define CXXO_COMPILER_SUPPORT_typeof 0
//! 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 variadic macros (<code>__VA_ARG__</code>).
#define CXXO_COMPILER_SUPPORT_va_args 0


/**
 * @}
 * */


#endif

cxxomfort/cxxomfort/config/clang.hpp became a regular file.

cxxomfort/cxxomfort/config/gcc.hpp became a regular file.

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

40
41
42
43
44
45
46

47
48
49
50
51
52
53

54
55
56
57
58
59
60
..
83
84
85
86
87
88
89

90
91
92
93
94
95
96
#define CXXOMFORT_CXX_STD (__cplusplus/100)

// We won't even make an attempt to support VC6
#if (CXXOMFORT_COMPILER_VERSION <= 120)
    #error "cxxomfort -- Detected an horribly broken compiler! (MSVC6 or earlier)"
#endif


#if (CXXOMFORT_COMPILER_VERSION > 120)
    #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
#endif


#if (CXXOMFORT_COMPILER_VERSION >= 160) // VC10 or higher
    #undef  CXXOMFORT_CXX_EMULATION
    #define CXXOMFORT_CXX_EMULATION 2011
    #undef  CXXO_COMPILER_SUPPORT_auto
    #define CXXO_COMPILER_SUPPORT_auto 1
    #undef  CXXO_COMPILER_SUPPORT_conditional_enableif
    #define CXXO_COMPILER_SUPPORT_conditional_enableif 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







>







>







 







>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#define CXXOMFORT_CXX_STD (__cplusplus/100)

// We won't even make an attempt to support VC6
#if (CXXOMFORT_COMPILER_VERSION <= 120)
    #error "cxxomfort -- Detected an horribly broken compiler! (MSVC6 or earlier)"
#endif

// At least VC2008
#if (CXXOMFORT_COMPILER_VERSION > 120)
    #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
#endif

// At least VC2010
#if (CXXOMFORT_COMPILER_VERSION >= 160) // VC10 or higher
    #undef  CXXOMFORT_CXX_EMULATION
    #define CXXOMFORT_CXX_EMULATION 2011
    #undef  CXXO_COMPILER_SUPPORT_auto
    #define CXXO_COMPILER_SUPPORT_auto 1
    #undef  CXXO_COMPILER_SUPPORT_conditional_enableif
    #define CXXO_COMPILER_SUPPORT_conditional_enableif 1
................................................................................
    #undef  CXXO_COMPILER_SUPPORT_unique_ptr
    #define CXXO_COMPILER_SUPPORT_unique_ptr 1
    
#endif

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

// At least VC2015
#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

Added cxxomfort/cxxomfort/cstd/cinttypes.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef CXXOMFORT_STD_CINTTYPES
#define CXXOMFORT_STD_CINTTYPES
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 * 
 * If inttypes is missing (eg in MSVC 2008), 
 * user must provide it via an alternative 
 * for example https://github.com/chemeris/msinttypes
 * 
 */
#include "../config.hpp"
#include CXXO_INCLUDE_SYS(inttypes.h)
#endif

Added cxxomfort/cxxomfort/cstd/system_error.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
#ifndef CXXOMFORT_STD_SYSTEM_ERROR
#define CXXOMFORT_STD_SYSTEM_ERROR
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../system_error.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstddef.hpp.

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














16
#ifndef CXXOMFORT_CSTDDEF_HPP
#define CXXOMFORT_CSTDDEF_HPP
/**
 * @file
 * @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"  // nullptr_t
#include "base/static_assert.hpp"
#include "impl/17-byte.hpp" // c++17's "byte"
#include CXXO_INCLUDE_SYS(cstddef)














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

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 */

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

/**
 * @page std0cstddef
 * 
 * Features related to <code><cstddef></code>.
 * 
 * * @c #nullptr , <code>@ref nullptr_t</code> (C++11)
 * * <code>@ref static_assert </code>(C++11)
 * * <code>@ref byte</code> (C++17)
 * 
 * See also: @ref cstdio , @ref cxxomfort-base .
 * **/


#endif

Changes to cxxomfort/cxxomfort/cstdint.hpp.

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


18






19
#ifndef CXXOMFORT_CSTDINT_HPP
#define CXXOMFORT_CSTDINT_HPP
/**
 * @file
 * @brief <cstdint> wrapper
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * @anchor cstdint
 *
 */

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










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

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * @anchor cstdint
 *
 */

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

/**
 * @page std0cstdint
 * 
 * Features related to <code><cstdint></code>.
 * 
 * 
 * See also: @ref std0cstddef , @ref cxxomfort-base .
 * **/

#endif

Changes to cxxomfort/cxxomfort/cxxomfort.hpp.

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
 *
 * This library is distributed under the terms of the
 * MIT License. Check LICENSE.txt for more information.
 * 
 * 
 * The library is organized in two ways:
 * 
 * First, the various features are organized depending on the C++ version they derive from:
 * 
 * * @subpage cxx03-backports
 * * @subpage cxx11-backports
 * * @subpage cxx14-backports
 * * @subpage cxx17-backports
 * * @subpage cxx20-backports
 * * @ref independent-features "Independent Features"
 * * @ref extra-features "Extras"

 * * @ref transparent-headers "Transparent Headers"







 * 



 * Second, they are organized according to the C++ Standard Header they were implemented from:
 * 
 * * @subpage algorithm "<algorithm>"
 * * @subpage cstddef "<cstddef>"

















 * * @subpage forward_list "<forward_list>"





 * * @subpage functional "<functional>"
 * * @subpage iterator "<iterator>"
 * * @subpage memory "<memory>"
 * * @subpage random "<random>"
 * * @subpage string "<string>"
 * * @subpage tuple "<tuple>"
 * * @subpage type_traits "<type_traits>"
 * * @subpage utility "<utility>"





 * 
 * The library features not only backports however; it also offers its own features and emulations up to and including its own @c string type (because who in C++ ever doesn't write one).
 * 
 * * @ref independent-features "Independent Features"








 *
 * For installation see @ref cxxomfort-installation "Installation" ; for general usage see @ref cxxomfort-usage "Usage" .
 * 
 */

//
// Setup
#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 "numeric.hpp" // <numeric> stuff like iota
#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 Backports from C++03.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><functional></code>: @ref bind1st etc.
 * 
*
 */

/**
 * @page cxx11-backports
 * @brief Backports from C++11.
 * 
 * C++11 adds a large number of features such as variadic templates, @c constexpr , static asserts and much improved template support and metaprogramming.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><algorithm></code>: copy_if(), copy_n(), partition_copy(), minmax(), minmax_element(), etc.
 * * From <code><string></code>: to_string() , etc.
 * * From <code><utility></code>: declval() , etc.
 * 
 * See also: @ref cxx14-backports .
 */

/**
 * @page cxx14-backports
 * @brief Backports from C++14.
 * 
 * C++14 adds a number of features regarding algorithms and function object support.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><algorithm></code>: equal(), mismatch(), etc.
 * * From <code><functional></code>: @link Transparent Functors @endlink .
 * * From <code><utility></code>: exchange() , std::integer_sequence , etc.
 * 
 * See also: @ref cxx17-backports .
 */

/**
 * @page cxx17-backports
 * @brief Backports from C++17.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><type_traits></code>: std::void_t, etc.
 * * From <code><utility></code>: as_const(), etc.
 * 
 * See also: @ref cxx20-backports .
 */

/**
 * @page cxx20-backports
 * @brief Backports from C++20.
 * 
 * A listing of some of the features backported:
 * 
 * * TBD
 * * From <code><utility></code>: as_const(), etc. 
 *
 * 
 */

/**
 * @page extra-features
 * @brief Non-automatic features of cxxomfort.
 */

#endif








|

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

>
>
>
|

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

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












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

>


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


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
 *
 * This library is distributed under the terms of the
 * MIT License. Check LICENSE.txt for more information.
 * 
 * 
 * The library is organized in two ways:
 * 
 *  First, the library is organized according to which C++ version does it pull implementations and features from, as follows:
 * 
 * <table><tr>
 *  <th>Basic features</th>
 *  <td align="center"> @subpage cxxomfort-base "Base Features (automatically included)" <br/>
 *  eg.: @c nullptr , @c static_assert , @c move / rvalue-reference emulation
 *  </td>
 * </tr><tr>
 *  <th>Backports</th>
 *  <td align="center"> @subpage cxx03-backports -- @subpage cxx11-backports --  @subpage cxx14-backports -- @subpage cxx17-backports --  @subpage cxx20-backports
 *  <br/> @subpage transparent-headers "Transparent Headers"
 *  </td>
 * </tr><tr>
 *  <th> Independent stuff </th>
 *  <td align="center">  @subpage cxxo:sup "Library Supplements" --  @subpage cxxo:extras "Extras"
 *  </td>
 * </tr>
 * </table>
 * 
 * 
 * 
 *
 * Also the library is organized according to the C++ Standard Header the features are pulled from:
 * 


 * <table>
 * <tr><td>+</td><th>C++</th><th> since C++11 </th><th> since C++14 </th><th> since C++17 </th>
 * </tr>
 * <tr><th> C Core </th>
 *  <td colspan="9" align="center"> @subpage std0cstddef "<cstddef>" -- @subpage std0cstdint "<cstdint>" -- @subpage std0cstdio "<cstdio>" </td>
 * </tr>
 * <tr><th> General C++ </th>
 * </td><td> @subpage std0functional "<functional>" -- @subpage std0memory "<memory>" <br/>
 * -- @subpage std0string "<string>" -- @subpage std0utility "<utility>" </td>
 * <td colspan="9"> @subpage std0random "<random>"  -- @subpage std0type_traits "<type_traits>"
 * </td>
 * </tr>
 * <tr><th> Generics </th>
 *  <td colspan="9" align="center"> @subpage std0algorithm "<algorithm>" -- @subpage std0numeric "<numeric>" -- @subpage std0iterator "<iterator>" </td>
 * </tr>
 * <tr><th> Containers lib </th>
 *  <td></td>
 *  <td colspan="9"> @subpage std0array "<array>" -- @subpage std0forward_list "<forward_list>" </td>
 * </tr>
 * <tr><th> I/O lib </th>
 *  <td colspan="9" align="center"> @subpage std0iostream "<iostream>" (TBD) -- @subpage std0iomanip "<iomanip>" (TBD) </td>
 * </tr>
 * <tr><th> Vocabulary </th>
 *  <td> @subpage std0functional "<functional>" </td>







 *  <td> @subpage std0memory "<memory>" -- @subpage std0tuple "<tuple>" </td>
 *  <td></td>
 *  <td> @subpage std0optional "<optional>" (TBD) -- @subpage std0variant "<variant>" (TBD) </td>
 * </tr>
 * </table>
 * 

 *

 * <table>
 * <tr><th colspan="9"> Usage </th></tr>
 * <tr><td> @subpage cxxomfort-installation "Installation" </td>
 *  <td> @subpage cxxomfort-behaviour "Configuration" </td>
 *  <td> @subpage cxxomfort-usage "Usage" </td>
 *  <th> @subpage cxxo:isr "Implementation Status" </th>
 * </tr>
 * </table>
 * .

 * 
 */

//
// Setup
#include "config.hpp"

//
// Main Features
//
// (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 "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
#include "util/type_traits.hpp" // basic type_traits
#include "library/sequences.hpp" // sequence helpers, seq_<T>()
#include "impl/regex-esc.hpp" // CXXO_R for raw regex patterns







































































#endif

Added cxxomfort/cxxomfort/docgen/install.hpp.









































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * @file install.hpp
 * @page cxxomfort-installation "Installation"
 *
 * Quick and dirty install:
 * 
 * <ol>
 * <li>Get @b Fossil 
 * </li>
 * <li><code>fossil clone http://ryan.gulix.cl/fossil.cgi/cxxomfort</code>
 * </li>
 * <li>Check dependencies and configurations for your compiler.
 * </li>
 * <li>Add <code>cxxomfort/cxxomfort</code> dir to compiler/project's search paths.
 * </li>
 * <li><code>#include <cxxomfort/cxxomfort.hpp></code>.
 * </li>
 * </ol>
 * 
 */

Added cxxomfort/cxxomfort/docgen/isr.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
/**
 * @page cxx03-backports
 * @brief Backports from C++03.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><functional></code>: @ref bind1st etc.
 * 
*
 */

/**
 * @page cxx11-backports
 * @brief Backports from C++11.
 * 
 * C++11 adds a large number of features such as variadic templates, @c constexpr , static asserts and much improved template support and metaprogramming.
 * 
 * A listing of some of the features backported:
 * 
 * * From core language: <code>#static_assert</code>, <code>#noexcept</code>, etc.
 * * From <code><cstddef></code>: @c #nullptr, @c std::nullptr_t etc.
 * * From <code><algorithm></code>: @c copy_if(), @c copy_n(), @c partition_copy(), @ref minmax(), @ref minmax_element(), etc.
 * * From <code><functional></code>: <code>@ref reference_wrapper</code>, @c ref() .
 * * From <code><memory></code>: @c addressof(), etc.
 * * From <code>\<numeric\></code>: @c iota() .
 * * From <code><random></code>: @c shuffle_order_engine and @c knuth_b , <code>#uniform_int_distribution</code>, etc.
 * * From <code><string></code>: <code>@ref to_string()</code> , @c stoul and siblings, etc.
 * * From <code><type_traits></code>: @c #decay, @c #enable_if, @c #conditional, etc.
 * * From <code><utility></code>: @c declval() , etc.
 * 
 * See also: @ref cxx03-backports @ref cxx14-backports @ref cxx17-backports .
 */

/**
 * @page cxx14-backports
 * @brief Backports from C++14.
 * 
 * C++14 adds a number of features regarding algorithms and function object support.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><algorithm></code>: @c equal(), @c mismatch(), etc.
 * * From <code><functional></code>: @link foo "Transparent Functors" @endlink .
 * * From <code><utility></code>: @c exchange() , @ref integer_sequence , etc.
 * 
 * See also: @ref cxx11-backports @ref cxx17-backports .
 */

/**
 * @page cxx17-backports
 * @brief Backports from C++17.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><cstddef></code>: <code>@ref byte</code> .
 * * From <code><numeric></code>: @c gcd(), @c lcm() .
 * * From <code><tuple></code>: @c make_from_tuple().
 * * From <code><type_traits></code>: @c @ref void_t .
 * * From <code><utility></code>: @c as_const(), etc.
 * * <code>@ref optional</code>.
 * 
 * See also: @ref cxx14-backports @ref cxx20-backports .
 */

/**
 * @page cxx20-backports
 * @brief Backports from C++20.
 * 
 * A listing of some of the features backported:
 * 
 * * From <code><type_traits></code>: @c @ref endian .
 *
 * See also: @ref cxx17-backports .
 */

/**
 * @page cxxo:sup Library Supplements
 * @brief Implementations and additions proper to the cxxomfort library.
 * 
 * The @b cxxomfort library does not only implement backports to C++ features; it also brings its own set of features to supplement various functionality that, for example, can not be backported to previous version in a meaningful fashion. 
 * 
 * Including the <code><cxxomfort/library.hpp></code> header and invoking the <code>cxxomfort::</code> namespace makes these features available.
 * 
 * Implementations included from here:
 * 
 * * @subpage cxxo:sup:algorithm "Supplements for <algorithm>"
 * * @subpage cxxo:sup:functional "Supplements for <functional>"
 * * @subpage cxxo:sup:numeric "Supplements for <numeric>"
 * * @subpage cxxo:sup:random "Supplements for <random>"
 * * @subpage cxxo:sup:string "Supplements for <string>"
 * * @subpage cxxo:sup:tuple "Supplements for <tuple>"
 * * @subpage cxxo:sup:type_traits "Supplements for <type_traits>"
 * 
 * * @subpage cxxo:FOREACH "FOREACH (foreach loop)"
 * * @subpage cxxo:i12n "I12N (Container Initialization)"
 * * @subpage cxxo:fixed_vector "Fixed vector"
 * * @subpage cxxo:fundamental "Fundamental"
 * * @subpage cxxo:typesafe_enum "Typesafe @c enum "
 * 
 * * @ref cxxo:pair03 "Pair"
 * * @ref cxxo:clstring "clString"
 * * @ref cxxo:type_name "type_name"
 * 
 */

/**
 * @page extra-features
 * @brief Non-automatic features of cxxomfort.
 */

cxxomfort/cxxomfort/extras.hpp became a regular file.

cxxomfort/cxxomfort/extras/14-assert.hpp became a regular file.

Changes to cxxomfort/cxxomfort/extras/array_ref.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
#ifndef CXXOMFORT_EXTRAS_ARRAY_REF_HPP
#define CXXOMFORT_EXTRAS_ARRAY_REF_HPP
/**
 * @file cxxomfort/extras/array_ref.hpp
 * @brief Implements array_ref proposal (n3334)
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * 
* For documentation see @link Features/Extras @endlink .
* 
* Reflection header: experimental/array_ref
* 
**/

#include <cxxomfort/base.hpp>
#include <iterator>
#include <stdexcept>
#include <vector>
#include <array>
#include <valarray>

#include <cxxomfort/library/fixed_vector.hpp>
#include <cxxomfort/extras/dynarray.hpp>

#define CXXOMFORT_IMPLEMENTS_n3334 CXXO_LIBRARY()

#if (defined(CXXOMFORT_NOTICES))
    #pragma message CXXO_NOTICE("enabled extras: array_ref<T> implementation")
#endif


namespace cxxomfort {
namespace extras {
namespace array_ref {

/**
 * @brief Array view for sequences, from n3334
 * @anchor array_ref
 * @ingroup extra-features
 * @sa n3334
 * 
 * A @c array_ref is a non-owning view of a sequence of 
 * *contiguous* elements via a simple {pointer+length} package.
 * 
 * It provides some of the same operatios available for readable
 * sequences, in particular begin() and end().
 * 
 * This implementation is intended to be used for sequences of 
 * const elements (ie.: template argument is <code>T const</code>).
 * 
**/
template <typename T>
class array_ref {
    public:
    typedef T       value_type;
    typedef typename std::add_const<T>::type * pointer;
    typedef typename std::add_const<T>::type * const_pointer;
    typedef T&                reference;
    typedef typename std::add_const<T>::type & const_reference;
    typedef ptrdiff_t    difference_type;
    typedef size_t       size_type;
    typedef T*           iterator;
    typedef T const*     const_iterator;
    typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
    
    public:
    
    CXXO_CONSTEXPR array_ref () CXXO_NOEXCEPT : ptr_(nullptr), len_(0) {}
    CXXO_CONSTEXPR array_ref (array_ref const& p) CXXO_NOEXCEPT : ptr_(p.ptr_), len_(p.len_) {}
    CXXO_CONSTEXPR array_ref (T const* p, size_t l) CXXO_NOEXCEPT : ptr_(p), len_(l) {}
    
    template <size_t N>
    explicit array_ref (T(&arr)[N]) CXXO_NOEXCEPT : 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_NOEXCEPT
    : ptr_(arr.data()), len_(arr.size()) {}
    
    // view ref from vector; should be a std::array conversion operator but can't in C++03, C++11
    template <typename Alloc>
    array_ref (std::vector<T,Alloc> const& vec) 
    : ptr_(std::addressof(vec[0])), len_(vec.size()) {}
    
    // view ref from valarray; should be a std::array conversion operator but can't in C++03, C++11
    array_ref (std::valarray<T> const& va) 
    : ptr_(std::addressof(va[0])), len_(va.size()) {}

    // view ref from dynarray; should be a std::array conversion operator but can't in C++11
    array_ref (::cxxomfort::extras::dynarray::dynarray<T> const& da) CXXO_NOEXCEPT
    : ptr_(da.data()), len_(da.size()) {}

    // view_ref from fixed_vector; should be a fixed_vector conversion operator but that would include extras from library.
    array_ref (::cxxomfort::fixed_vector<T> const& r) CXXO_NOEXCEPT 
    : ptr_(r.data()), len_(r.size()) {}

    // access to elements
    //reference       at (size_t len) { assert_range(len); return ptr_[len]; }
    const_reference at (size_t len) const { assert_range(len); return ptr_[len]; }
    //reference       operator[] (size_t len) CXXO_NOEXCEPT { return ptr_[len]; }
    const_reference operator[] (size_t len) const CXXO_NOEXCEPT { return ptr_[len]; }
    
    // view info
    //! @return size of the view as a @c size_t .
    size_t          size () const CXXO_NOEXCEPT { return len_; }
    //! @return @c bool .
    bool            empty () const CXXO_NOEXCEPT { return size() == 0; }
    //! @return pointer to the view's data.
    pointer         data () CXXO_NOEXCEPT { return ptr_; }
    //! @return pointer to the view's data.
    const_pointer   data () const CXXO_NOEXCEPT { return ptr_; }
    
    // iterators
    const_iterator  cbegin () const CXXO_NOEXCEPT { return ptr_; }
    const_iterator  cend () const CXXO_NOEXCEPT { return ptr_+len_; }
    const_iterator  begin () const CXXO_NOEXCEPT { return cbegin(); }
    const_iterator  end () const CXXO_NOEXCEPT { return cend(); }

    const_reverse_iterator    crbegin () const CXXO_NOEXCEPT { return const_reverse_iterator(ptr_+len_); }
    const_reverse_iterator    crend () const CXXO_NOEXCEPT { return const_reverse_iterator(ptr_); }
    const_reverse_iterator    rbegin () const CXXO_NOEXCEPT { return crbegin(); }
    const_reverse_iterator    rend () const CXXO_NOEXCEPT { 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 assert_range (size_t len) const {
        if (len>=len_) throw std::out_of_range("array_ref: out of range");
    }
    
    const_pointer   ptr_;
    size_t const    len_;
}; // array_ref

template <typename Ty, size_t N>
array_ref<Ty> make_array_ref(Ty(&arr)[N]) {
    return array_ref<Ty>(arr);
}

template <typename Ty, size_t N>
array_ref<Ty> make_array_ref(std::array<Ty,N> const& a) {
    return array_ref<Ty>(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 Ty>
array_ref<Ty> make_array_ref(::cxxomfort::extras::dynarray::dynarray<Ty> const& v) {
    return array_ref<Ty>(v);
}

} // namespace array_ref
} // namespace extras
}

#endif


<
<
<
<
<
<
<
<
<
<
<

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

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
1
2











3





4
5






6
























































































































































#ifndef CXXOMFORT_EXTRAS_ARRAY_REF_HPP
#define CXXOMFORT_EXTRAS_ARRAY_REF_HPP











#include <cxxomfort/base.hpp>





#pragma message CXXO_WARNING("deprecated header. New header is <cxxomfort/library/array_ref.hpp>")
#include <cxxomfort/library/array_ref.hpp>






#endif
























































































































































cxxomfort/cxxomfort/extras/auto-impl.hpp became a regular file.

cxxomfort/cxxomfort/extras/auto.hpp became a regular file.

Changes to cxxomfort/cxxomfort/extras/dynarray.hpp.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


// To invoke this via a std header see cstd/dynarray.

// TBD: implement option to have dynarray be copy assignable

#include <cxxomfort/base.hpp>
#include <cxxomfort/sequences.hpp> // is_iterator
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <memory>
#define CXXOMFORT_IMPLEMENTS_n2648 CXXO_LIBRARY()

//







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


// To invoke this via a std header see cstd/dynarray.

// TBD: implement option to have dynarray be copy assignable

#include <cxxomfort/base.hpp>
#include <cxxomfort/library/sequences.hpp> // is_iterator
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <memory>
#define CXXOMFORT_IMPLEMENTS_n2648 CXXO_LIBRARY()

//

Changes to cxxomfort/cxxomfort/extras/foreach.hpp.


1
2

#pragma message CXXO_WARNING("this header is deprecated. New header is <cxxomfort/library/foreach.hpp>")
#include <cxxomfort/library/foreach.hpp>
>
|

1
2
3
#include <cxxomfort/base.hpp>
#pragma message CXXO_WARNING("deprecated header. New header is <cxxomfort/library/foreach.hpp>")
#include <cxxomfort/library/foreach.hpp>

Changes to cxxomfort/cxxomfort/extras/forward_list.hpp.


1
2

#pragma message CXXO_WARNING("this header is deprecated. New header is <cxxomfort/forward_list.hpp>")
#include <cxxomfort/forward_list.hpp>
>
|

1
2
3
#include <cxxomfort/base.hpp>
#pragma message CXXO_WARNING("deprecated header. New header is <cxxomfort/forward_list.hpp>")
#include <cxxomfort/forward_list.hpp>

Changes to cxxomfort/cxxomfort/extras/localfn.hpp.


1
2

#pragma message CXXO_WARNING("this header is deprecated. New header is <cxxomfort/library/localfn.hpp>")
#include <cxxomfort/library/localfn.hpp>
>
|

1
2
3
#include <cxxomfort/base.hpp>
#pragma message CXXO_WARNING("deprecated header. New header is <cxxomfort/library/localfn.hpp>")
#include <cxxomfort/library/localfn.hpp>

Changes to cxxomfort/cxxomfort/extras/observer_ptr.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef CXXOMFORT_EXTRAS_OBSERVER_PTR_HPP
#define CXXOMFORT_EXTRAS_OBSERVER_PTR_HPP
/**
 * @file cxxomfort/extras/observer_ptr.hpp
 * @brief Implements observer_ptr proposal (n3840)
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * 
* For documentation see @link Features/Extras @endlink .
* 
* Reflection header: experimental/memory (to be mapped in cstd)
* 
**/

#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n3840 CXXO_BACKPORT()
................................................................................

namespace cxxomfort {
namespace extras {
namespace observer_ptr {

/**
 * @brief observer_ptr - the world's dumbest smart pointer
 * @ingroup extra-features
 * @ref memory
 * 
 * @c observer_ptr  is a simple "pointer wrapper" type that manages a 
 * non-owning pointer. No further "intelligence" is added to the wrapper's 
 * behaviour. It is added to C++17 as an "experimental".
 * 
 * @sa n3840
 * 




<


|







 







|
|







1
2
3
4

5
6
7
8
9
10
11
12
13
14
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef CXXOMFORT_EXTRAS_OBSERVER_PTR_HPP
#define CXXOMFORT_EXTRAS_OBSERVER_PTR_HPP
/**
 * @file cxxomfort/extras/observer_ptr.hpp

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * 
* For documentation see @link cxxo:extras Extras @endlink .
* 
* Reflection header: experimental/memory (to be mapped in cstd)
* 
**/

#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n3840 CXXO_BACKPORT()
................................................................................

namespace cxxomfort {
namespace extras {
namespace observer_ptr {

/**
 * @brief observer_ptr - the world's dumbest smart pointer
 * @ingroup cxxo:extras
 * @ref std0memory
 * 
 * @c observer_ptr  is a simple "pointer wrapper" type that manages a 
 * non-owning pointer. No further "intelligence" is added to the wrapper's 
 * behaviour. It is added to C++17 as an "experimental".
 * 
 * @sa n3840
 * 

Changes to cxxomfort/cxxomfort/extras/optional-impl.hpp.

267
268
269
270
271
272
273

274
275
276
277
278
279
280
//
template <typename T>
class optional_impl<T, typename std::enable_if<std::is_fundamental<T>::value>::type > {
    private:
    typedef T       storage_type;
    protected:
    typedef T       value_type;

    static const bool is_specialized = true;

    CXXO_CONSTEXPR optional_impl () CXXO_NOEXCEPT
    : _engaged(false) {}
    // trivially copyable
#if (CXXOMFORT_CXX_STD >= 2011)
    constexpr optional_impl (optional_impl const&) noexcept = default;







>







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
//
template <typename T>
class optional_impl<T, typename std::enable_if<std::is_fundamental<T>::value>::type > {
    private:
    typedef T       storage_type;
    protected:
    typedef T       value_type;
    typedef optional<T>  optional_type;
    static const bool is_specialized = true;

    CXXO_CONSTEXPR optional_impl () CXXO_NOEXCEPT
    : _engaged(false) {}
    // trivially copyable
#if (CXXOMFORT_CXX_STD >= 2011)
    constexpr optional_impl (optional_impl const&) noexcept = default;

cxxomfort/cxxomfort/extras/optional-io.hpp became a regular file.

Changes to cxxomfort/cxxomfort/extras/optional.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef CXXOMFORT_EXTRAS_OPTIONAL_HPP
#define CXXOMFORT_EXTRAS_OPTIONAL_HPP
/**
 * @file cxxomfort/extras/optional.hpp
 * @brief Implementation of <code>optional<T></code> proposal.
 */

/*
 *
 * Optional as per C++ Proposal (n1878):
 * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1878.htm
 * Also incorporates some implementation details and fixes from n3527
 * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3527.html
 *


<
<
<
<
<







1
2





3
4
5
6
7
8
9
#ifndef CXXOMFORT_EXTRAS_OPTIONAL_HPP
#define CXXOMFORT_EXTRAS_OPTIONAL_HPP





/*
 *
 * Optional as per C++ Proposal (n1878):
 * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1878.htm
 * Also incorporates some implementation details and fixes from n3527
 * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3527.html
 *

Changes to cxxomfort/cxxomfort/forward_list.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
#ifndef CXXOMFORT_FORWARD_LIST_HPP
#define CXXOMFORT_FORWARD_LIST_HPP
/**
 * @file
 * @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.
//
................................................................................
    };
    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.




<










|







 







|
>







1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef CXXOMFORT_FORWARD_LIST_HPP
#define CXXOMFORT_FORWARD_LIST_HPP
/**
 * @file

 * @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 <code><forward_list></code> is
 * provided in cstd/ directory.
 *
 *
**/
// An implementation of forward_list<> based off
// my former ListaEnlazada class.
//
................................................................................
    };
    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 cxx11-backports
 * @xrefitem std0forwardlist "" ""
 *
 * 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.

Changes to cxxomfort/cxxomfort/functional.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
..
29
30
31
32
33
34
35
36












37
#ifndef CXXOMFORT_FUNCTIONAL_HPP
#define CXXOMFORT_FUNCTIONAL_HPP

/**
 * @file cxxomfort/functional.hpp
 * @brief Implementations and additions tied to <functional>.
 * 
 * Interfaces defined in this file:
 *
 * * bit_and, bit_or, bit_not as per C++14.
 * * transparent plus, minus, multiplies, divides, modulus as per C++14.
 *
 */
................................................................................
}
}


#include "./impl/14-functional-transparent.hpp"
//#include "./impl/17-notfn.hpp"
//#include "./impl/03-restore_binders.hpp"













#endif





<







 








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

1
2
3
4
5

6
7
8
9
10
11
12
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef CXXOMFORT_FUNCTIONAL_HPP
#define CXXOMFORT_FUNCTIONAL_HPP

/**
 * @file cxxomfort/functional.hpp

 * 
 * Interfaces defined in this file:
 *
 * * bit_and, bit_or, bit_not as per C++14.
 * * transparent plus, minus, multiplies, divides, modulus as per C++14.
 *
 */
................................................................................
}
}


#include "./impl/14-functional-transparent.hpp"
//#include "./impl/17-notfn.hpp"
//#include "./impl/03-restore_binders.hpp"

/**
 * @page std0functional
 * @brief Implementations and additions tied to <functional>.
 * 
 * Interfaces defined in this file:
 * 
 * * <code>@ref reference_wrapper</code>, @c ref(), @c cref() (C++11)
 * * @c Transparent / Heterogegenous Functors (C++14)
 *
 */


#endif

Added cxxomfort/cxxomfort/impl/03-array.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_03_STD_ARRAY_HPP
#define CXXOMFORT_IMPL_03_STD_ARRAY_HPP
/**
 * @file
 * 
 */
#include "./base.hpp"
#include CXXO_INCLUDE_SYS(iterator)
#include CXXO_INCLUDE_SYS(algorithm)


namespace cxxomfort {
namespace cxxostd {

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

template <typename T, size_t N>
struct array {
    static_assert (N , "array<T,N> with N>0");
    
    typedef T value_type;
    enum{ const_size = N};
    
    typedef typename add_pointer<T>::type    pointer;
    typedef T const           const_value_type;
    typedef typename add_pointer<const_value_type>::type const_pointer;
    typedef pointer           iterator;
    typedef const_pointer     const_iterator;
    typedef typename std::reverse_iterator<iterator>::type reverse_iterator;
    typedef typename std::reverse_iterator<const_iterator>::type const_reverse_iterator;
    
    
    pointer    data () CXXO_NOEXCEPTNOTHROW { return elems; }
    const_pointer data () const CXXO_NOEXCEPTNOTHROW { return elems; }
    size_t     size () const CXXO_NOEXCEPTNOTHROW { return N; }
    size_t     max_size () const CXXO_NOEXCEPTNOTHROW { return N; }
    bool       empty () const CXXO_NOEXCEPTNOTHROW { return false; }

    T&       operator[] (size_t i) CXXO_NOEXCEPTNOTHROW { return elems[i]; }
    T const& operator[] (size_t i) const CXXO_NOEXCEPTNOTHROW { return elems[i]; }
    
    iterator        begin () CXXO_NOEXCEPT { return elems; }
    const_iterator  begin () const CXXO_NOEXCEPT { return elems; }
    iterator        end () CXXO_NOEXCEPT { return elems+N; }
    const_iterator  end () const CXXO_NOEXCEPT { return elems+N; }
    
    void fill (T const& t) {
        std::fill(this->begin(), this->end(), t);
    }
    
    
    private:
    T elems[N];
};


}
}

#if (CXXOMFORT_CXX_STD < 2011 && defined(CXXOMFORT_NO_TR1))
namespace std { namespace tr1 {
    using cxxomfort::cxxostd::array;
}}
#endif

#endif

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

1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_IMPL_STD_BIT_HPP
#define CXXOMFORT_IMPL_STD_BIT_HPP
/**
 * @file
 * @brief c++03 fixes to <functional> in incomplete implementations
 * 
 */
#include "./base.hpp"
#include CXXO_INCLUDE_SYS(functional)

// fix missing bit_and, bit_or, bit_xor in MSVC 2008
#if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC && CXXOMFORT_COMPILER_VERSION <= 150)




<







1
2
3
4

5
6
7
8
9
10
11
#ifndef CXXOMFORT_IMPL_STD_BIT_HPP
#define CXXOMFORT_IMPL_STD_BIT_HPP
/**
 * @file

 * 
 */
#include "./base.hpp"
#include CXXO_INCLUDE_SYS(functional)

// fix missing bit_and, bit_or, bit_xor in MSVC 2008
#if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC && CXXOMFORT_COMPILER_VERSION <= 150)

Changes to cxxomfort/cxxomfort/impl/03-random_renames.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
..
45
46
47
48
49
50
51
52
53
54
#ifndef CXXOMFORT_IMPL_RANDOM_RENAMES_HPP
#define CXXOMFORT_IMPL_RANDOM_RENAMES_HPP
/**
 * @file
 */

#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) && (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC||CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG))
#if !defined(__GXX_EXPERIMENTAL_CXX0X__)
namespace std {
namespace tr1 {

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
















//! @ingroup cxx11-backports
template <typename II, II _w, II _s, II _r>
class subtract_with_carry_engine 



: public subtract_with_carry<II,_w,_s,_r> {
    public:
    typedef typename subtract_with_carry<II,_w,_s,_r>::result_type result_type;















    subtract_with_carry_engine(result_type s=0) 
    : subtract_with_carry<II,_w,_s,_r>(s) {}
















};


typedef subtract_with_carry_engine<uint_fast32_t, 24,10,24> ranlux24_base;


//! @ingroup cxx11-backports
template <typename II>
class uniform_int_distribution
: public uniform_int<II> {
    public:
    uniform_int_distribution(II a, II b)
................................................................................
    : uniform_real<Real>(a,b) {}
};


} // namespace tr1
} // namespace std

#endif // c++0x emulation
#endif // fix
#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
..
95
96
97
98
99
100
101

102
103
#ifndef CXXOMFORT_IMPL_RANDOM_RENAMES_HPP
#define CXXOMFORT_IMPL_RANDOM_RENAMES_HPP
/**
 * @file
 */

#include "../base.hpp"
#include <random>
//#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.

template<class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
class linear_congruential_engine 
: public linear_congruential<_UIntType, __a, __c, __m> {
    private:
    typedef linear_congruential<_UIntType, __a, __c, __m> base_type;
    public:
    using base_type::result_type;
    explicit linear_congruential_engine (unsigned long sd=1)
    : base_type(sd) {}
};

// mt19937
// mt19937_64

#if (1)
//! @ingroup cxx11-backports
template <typename II, II _w, II _s, II _r>
class subtract_with_carry_engine 
/* : protected subtract_with_carry<II,_w,_s,_r>  */
{
    private:
    typedef subtract_with_carry<II,_w,_s,_r> base_type;
    public:
    typedef typename base_type::result_type result_type;
    explicit subtract_with_carry_engine (result_type sd=0) 
    // : base_type(sd) {}
    : _P(sd) {}

    void seed ( result_type value = base_type::default_seed ) { _P.seed(value); }
    result_type operator() () { return _P(); }
    void discard (unsigned int z) { _P.discard(z); } 
    result_type min () const { return _P.min(); }
    result_type max () const { return _P.max(); }

    private:
    base_type _P;
};
#else
template <typename II, II _w, II _s, II _r>
class subtract_with_carry_engine 
: private subtract_with_carry<II,_w,_s,_r> 
{
    private:
    typedef subtract_with_carry<II,_w,_s,_r> base_type;
    public:
    using base_type::result_type;
    explicit subtract_with_carry_engine (result_type sd=0) 
    : base_type(sd) {}

    template <typename G>
    explicit subtract_with_carry_engine (G& g) 
    : base_type(g) {}

    using base_type::min;
    using base_type::max;
    using base_type::seed;
    using base_type::operator();
};
#endif

typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base;
typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12> ranlux48_base;

//! @ingroup cxx11-backports
template <typename II>
class uniform_int_distribution
: public uniform_int<II> {
    public:
    uniform_int_distribution(II a, II b)
................................................................................
    : uniform_real<Real>(a,b) {}
};


} // namespace tr1
} // namespace std


#endif // fix
#endif

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

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


22
23
24
25
26
27
28
..
31
32
33
34
35
36
37


38
39
40
41
42
43
44
45
46
47
48
#include "../config.hpp"

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION==0)
    #define CXXOMFORT_USING_addressof
#endif // c++11

namespace cxxomfort {
namespace memory {

/**
 * @brief Returns the address of an object.
 * @ingroup cxx11-backports


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

//! @overload addressof
................................................................................
    return reinterpret_cast<T const*>(&reinterpret_cast<char const&> (arg) );
}

} // memory
} // cxxomfort




#if defined(CXXOMFORT_USING_addressof)

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

#else
    // nothing to do
#endif

#endif // file







|




>
>







 







>
>
|
<
|
|
|
<
|
<



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
33
34
35
36
37
38
39
40
41
42

43
44
45

46

47
48
49
#include "../config.hpp"

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION==0)
    #define CXXOMFORT_USING_addressof
#endif // c++11

namespace cxxomfort {
namespace cxxostd {

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

//! @overload addressof
................................................................................
    return reinterpret_cast<T const*>(&reinterpret_cast<char const&> (arg) );
}

} // memory
} // cxxomfort


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

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

    #endif

#endif

#endif // file

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

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
..
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
..
68
69
70
71
72
73
74

































75
76
77
78
79
80
 * That however is an intrinsic, so it has to be detected on a per-compiler basis.
 * For compilers without __alignof(), we can usually do "well enough" by reserving 
 * [2*sizeof(T)+1] for compound types, and [sizeof(T)] for fundamental types.
 */


namespace cxxomfort {
namespace memory {
#if 0

#elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC) \
 || (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG)
    #if (CXXOMFORT_COMPILER_VERSION<=406) // align(N) can only take literals

template <size_t S, size_t A = -1> struct aligned_storage;
#define ALIGNED_STORAGE_ALIGN(N) \
template <size_t S> struct aligned_storage<S, N > { \
    typedef struct { unsigned char __attribute__((aligned( N ))) elem[S]; } type; \

}
ALIGNED_STORAGE_ALIGN(1);
ALIGNED_STORAGE_ALIGN(2);
ALIGNED_STORAGE_ALIGN(4);
ALIGNED_STORAGE_ALIGN(8);
ALIGNED_STORAGE_ALIGN(16);
ALIGNED_STORAGE_ALIGN(32);
................................................................................
    #endif // gcc

#elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC) // declspec(N) can only take literals

template <size_t S, size_t A = -1> struct aligned_storage;
#define ALIGNED_STORAGE_ALIGN(N) \
template <size_t S> struct aligned_storage<S, N > { \
    typedef struct __declspec(align( N )) { unsigned char elem[S]; } type;  \

}

ALIGNED_STORAGE_ALIGN(1);
ALIGNED_STORAGE_ALIGN(2);
ALIGNED_STORAGE_ALIGN(4);
ALIGNED_STORAGE_ALIGN(8);
ALIGNED_STORAGE_ALIGN(16);
................................................................................
#undef ALIGNED_STORAGE_ALIGN
#define CXXO_DEFINED_ALIGNED_STORAGE

#else // unrecognized compiler
#error "Unknown support status for aligned_storage"

#endif // support for aligned_storage


































} // memory
} // cxxomfort


#endif // file







|









|
>







 







|
>







 







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






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
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
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
 * That however is an intrinsic, so it has to be detected on a per-compiler basis.
 * For compilers without __alignof(), we can usually do "well enough" by reserving 
 * [2*sizeof(T)+1] for compound types, and [sizeof(T)] for fundamental types.
 */


namespace cxxomfort {
namespace cxxostd {
#if 0

#elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC) \
 || (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG)
    #if (CXXOMFORT_COMPILER_VERSION<=406) // align(N) can only take literals

template <size_t S, size_t A = -1> struct aligned_storage;
#define ALIGNED_STORAGE_ALIGN(N) \
template <size_t S> struct aligned_storage<S, N > { \
    typedef struct { unsigned char __attribute__((aligned( N ))) data[S]; } \
    type; \
}
ALIGNED_STORAGE_ALIGN(1);
ALIGNED_STORAGE_ALIGN(2);
ALIGNED_STORAGE_ALIGN(4);
ALIGNED_STORAGE_ALIGN(8);
ALIGNED_STORAGE_ALIGN(16);
ALIGNED_STORAGE_ALIGN(32);
................................................................................
    #endif // gcc

#elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC) // declspec(N) can only take literals

template <size_t S, size_t A = -1> struct aligned_storage;
#define ALIGNED_STORAGE_ALIGN(N) \
template <size_t S> struct aligned_storage<S, N > { \
    typedef struct __declspec(align( N )) { unsigned char elem[S]; } \
    type;  \
}

ALIGNED_STORAGE_ALIGN(1);
ALIGNED_STORAGE_ALIGN(2);
ALIGNED_STORAGE_ALIGN(4);
ALIGNED_STORAGE_ALIGN(8);
ALIGNED_STORAGE_ALIGN(16);
................................................................................
#undef ALIGNED_STORAGE_ALIGN
#define CXXO_DEFINED_ALIGNED_STORAGE

#else // unrecognized compiler
#error "Unknown support status for aligned_storage"

#endif // support for aligned_storage


#if (0 && !defined(CXXOMFORT_ALIGNMENT_TOOLS_SUPPORTED))
template <size_t S, size_t A = -1> struct aligned_storage {
    typedef union { 
        unsigned char storage[S]; 
        struct struct_;
        double dd[2]; 
        long double ld;
        double d;
        long l;
        int i;
        char c;
        void (*fn_a)();
        int struct_::memobj;
        double (struct_::*memfn)(int);
    } type;
};
#else
    #if defined(__GNUC__) && (CXXOMFORT_COMPILER_VERSION >= 406)
    // in GCC >= 4.6, __attribute__(aligned) can take compile-time constants
    #elif defined(__GNUC__) && (CXXOMFORT_COMPILER_VERSION >= 402)
    // in GCC >= 4.2, __attribute__(aligned) can only take numeric literals
    #elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG) 
    // in MSC (tested versions), __declspec(aligned) can only take numeric literals

    #elif defined(_MSC_VER)
    #else
    #error ("Unidentified method for aligned_storage.");

    #endif
#endif


} // memory
} // cxxomfort


#endif // file

Changes to cxxomfort/cxxomfort/impl/11-conditional.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
#include "../config.hpp"

#if (CXXOMFORT_CXX_STD < 2011)
    #define CXXOMFORT_USING_conditional
#endif

namespace cxxomfort {
namespace type_traits {







template <bool B, typename T=void>
struct enable_if{};

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







template <bool B, typename T, typename U>
struct conditional {};

template <typename T, typename U>
struct conditional<false,T,U> { typedef U type; };

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

} // type_traits
} // cxxomfort




#if (CXXO_COMPILER_SUPPORT_conditional_enableif==0)
namespace std {
    using ::cxxomfort::type_traits::enable_if;
    using ::cxxomfort::type_traits::conditional;
}
#endif


#endif // file







|

>
>
>
>
>
>








>
>
>
>
>
>











>
>
>



|
|

|
>


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

#if (CXXOMFORT_CXX_STD < 2011)
    #define CXXOMFORT_USING_conditional
#endif

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief Metaprogramming helper that defines a @c type only if a condition holds.
 * @ingroup cxx11-backports
 * @xrefitem std0type_traits "<type_traits>" ""
 * @xrefitem std:tr1 "" ""
 */
template <bool B, typename T=void>
struct enable_if{};

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

/**
 * @brief Metaprogramming helper that defines a @c type to be either @a T or @a U.
 * @ingroup cxx11-backports
 * @xrefitem std0type_traits "<type_traits>" ""
 * @xrefitem std:tr1 "" ""
 */
template <bool B, typename T, typename U>
struct conditional {};

template <typename T, typename U>
struct conditional<false,T,U> { typedef U type; };

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

} // type_traits
} // cxxomfort

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

#if (CXXO_COMPILER_SUPPORT_conditional_enableif==0)
namespace std {
    using ::cxxomfort::cxxostd::enable_if;
    using ::cxxomfort::cxxostd::conditional;
}
#endif // support
#endif // no std using

#endif // file

Added cxxomfort/cxxomfort/impl/11-decay.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
#ifndef CXXOMFORT_IMPL_DECAY_HPP
#define CXXOMFORT_IMPL_DECAY_HPP

/**
 * @file
 */

#include <cxxomfort/config.hpp>

// obtained directly from cppreference.

namespace cxxomfort {
namespace cxxostd {
template< typename T >
struct decay {
    private:
    typedef typename std::remove_reference<T>::type U;
    public:
    typedef typename std::conditional< 
        std::is_array<U>::value,
        typename std::remove_extent<U>::type*,
        typename std::conditional< 
            std::is_function<U>::value,
            typename std::add_pointer<U>::type,
            typename std::remove_cv<U>::type
        >::type
    >::type type;
};


} // cxxostd
}

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2011 /* && CXXO_COMPILER_SUPPORT_tr1_type_traits==0 */ )
    namespace std {
        using ::cxxomfort::cxxostd::decay;
    }
    #endif
#endif

#endif

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

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

16
17
18
19
20
21
22
..
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80


 * @file
 */

#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n2569 CXXO_BACKPORT()

namespace cxxomfort {
namespace algorithm {

/**
 * @ingroup algorithm
 * @ingroup cxx11-backports

 * @sa n2569
 * @{
 */

/**
 * @brief Returns @c true  if all elements in sequence <var>[ini,fin)</var> comply with predicate @p p .
 * @param p A predicate (a function that returns @c true or @c false ).
................................................................................
 * @}
 */

} // cxxomfort::algorithm
} // cxxomfort


#if (!defined(CXXOMFORT_NO_STD_USING))

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

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










|




>







 







|
>

|
|
|
|
|
|
|
|




<

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

#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n2569 CXXO_BACKPORT()

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup algorithm
 * @ingroup cxx11-backports
 * @xrefitem std0algorithm "<algorithm>" ""
 * @sa n2569
 * @{
 */

/**
 * @brief Returns @c true  if all elements in sequence <var>[ini,fin)</var> comply with predicate @p p .
 * @param p A predicate (a function that returns @c true or @c false ).
................................................................................
 * @}
 */

} // cxxomfort::algorithm
} // cxxomfort


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

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



#endif

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

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
..
32
33
34
35
36
37
38

39



40
41
42
43
44
45
46
..
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
 * @file
 */

#include <cxxomfort/config.hpp>

namespace cxxomfort {
namespace algorithm {

/**
 * @ingroup algorithm
 * @ingroup cxx11-backports

 * @sa n2569
 * @{
 */

//
// minmax, minmax_element
//

//! return a <code>pair(min,max)</code> from two arguments and a comparator @a Less .
template <typename T, typename Comparator>
std::pair<T const&, T const&> minmax (T const& a, T const& b, Comparator Less) {
    return Less(b,a) ? 
    std::pair<T const&, T const&>(b, a) : std::pair<T const&, T const&>(a, b)
    ;
}
................................................................................
template <typename T>
std::pair<T const&, T const&> minmax (T const& a, T const& b)  {
    return (b < a) ? 
    std::pair<T const&,T const&>(b, a) : std::pair<T const&,T const&>(a, b)
    ;
}


//! Returns the pair (minimum,maximum) for the given sequence and comparator @p less .



template <typename FIterator, typename Comparator>
std::pair<FIterator,FIterator> 
minmax_element (FIterator ini, FIterator fin, Comparator less) {
    std::pair<FIterator, FIterator> result(ini, fin);
 
    if (ini == fin) return result;
    if (++ini == fin) return result;
................................................................................
 * @}
 */

} // cxxomfort::algorithm
} // cxxomfort


#if (!defined(CXXOMFORT_NO_STD_USING))

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC && CXXOMFORT_COMPILER_VERSION >=404 && CXXOMFORT_COMPILER_VERSION < 600 && CXXOMFORT_CXX_EMULATION==2011 )
    // GCC already has defined these in 4.4-4.6 c++0x mode
    #else
namespace std {
    using ::cxxomfort::algorithm::minmax;
    using ::cxxomfort::algorithm::minmax_element;
}

    #endif

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








|


<

>




<
<
<
<







 







>
|
>
>
>







 







|
>





|
|








3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18




19
20
21
22
23
24
25
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
 * @file
 */

#include <cxxomfort/config.hpp>

namespace cxxomfort {
namespace cxxostd {

/**

 * @ingroup cxx11-backports
 * @xrefitem std0algorithm "" ""
 * @sa n2569
 * @{
 */





//! return a <code>pair(min,max)</code> from two arguments and a comparator @a Less .
template <typename T, typename Comparator>
std::pair<T const&, T const&> minmax (T const& a, T const& b, Comparator Less) {
    return Less(b,a) ? 
    std::pair<T const&, T const&>(b, a) : std::pair<T const&, T const&>(a, b)
    ;
}
................................................................................
template <typename T>
std::pair<T const&, T const&> minmax (T const& a, T const& b)  {
    return (b < a) ? 
    std::pair<T const&,T const&>(b, a) : std::pair<T const&,T const&>(a, b)
    ;
}

/**
 * @brief Returns the pair (minimum,maximum) for the given sequence and comparator @p less .
 * @param less A comparator object with the same semantics as <code>std::less</code> .
 * @return A <code>std::pair</code> containing the minimum and maximum.
 */
template <typename FIterator, typename Comparator>
std::pair<FIterator,FIterator> 
minmax_element (FIterator ini, FIterator fin, Comparator less) {
    std::pair<FIterator, FIterator> result(ini, fin);
 
    if (ini == fin) return result;
    if (++ini == fin) return result;
................................................................................
 * @}
 */

} // cxxomfort::algorithm
} // cxxomfort


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC && CXXOMFORT_COMPILER_VERSION >=404 && CXXOMFORT_COMPILER_VERSION < 600 && CXXOMFORT_CXX_EMULATION==2011 )
    // GCC already has defined these in 4.4-4.6 c++0x mode
    #else
namespace std {
    using ::cxxomfort::cxxostd::minmax;
    using ::cxxomfort::cxxostd::minmax_element;
}

    #endif

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

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

3
4
5
6
7
8
9
10
11

12
13


14
15

16
17
18
19
20
21
22
..
93
94
95
96
97
98
99
100


101
102
103
104
105
106
107
108
109
110
111
112
113
/**
 * @file
 */
#include <algorithm>
#include <utility>

namespace cxxomfort {
namespace algorithm {


/* Returns true if range [iniA,finA] (with internally calculated finA) 
 * is a permutation of range [ini1,fin1).


 * Source: cppreference.com
 */

template <typename It1, typename ItA>
bool is_permutation (It1 ini1, It1 fin1, ItA iniA) {
    using namespace std;
    // skip common prefix
    pair<It1&,ItA&>(ini1,iniA) = mismatch(ini1,fin1,iniA);
    if (ini1!=fin1) {
        // there is a mismatch
................................................................................
    std::less<typename std::iterator_traits<BidirIt>::value_type> less;
    return prev_permutation(ini, fin, less);
}

} // cxxomfort::algo
} // cxxomfort

#if (!defined(CXXOMFORT_NO_STD_USING))


#if (CXXOMFORT_CXX_STD < 2011)
namespace std {
// [next,prev]_permutation already present in GCC >= 4.4 as an extension
#if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_GCC && CXXOMFORT_COMPILER_VERSION < 404)
    using ::cxxomfort::algorithm::is_permutation;
    using ::cxxomfort::algorithm::prev_permutation;
    using ::cxxomfort::algorithm::next_permutation;
#endif

}
#endif // c++11
#endif // std using
#endif







|

>
|

>
>

<
>







 







|
>
>

|
|
|
|
|
|
|

|



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

18
19
20
21
22
23
24
25
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
 * @file
 */
#include <algorithm>
#include <utility>

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief Returns true if range [iniA,finA] (with internally calculated finA) 
 * is a permutation of range [ini1,fin1).
 * @ingroup cxx11-backports
 * @xrefitem std:algorithm "<algorithm>" ""
 * Source: cppreference.com

 * **/
template <typename It1, typename ItA>
bool is_permutation (It1 ini1, It1 fin1, ItA iniA) {
    using namespace std;
    // skip common prefix
    pair<It1&,ItA&>(ini1,iniA) = mismatch(ini1,fin1,iniA);
    if (ini1!=fin1) {
        // there is a mismatch
................................................................................
    std::less<typename std::iterator_traits<BidirIt>::value_type> less;
    return prev_permutation(ini, fin, less);
}

} // cxxomfort::algo
} // cxxomfort

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

#if (CXXOMFORT_CXX_STD < 2011)
    namespace std {
    // [next,prev]_permutation already present in GCC >= 4.4 as an extension
    #if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_GCC && CXXOMFORT_COMPILER_VERSION < 404)
        using ::cxxomfort::cxxostd::is_permutation;
        using ::cxxomfort::cxxostd::prev_permutation;
        using ::cxxomfort::cxxostd::next_permutation;
    #endif

    }
#endif // c++11
#endif // std using
#endif

Changes to cxxomfort/cxxomfort/impl/11-to_string.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
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
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
...
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
#ifndef CXXOMFORT_IMPL_STRING_HPP
#define CXXOMFORT_IMPL_STRING_HPP
/**
 * @file
 * @brief Implements the "to_string" functionality.
 *
 * This file implements the template function "to_string", 
 * which converts a builtin integral type to a decimal representation 
 * in a @c std::string , and the template functions "stoul" and "stoi" which 
 * perform the inverse function.
 * 
 * Interfaces defined in this file:
 * 
 * @arg @c std::to_string  (for integral types)
 * @arg @c std::sto[u]l[l] (for integral types)
 * 
 * This version of "to_string" has only support for integral types, 
 * eg.: @c int , @c short and similar. Floating-point type support 
 * or wstring support are not yet available.
 * 
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/util/type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>
#include <cstdio>
#include <cstdlib>
................................................................................
        //char *e= b + vstr.size();
        ret = _pfn( b, &eipos, _b);
        int err= errno;
        const std::string throwmsg= std::string("string2integral: conversion of string \"") + _s + "\" to integral";
        if (err==ERANGE) throw out_of_range( throwmsg );
        else if (err==EINVAL || eipos==b) throw invalid_argument( "string2integral: invalid argument in call to");
        //std::cerr<< "[err="<< err<< "]"<< std::endl;
        if (_p) *_p = (eipos - b);
        return ret;
    }

    private:
    std::string const& _s;
    string_to_integral& operator= (string_to_integral const&);

................................................................................
    const int _b;
    convertfn _pfn;
};


} //cxxomfort::cxxostd::detail_string



/**
 * @brief Returns a @c string expression of an integral.

 * @ingroup cxx11-backports


 */






static inline std::string to_string (unsigned short u) {
    return detail_string::stringexpr(u);
}
//! @overload to_string
static inline std::string to_string (long long i) {
    return detail_string::stringexpr(i);
}
//! @overload to_string
static inline std::string to_string (unsigned long long u) {
    return detail_string::stringexpr(u);
}
//! @overload to_string
static inline std::string to_string (long double i) {
    return detail_string::stringexpr(i);
}
................................................................................

std::wstring to_wstring (int i) {
    return detail::stringexpr(i);
}
*/



static inline unsigned long       stoul (std::string const& str, size_t* pinv, int base=10) {
    return detail_string::string_to_integral<unsigned long>(str,pinv,base);
//    return strtoul (str.c_str(), pinv, base);
}


static inline unsigned long long  stoull (std::string const& str, size_t* pinv, int base=10) {
    return detail_string::string_to_integral<unsigned long long>(str,pinv,base);
//    return strtoull (str.c_str(), pinv, base);
}


static inline signed long         stol (std::string const& str, size_t * pinv, int base=10) {
    return detail_string::string_to_integral<signed long>(str,pinv,base);
//    return strtol (str.c_str(), pinv, base);
}


static inline signed long long    stoll (std::string const& str, size_t * pinv, int base=10) {
    return detail_string::string_to_integral<signed long long>(str,pinv,base);
//    return strtoll (str.c_str(), pinv, base);
}

/**
 * @}






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







 







|







 







>



>

>
>

>
>
>
>
>
>



|



|







 







|





>





>





>







1
2
3
4
5
6














7
8
9
10
11
12
13
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
...
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
...
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
#ifndef CXXOMFORT_IMPL_STRING_HPP
#define CXXOMFORT_IMPL_STRING_HPP
/**
 * @file
 * @brief Implements the "to_string" functionality.
 *














 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/util/type_traits.hpp> // is_arithmetic w/o C++11 dependency
#include <string>
#include <cstdio>
#include <cstdlib>
................................................................................
        //char *e= b + vstr.size();
        ret = _pfn( b, &eipos, _b);
        int err= errno;
        const std::string throwmsg= std::string("string2integral: conversion of string \"") + _s + "\" to integral";
        if (err==ERANGE) throw out_of_range( throwmsg );
        else if (err==EINVAL || eipos==b) throw invalid_argument( "string2integral: invalid argument in call to");
        //std::cerr<< "[err="<< err<< "]"<< std::endl;
        if (_p) *_p = static_cast<size_t>(eipos - b);
        return ret;
    }

    private:
    std::string const& _s;
    string_to_integral& operator= (string_to_integral const&);

................................................................................
    const int _b;
    convertfn _pfn;
};


} //cxxomfort::cxxostd::detail_string

#if (defined(DOXYGEN_DOC))

/**
 * @brief Returns a @c string expression of an integral.
 * @param u A value of one of C++'s native integer types.
 * @ingroup cxx11-backports
 * @xrefitem std0string "" ""
 * @ref cxxomfort::library::string:to_string()
 */
template <typename NativeScalar>
static inline std::string to_string (NativeScalar u) {};

#endif


static inline std::string to_string (unsigned short u) {
    return detail_string::stringexpr(u);
}
//! @overload to_string(unsigned short)
static inline std::string to_string (long long i) {
    return detail_string::stringexpr(i);
}
//! @overload to_string(unsigned short)
static inline std::string to_string (unsigned long long u) {
    return detail_string::stringexpr(u);
}
//! @overload to_string
static inline std::string to_string (long double i) {
    return detail_string::stringexpr(i);
}
................................................................................

std::wstring to_wstring (int i) {
    return detail::stringexpr(i);
}
*/


//! Converts a string expression to <code>unsigned long</code>.
static inline unsigned long       stoul (std::string const& str, size_t* pinv, int base=10) {
    return detail_string::string_to_integral<unsigned long>(str,pinv,base);
//    return strtoul (str.c_str(), pinv, base);
}

//! Converts a string expression to <code>unsigned long long</code>.
static inline unsigned long long  stoull (std::string const& str, size_t* pinv, int base=10) {
    return detail_string::string_to_integral<unsigned long long>(str,pinv,base);
//    return strtoull (str.c_str(), pinv, base);
}

//! Converts a string expression to <code>signed long</code>.
static inline signed long         stol (std::string const& str, size_t * pinv, int base=10) {
    return detail_string::string_to_integral<signed long>(str,pinv,base);
//    return strtol (str.c_str(), pinv, base);
}

//! Converts a string expression to <code>signed long long</code>.
static inline signed long long    stoll (std::string const& str, size_t * pinv, int base=10) {
    return detail_string::string_to_integral<signed long long>(str,pinv,base);
//    return strtoll (str.c_str(), pinv, base);
}

/**
 * @}

Added cxxomfort/cxxomfort/impl/11-underlying_type.hpp.

































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
#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/various.hpp> // integral_of_size
#include <cxxomfort/type_traits.hpp> // make_signed

#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_GCC)
    // Add underlying_type approximation for GCC < 4.7 in any mode
    // see http://stackoverflow.com/questions/9343329/how-to-know-underlying-type-of-class-enum/10956467#10956467
    #if (CXXOMFORT_COMPILER_VERSION < 407)
        #define CXXOMFORT_USING_underlying_type 1
    #elif (CXXOMFORT_COMPILER_VERSION >= 407 && CXXOMFORT_CXX_STD < 2011 )
        #define CXXOMFORT_USING_underlying_type 1
    #endif
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_CLANG)
    #if (CXXOMFORT_CXX_STD >= 2011)
    #else
        #define CXXOMFORT_USING_underlying_type 1
    #endif
#elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC && CXXOMFORT_CXX_STD<2011)
    #define CXXOMFORT_USING_underlying_type 1
#endif // support for underlying_type

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

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

#endif

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

    }

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


#endif

Changes to cxxomfort/cxxomfort/impl/14-algorithm-equal.hpp.

1
2
3




4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
33
34
35
36
37
38
39



40

41
42
43
44
45
46
47
..
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
#ifndef CXXOMFORT_IMPL_ALGORITHM_14EQUAL_HPP
#define CXXOMFORT_IMPL_ALGORITHM_14EQUAL_HPP





#include <cxxomfort/base.hpp>
#include <type_traits>
#include "../algorithm.hpp"
// <algorithm> should have been included already

namespace cxxomfort {
namespace algorithm {

//
// explicit sized ranges for equal, from C++14
//
namespace detail_algorithm {
template <typename T1, typename T2> struct heterogenous_equal_to {
    bool operator() (T1 const& t1, T2 const& t2) const { return t1 == t2; }
................................................................................
}


} //detail_algorithm

/**
 * @brief Compare two sequences [ini1,fin1) and [ini2,fin2) for equality given comparator @p eq . Four-iterators overload.



 * @ingroup cxx14-backports

 * @return a @c bool 
 */
template <typename RangeIt1, typename RangeIt2, typename Compare> inline 
bool 
equal (RangeIt1 ini1, RangeIt1 fin1, RangeIt2 ini2, RangeIt2 fin2, Compare eq) {
    typedef typename std::iterator_traits<RangeIt1>::iterator_category cat_1;
    typedef typename std::iterator_traits<RangeIt2>::iterator_category cat_2;
................................................................................
    return detail_algorithm::equal_impl(ini1,fin1,ini2,fin2,eq,dispatcher_t());
}

//! @overload equal(ini1,fin1,ini2,fin2,eq)
template <typename RangeIt1, typename RangeIt2> inline 
bool 
equal (RangeIt1 ini1, RangeIt1 fin1, RangeIt2 ini2, RangeIt2 fin2) {


    typedef typename std::iterator_traits<RangeIt1>::value_type T1;
    typedef typename std::iterator_traits<RangeIt2>::value_type T2;






    detail_algorithm::heterogenous_equal_to< T1, T2 > this_eq;
    return detail_algorithm::equal_impl(ini1, fin1, ini2, fin2, this_eq);
}

//
// explicit sized ranges for mismatch, from C++14
//

/**
 * @brief Finds the first difference (dif1,dif2) between two sequences [ini1,fin1) and [ini2,fin2), given comparator @p eq . Four-iterator overload.

 * @ingroup cxx14-backports

 */
template<class InputIt1, class InputIt2, class BinaryPredicate>
std::pair<InputIt1, InputIt2>
mismatch (InputIt1 ini1, InputIt1 fin1, InputIt2 ini2, InputIt2 fin2, BinaryPredicate p) {
    while (ini1 != fin1 && ini2 != fin2 && p(*ini1, *ini2)) {
        ++ini1, ++ini2;
    }


<
>
>
>
>






|







 







>
>
>

>







 







>
>


>
>
>
>
>
>

|








>

>







1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
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
#ifndef CXXOMFORT_IMPL_ALGORITHM_14EQUAL_HPP
#define CXXOMFORT_IMPL_ALGORITHM_14EQUAL_HPP

/**
 * @file
 * @brief Implementation of C++14's overloads for @c equal(), @c mismatch() .
 * */
#include <cxxomfort/base.hpp>
#include <type_traits>
#include "../algorithm.hpp"
// <algorithm> should have been included already

namespace cxxomfort {
namespace cxxostd {

//
// explicit sized ranges for equal, from C++14
//
namespace detail_algorithm {
template <typename T1, typename T2> struct heterogenous_equal_to {
    bool operator() (T1 const& t1, T2 const& t2) const { return t1 == t2; }
................................................................................
}


} //detail_algorithm

/**
 * @brief Compare two sequences [ini1,fin1) and [ini2,fin2) for equality given comparator @p eq . Four-iterators overload.
 * @param[in] ini1,fin1 Delimiters for the first sequence argument to compare.
 * @param[in] ini2,fin2 Delimiters for the second sequence argument to compare.
 * @param eq An @e equality compare object.
 * @ingroup cxx14-backports
 * @xrefitem std:algorithm "<algorithm>" ""
 * @return a @c bool 
 */
template <typename RangeIt1, typename RangeIt2, typename Compare> inline 
bool 
equal (RangeIt1 ini1, RangeIt1 fin1, RangeIt2 ini2, RangeIt2 fin2, Compare eq) {
    typedef typename std::iterator_traits<RangeIt1>::iterator_category cat_1;
    typedef typename std::iterator_traits<RangeIt2>::iterator_category cat_2;
................................................................................
    return detail_algorithm::equal_impl(ini1,fin1,ini2,fin2,eq,dispatcher_t());
}

//! @overload equal(ini1,fin1,ini2,fin2,eq)
template <typename RangeIt1, typename RangeIt2> inline 
bool 
equal (RangeIt1 ini1, RangeIt1 fin1, RangeIt2 ini2, RangeIt2 fin2) {
    typedef typename std::iterator_traits<RangeIt1>::iterator_category cat_1;
    typedef typename std::iterator_traits<RangeIt2>::iterator_category cat_2;
    typedef typename std::iterator_traits<RangeIt1>::value_type T1;
    typedef typename std::iterator_traits<RangeIt2>::value_type T2;
    typedef std::random_access_iterator_tag rtag;
    using traits::is_same;
    typedef typename std::conditional< 
        (is_same<cat_1,rtag>::value and is_same<cat_2,rtag>::value)
        , traits::true_type, traits::false_type
    >::type dispatcher_t;
    detail_algorithm::heterogenous_equal_to< T1, T2 > this_eq;
    return detail_algorithm::equal_impl(ini1, fin1, ini2, fin2, this_eq, dispatcher_t());
}

//
// explicit sized ranges for mismatch, from C++14
//

/**
 * @brief Finds the first difference (dif1,dif2) between two sequences [ini1,fin1) and [ini2,fin2), given comparator @p eq . Four-iterator overload.
 * @param p An @e equality compare object.
 * @ingroup cxx14-backports
 * @xrefitem std:algorithm "<algorithm>" ""
 */
template<class InputIt1, class InputIt2, class BinaryPredicate>
std::pair<InputIt1, InputIt2>
mismatch (InputIt1 ini1, InputIt1 fin1, InputIt2 ini2, InputIt2 fin2, BinaryPredicate p) {
    while (ini1 != fin1 && ini2 != fin2 && p(*ini1, *ini2)) {
        ++ini1, ++ini2;
    }

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
67
68
69
70
71
72
73


74
75
76
77
78
79
80
...
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
#ifndef CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
#define CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
/**
 * @file
 * @brief Partial implementation of N3421 "Easier <functional> syntax" aka: Transparent Functors
 * @ingroup cxx14-backports
 * 
 * @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm
 * @see http://stackoverflow.com/questions/17737132/transparent-operator-functors
 * 
 * This header should be included @b after <functional> has been included.
 * 
 * Interfaces exported in this header:
 * 
 * * @c std::less<void>
 * * @c std::greater<void>
................................................................................
 * @brief Transparent functor for '@c Op ', to be used as <code>Op<void></code>. \
 *  \
 * These operators permit transparent (not type-dependent) comparators \
 * to be used in the contexts where eg.: <code>std::less</code> is expected. \
 *  \
 * @ingroup cxx14-backports   \
 * @sa 3421 \


 */   \
template <> struct Op <void> :  \
std::Op <int> { \
    typedef bool result_type; \
    template <typename T, typename U> \
    inline bool operator() (T const& t, U const& u) const { return t Sym u; } \
}; \
................................................................................
 */

} //cxxomfort::cxxostd
} //cxxomfort

// for the facilities to function correctly they are rebuilt in 
// namespace std; but we give users the option not to.
#if (!defined(CXXOMFORT_NO_STD_USING))

/*
 * Transparent functors were established in C++14
 */
#if (CXXOMFORT_CXX_STD < 2014)
namespace std {

    //! Transparent @em equal_to functor.




<
<

<
<







 







>
>







 







|
>







1
2
3
4


5


6
7
8
9
10
11
12
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
#define CXXOMFORT_IMPL_FUNCTIONAL_14FUNCTORS_HPP
/**
 * @file


 * 


 * 
 * This header should be included @b after <functional> has been included.
 * 
 * Interfaces exported in this header:
 * 
 * * @c std::less<void>
 * * @c std::greater<void>
................................................................................
 * @brief Transparent functor for '@c Op ', to be used as <code>Op<void></code>. \
 *  \
 * These operators permit transparent (not type-dependent) comparators \
 * to be used in the contexts where eg.: <code>std::less</code> is expected. \
 *  \
 * @ingroup cxx14-backports   \
 * @sa 3421 \
 * @see @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm \
 * @see http://stackoverflow.com/questions/17737132/transparent-operator-functors \
 */   \
template <> struct Op <void> :  \
std::Op <int> { \
    typedef bool result_type; \
    template <typename T, typename U> \
    inline bool operator() (T const& t, U const& u) const { return t Sym u; } \
}; \
................................................................................
 */

} //cxxomfort::cxxostd
} //cxxomfort

// for the facilities to function correctly they are rebuilt in 
// namespace std; but we give users the option not to.
#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
/*
 * Transparent functors were established in C++14
 */
#if (CXXOMFORT_CXX_STD < 2014)
namespace std {

    //! Transparent @em equal_to functor.

Changes to cxxomfort/cxxomfort/impl/14-integer_sequence.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
..
89
90
91
92
93
94
95
96

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef CXXOMFORT_IMPL_14_INTEGER_SEQUENCE_HPP
#define CXXOMFORT_IMPL_14_INTEGER_SEQUENCE_HPP
#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n3658 CXXO_BACKPORT()



#if (CXXOMFORT_CXX_STD >= 2014)
    // nothing to do
#else
// room here for a possible c++03 implementation? I wish.
#if (CXXOMFORT_CXX_STD < 2011)


#elif (CXXOMFORT_CXX_STD == 2011 || (CXXOMFORT_CXX_EMULATION==2011 && CXXO_COMPILER_SUPPORT_variadic))

namespace cxxomfort {
namespace utility {

/**
 * @ingroup utility

 * @{
 */
template <typename T, T... Elems>
struct integer_sequence {
    typedef T type;
    static const size_t size= sizeof...(Elems);
}; 
................................................................................
/**
 * @}
 */

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

#if (!defined(CXXOMFORT_NO_STD_USING))

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

#endif // c++11

#endif // support
#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
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef CXXOMFORT_IMPL_14_INTEGER_SEQUENCE_HPP
#define CXXOMFORT_IMPL_14_INTEGER_SEQUENCE_HPP
#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n3658 CXXO_BACKPORT()
/**
 * @file
 */
#if (CXXOMFORT_CXX_STD >= 2014)
    // nothing to do
#else
// room here for a possible c++03 implementation? I wish.
#if (CXXOMFORT_CXX_STD < 2011)


#elif (CXXOMFORT_CXX_STD == 2011 || (CXXOMFORT_CXX_EMULATION==2011 && CXXO_COMPILER_SUPPORT_variadic))

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup cxx14-backports
 * @xrefitem std:utility "<utility>"
 * @{
 */
template <typename T, T... Elems>
struct integer_sequence {
    typedef T type;
    static const size_t size= sizeof...(Elems);
}; 
................................................................................
/**
 * @}
 */

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

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
namespace std {
    //! Brings @c integer_sequence to std.
    using cxxomfort::cxxostd::integer_sequence;
    using cxxomfort::cxxostd::index_sequence;
    using cxxomfort::cxxostd::make_integer_sequence;
    using cxxomfort::cxxostd::make_index_sequence;
} // namespace std
#endif // std using

#endif // c++11

#endif // support
#endif


cxxomfort/cxxomfort/impl/14-make_unique.hpp became a regular file.

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

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
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

#include <cxxomfort/base.hpp>
#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


namespace cxxomfort {
namespace tuple {
namespace detail {

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


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

// this makes recursion stop, as the "value" needed to keep computing is not found.
template <typename C, int N, typename Tuple>
struct tuple_element2index_helper<C,-1,N,Tuple> {
};

// this *also* makes recursion stop, as the "value" needed to keep computing is not found.
template <typename C, int N, typename Tuple>
struct tuple_element2index_helper<C,-2,N,Tuple> {
};

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, int N, int M, 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,M,Tuple>::value
    };
};

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

} // namespace detail

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

/*
 * Given a type C and tuple type Tuple
 * set ::value to the index of the type C in Tuple.
 * If C does not appear in Tuple or appears more than once, fail with compilation error.
 */
template <typename C, typename Tuple>
struct tuple_index {
    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.");
    enum { value = detail::tuple_element2index_helper<C,0,std::tuple_size<T>::value,T>::value };
};

} // namespace tuple
} // namespace cxxomfort




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

namespace std {
#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) )


// three overloads as per cppreference

/**
 * @brief Return a member of a tuple given its type as a template argument.
 * @ingroup cxx14-backports
 */
template <typename C, typename... Targs
/* , typename = std::enable_if< cxxomfort::tuple::tuple_index<C,std::tuple<Targs...> >::value != -1 */
> 
C&& get (std::tuple<Targs...>&& t) CXXO_NOEXCEPT {
    enum { N = cxxomfort::tuple::tuple_index<C, std::tuple<Targs...> >::value };
    return std::forward<C>(get<N>(t));
}

//! @overload get
template <typename C, typename... Targs
/* , typename = std::enable_if< cxxomfort::tuple::tuple_index<C,std::tuple<Targs...> >::value != -1  */
>
C const& get (std::tuple<Targs...> const& t) CXXO_NOEXCEPT {
    enum { N = cxxomfort::tuple::tuple_index<C, std::tuple<Targs...> >::value };
    return (get<N>(t));
}

//! @overload get
template <typename C, typename... Targs
, typename = std::enable_if< cxxomfort::tuple::tuple_index<C,std::tuple<Targs...> >::value != -1> 
>
C& get (std::tuple<Targs...> & t) CXXO_NOEXCEPT {
    enum { N = cxxomfort::tuple::tuple_index<C, std::tuple<Targs...> >::value };
    return (get<N>(t));
}

#else
// at this point, c++03
//! Return a member from a tuple given its type.
template <typename C, typename Tuple>
typename std::enable_if< cxxomfort::tuple::is_tuple<Tuple>::value ,
    typename std::tuple_element< cxxomfort::tuple::tuple_index<C,Tuple>::value, Tuple>::type
>::type
const& get (Tuple const& t) {
    enum { N = cxxomfort::tuple::tuple_index<C,Tuple>::value }; 
    return get<N>(t);
}

//! @overload get
template <typename C, typename Tuple>
typename std::enable_if< cxxomfort::tuple::is_tuple<Tuple>::value && (cxxomfort::tuple::tuple_index<C,Tuple>::value != -1), 
    typename std::tuple_element< cxxomfort::tuple::tuple_index<C,Tuple>::value, Tuple>::type&
>::type
get (Tuple& t) {
    enum { N = cxxomfort::tuple::tuple_index<C,Tuple>::value }; 
    return get<N>(t);
}

#endif
}


................................................................................
    enum { value= detail::tuple_element2index_helper_pair<T1,C>::value };
    return p.second;
}

}
*/

// bring the new names to namespace std
namespace std {
    //using ::cxxomfort::tuple::get;
    using ::cxxomfort::tuple::tuple_index;
}

#if defined(DOXYGEN_DOC)
namespace cxxomfort {
namespace tuple {

/**
 * @brief Return a member of a tuple given its type as a template argument.
 * @ingroup cxx14-backports
 * @tparam T a type, such that it exists in the type pack @c TupleArgs... .
 */
template <typename T, typename... TupleArgs>







>








<
|
|

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

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

<
<
<
<



>











|








|





|


|







|
|


|





|
|


|







 







<
<
<
<
<
<


|







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
...
130
131
132
133
134
135
136






137
138
139
140
141
142
143
144
145
146

#include <cxxomfort/base.hpp>
#define CXXOMFORT_IMPLEMENTS_n3584 CXXO_EMULATION()
#define CXXOMFORT_IMPLEMENTS_n3670 CXXO_EMULATION()

#include <type_traits>
#include <tuple>
#include <cxxomfort/library/tuplefn.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) )


// three overloads as per cppreference

/**
 * @brief Return a member of a tuple given its type as a template argument.
 * @ingroup cxx14-backports
 */
template <typename C, typename... Targs
/* , typename = std::enable_if< cxxomfort::tuple::tuple_index<C,std::tuple<Targs...> >::value != -1 */
> 
C&& get (std::tuple<Targs...>&& t) CXXO_NOEXCEPT {
    enum { N = tuple_index<C, std::tuple<Targs...> >::value };
    return std::forward<C>(get<N>(t));
}

//! @overload get
template <typename C, typename... Targs
/* , typename = std::enable_if< cxxomfort::tuple::tuple_index<C,std::tuple<Targs...> >::value != -1  */
>
C const& get (std::tuple<Targs...> const& t) CXXO_NOEXCEPT {
    enum { N = tuple_index<C, std::tuple<Targs...> >::value };
    return (get<N>(t));
}

//! @overload get
template <typename C, typename... Targs
, typename = std::enable_if< tuple_index<C,std::tuple<Targs...> >::value != -1> 
>
C& get (std::tuple<Targs...> & t) CXXO_NOEXCEPT {
    enum { N = tuple_index<C, std::tuple<Targs...> >::value };
    return (get<N>(t));
}

#else
// at this point, c++03
//! Return a member from a tuple given its type.
template <typename C, typename Tuple>
typename std::enable_if< is_tuple<Tuple>::value ,
    typename std::tuple_element< tuple_index<C,Tuple>::value, Tuple>::type
>::type
const& get (Tuple const& t) {
    enum { N = tuple_index<C,Tuple>::value }; 
    return get<N>(t);
}

//! @overload get
template <typename C, typename Tuple>
typename std::enable_if< is_tuple<Tuple>::value && (tuple_index<C,Tuple>::value != -1), 
    typename std::tuple_element< tuple_index<C,Tuple>::value, Tuple>::type&
>::type
get (Tuple& t) {
    enum { N = tuple_index<C,Tuple>::value }; 
    return get<N>(t);
}

#endif
}


................................................................................
    enum { value= detail::tuple_element2index_helper_pair<T1,C>::value };
    return p.second;
}

}
*/







#if defined(DOXYGEN_DOC)
namespace cxxomfort {
namespace cxxostd {

/**
 * @brief Return a member of a tuple given its type as a template argument.
 * @ingroup cxx14-backports
 * @tparam T a type, such that it exists in the type pack @c TupleArgs... .
 */
template <typename T, typename... TupleArgs>

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

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
#include "../config.hpp"
#include "../type_traits.hpp"
#include "../using.hpp"
#include <utility>
#include <type_traits>

namespace cxxomfort {
namespace utility {

/**
 * @brief returns a @c const  view of object @p t . A @ref cxx17-backports .
 * @ingroup utility
 * @return A reference to its argument with @c const added.
 * @sa cxx17-backports
 */
template< typename T >
inline CXXO_CONSTEXPR typename std::add_const< T >::type & 
as_const( T &t ) CXXO_NOEXCEPT {
    return t;
}

} // utility
} // cxxomfort


#if (!defined(CXXOMFORT_NO_STD_USING))

namespace std {
    using cxxomfort::utility::as_const;
}
#endif

#if defined (DOXYGEN_DOC)
namespace cxxomfort {
    //! @brief Const view
    template <typename T> T const& as_const (T&) {}
}

#endif

#endif // file







|



|
|
|



|







|
>

|












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
#include "../config.hpp"
#include "../type_traits.hpp"
#include "../using.hpp"
#include <utility>
#include <type_traits>

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief returns a @c const  view of object @p t . A @ref cxx17-backports .
 * @return A reference to its argument with @c const qualifier added.
 * @ingroup cxx17-backports
 * @xrefitem std:utility "<utility>" ""
 */
template< typename T >
inline CXXO_CONSTEXPR typename std::add_const< T >::type & 
as_const( T& t ) CXXO_NOEXCEPT {
    return t;
}

} // utility
} // cxxomfort


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
namespace std {
    using cxxomfort::cxxostd::as_const;
}
#endif

#if defined (DOXYGEN_DOC)
namespace cxxomfort {
    //! @brief Const view
    template <typename T> T const& as_const (T&) {}
}

#endif

#endif // file

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

/*
 * 
 * * std::boolean_constant
 * 
 */

#include <cxxomfort/base.hpp>

#include <type_traits>
#include <tuple>

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 2)
    #pragma message CXXO_NOTICE("enabled boolean_constant implementation")
    #endif
#endif


namespace cxxomfort {
namespace type_traits {












#if (CXXOMFORT_CXX_STD<2014)
template <bool B>
struct bool_constant 
: std::integral_constant<bool,B> {};

#else
template <bool B>
using bool_constant = std::integral_constant<bool,B>;

#endif

}
}




#if (CXXOMFORT_CXX_STD < 2017)
namespace std {
    using ::cxxomfort::type_traits::bool_constant;
}
#endif


#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
#ifndef CXXOMFORT_IMPL_17_BOOLEANCONSTANT_HPP
#define CXXOMFORT_IMPL_17_BOOLEANCONSTANT_HPP
/**
 * @file
 * @brief Implementation of C++17's "bool_constant".


 */




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

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 2)
    #pragma message CXXO_NOTICE("enabled boolean_constant implementation")
    #endif
#endif


namespace cxxomfort {
namespace cxxostd {

/**
 * @class bool_constant 
 * @brief A <code>bool</code> compile time equivalent of @c integral_constant , as per C++17.
 * @ingroup cxx17-backports
 * @xrefitem std:type_traits "<type_traits>" ""
 * @xrefitem integral_constant "" ""
 * 
 * <code>bool_constant<false></code> is semantically equialent to <code>false_type</code> and 
 * <code>bool_constant<true></code> is semantically equialent to <code>true_type</code>.
 * 
 * */
#if (CXXOMFORT_CXX_STD<2014)
template <bool B>
struct bool_constant 
: ::std::integral_constant<bool,B> {};

#else
template <bool B>
using bool_constant = ::std::integral_constant<bool,B>;

#endif

}
}

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

#if (CXXOMFORT_CXX_STD < 2017)
namespace std {
    using ::cxxomfort::cxxostd::bool_constant;
}
#endif // cxx_std
#endif // using std

#endif



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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
42
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57
58
59
60
..
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
...
155
156
157
158
159
160
161




162
163
164
165
166
167
168
...
173
174
175
176
177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
#ifndef CXXOMFORT_IMPL_CSTDDEF_BYTE_HPP
#define CXXOMFORT_IMPL_CSTDDEF_BYTE_HPP
/**
 * @file 17-byte.hpp
 * @brief Header file for implementation of std::byte backport.
 */

/**
 * 
 * 
 * byte accepts the follosing operations:
 * 
 * * to_byte (Integral) -> byte
 * * to_integral<Integral>(byte) -> Integral
 * byte == byte and all other comparisons
................................................................................
// quick and easy encapsulation

}

/**
 * @brief "byte" type for C++17.
 * @ingroup cxx17-backports
 * @ref cstddef

 * 
 * A '<code>byte</code>' is much like an <code>unsigned char</code>, 
 * except that it is not an integral type but a compound-like 
 * type of its own. 
 * 
 * Only bit operations (via bitmask operators) and explicit integral 
 * transformations are defined for it.
 * 
 * The following basic operations are allowed:
 * 
 * @code
................................................................................
 * b >>= 2;
 * c <<= 3;
 * c= ~b;
 * int cint = to_integer<int>(c);
 * @endcode
 *
 */

struct byte: protected detail::byteimpl  {
    private:
    typedef detail::byteimpl underlying_t;
    public:
    
    byte (byte const& b) : detail::byteimpl((detail::byteimpl const&)b) {}
    explicit byte (unsigned char c) : detail::byteimpl( library::from_underlying<detail::byteimpl>(c) ) {}

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

template <typename TI >
TI to_integer (byte b) CXXO_NOEXCEPT {
    static_assert (std::is_integral<TI>::value, "is_integral");
    return static_cast<TI>(b.underlying());
}





template <typename TI> 
byte to_byte (TI i) {
    static_assert (sizeof(byte)==sizeof(char), "byte does not seem to be a char");
    static_assert (std::is_integral<TI>::value, "is_integral");
    return byte( static_cast<unsigned char>(i) );
}

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

/**
 * @}
 */


// cstddef
}
// cxxomfort
}

#if (!defined(CXXOMFORT_NO_STD_USING))

namespace std {
    //! @ref cxx17-backports
    using cxxomfort::cxxostd::byte;
    using cxxomfort::cxxostd::to_byte;
    using cxxomfort::cxxostd::to_integer;
}
#endif







|







 







|
>



|







 







>
|







 







>
>
>
>







 







|




|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#ifndef CXXOMFORT_IMPL_CSTDDEF_BYTE_HPP
#define CXXOMFORT_IMPL_CSTDDEF_BYTE_HPP
/**
 * @file 17-byte.hpp
 * @brief Header file for implementation of std::byte backport.
 */

/*
 * 
 * 
 * byte accepts the follosing operations:
 * 
 * * to_byte (Integral) -> byte
 * * to_integral<Integral>(byte) -> Integral
 * byte == byte and all other comparisons
................................................................................
// quick and easy encapsulation

}

/**
 * @brief "byte" type for C++17.
 * @ingroup cxx17-backports
 * @xrefitem std0cstddef "<cstddef>" "std::byte"
 * @see https://en.cppreference.com/w/cpp/types/byte
 * 
 * A '<code>byte</code>' is much like an <code>unsigned char</code>, 
 * except that it is not an integral type but a compound-like 
 * type of its own. It represents one @e character in memory.
 * 
 * Only bit operations (via bitmask operators) and explicit integral 
 * transformations are defined for it.
 * 
 * The following basic operations are allowed:
 * 
 * @code
................................................................................
 * b >>= 2;
 * c <<= 3;
 * c= ~b;
 * int cint = to_integer<int>(c);
 * @endcode
 *
 */
struct byte
: protected detail::byteimpl  {
    private:
    typedef detail::byteimpl underlying_t;
    public:
    
    byte (byte const& b) : detail::byteimpl((detail::byteimpl const&)b) {}
    explicit byte (unsigned char c) : detail::byteimpl( library::from_underlying<detail::byteimpl>(c) ) {}

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

template <typename TI >
TI to_integer (byte b) CXXO_NOEXCEPT {
    static_assert (std::is_integral<TI>::value, "is_integral");
    return static_cast<TI>(b.underlying());
}

/**
 * @brief Construct a 'byte' value from an integer.
 * @ingroup cxx17-backports
 */
template <typename TI> 
byte to_byte (TI i) {
    static_assert (sizeof(byte)==sizeof(char), "byte does not seem to be a char");
    static_assert (std::is_integral<TI>::value, "is_integral");
    return byte( static_cast<unsigned char>(i) );
}

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

/**
 * @}
 */


// cxxostd
}
// cxxomfort
}

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
namespace std {
    //! @ref cxx17-backports
    using cxxomfort::cxxostd::byte;
    using cxxomfort::cxxostd::to_byte;
    using cxxomfort::cxxostd::to_integer;
}
#endif

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

6
7
8
9
10
11
12
13
14
15
16

17
18

19
20
21
22
23
24
25
..
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
 * @sa http://en.cppreference.com/w/cpp/algorithm/clamp
 * 
 */

#if (CXXOMFORT_CXX_STD < 2017)

namespace cxxomfort {
namespace algorithm {

/**
 * @brief Clamps a value.

 * @ingroup cxx17-backports
 * @ref algorithm

 */
template<class T, class Compare>
CXXO_CONSTEXPR
T const& clamp ( T const& val, T const& lo, T const& hi, Compare comp) {
    return assert( !comp(hi, lo) ),
        comp(val, lo) ? lo : comp(hi, val) ? hi : val;
}
................................................................................
T const& clamp ( T const& val, T const& lo, T const& hi) {
    return clamp (val, lo, hi, std::less<T>() );
}

} // algorithm
} // cxxomfort

#if (!defined(CXXOMFORT_NO_STD_USING))

namespace std {
    using cxxomfort::algorithm::clamp;
}
#endif

#endif // c++17

#endif







|



>

<
>







 







|
>

|






6
7
8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
26
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 * @sa http://en.cppreference.com/w/cpp/algorithm/clamp
 * 
 */

#if (CXXOMFORT_CXX_STD < 2017)

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief Clamps a value.
 * @return An altered value from @a val to fit into the open interval (@a lo , @a hi ).
 * @ingroup cxx17-backports

 * @xrefitem std:algorithm "<algorithm>" ""
 */
template<class T, class Compare>
CXXO_CONSTEXPR
T const& clamp ( T const& val, T const& lo, T const& hi, Compare comp) {
    return assert( !comp(hi, lo) ),
        comp(val, lo) ? lo : comp(hi, val) ? hi : val;
}
................................................................................
T const& clamp ( T const& val, T const& lo, T const& hi) {
    return clamp (val, lo, hi, std::less<T>() );
}

} // algorithm
} // cxxomfort

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
namespace std {
    using cxxomfort::cxxostd::clamp;
}
#endif

#endif // c++17

#endif

Added cxxomfort/cxxomfort/impl/17-iterator_access.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
#ifndef CXXOMFORT_IMPL_17_SIZE_HPP
#define CXXOMFORT_IMPL_17_SIZE_HPP
/**
 * @file
 */
#include <cxxomfort/config.hpp>

// TODO fix "size" for compatibility with C++17's name
//
// From proposal N4017
//
// This implements a nonmember size() that calls member .size().
// For containers that somehow don't have size() (looking at you forward_list >_>)
// let's do distance(.begin(),.end())

namespace cxxomfort {
namespace cxxostd {
namespace iterator {

namespace detail_size {
template <typename C, bool F=false> struct call_size_has {
    typename C::difference_type operator() (C const& c) const { 
        return std::distance(c.begin() , c.end());
    }
}; // call_size_has

template <typename C> struct call_size_has<C,true> {
    typename C::difference_type operator() (C const& c) const { 
        return c.size();
    }
}; // call_size_has

} // detail_size

/**
 * @brief Returns the size (number of elements) of a sequence / container expression.
 * @ingroup cxx17-backports 
 * @xrefitem std0iterator "" ""
 */
template <typename C> inline
typename C::size_type
size (C & c) {
    typedef typename C::iterator iterator;
    (void)iterator();
    typedef typename C::difference_type difference_type;
    (void)difference_type();
    typedef typename C::value_type value_type;
    (void)value_type();
    const detail_size::call_size_has< C, ::cxxomfort::iterator::iterator_accessors_helper<C>::has_size > s={};
    return s(c);
}

// overload for native arrays
template <typename T, size_t N> inline
size_t size (T(&arr)[N]) {
    (void)arr;
    return N;
}

/*
 * data, from c++17
 */

template <typename C>
#if (CXXOMFORT_CXX_STD < 2011)
typename C::const_pointer 
#else
decltype(std::declval<C const>().data())
#endif
data (C const& c) {
    return c.data();
}

template <typename C>
#if (CXXOMFORT_CXX_STD < 2011)
typename C::pointer
#else
decltype(std::declval<C>().data())
#endif
data (C& c) {
    return c.data();
}

template <typename T, size_t N>
CXXO_CONSTEXPR T* data (T (&a)[N]) CXXO_NOEXCEPT {
    return a;
}

#if (CXXOMFORT_CXX_STD>=2011 && CXXOMFORT_CXX_STD<2017)
template <typename T>
constexpr const T* data (std::initializer_list<T> const& i) noexcept {
    return i.begin();
}
#endif


/*
 * empty, from c++17
 */

template <typename C>
bool empty (C const& c) {
    return c.empty();
}

template <typename T, size_t N>
CXXO_CONSTEXPR bool empty (T const (&a)[N]) CXXO_NOEXCEPT {
    return false;
}

#if (CXXOMFORT_CXX_STD>=2011 && CXXOMFORT_CXX_STD<2017)
template <typename T>
constexpr bool empty (std::initializer_list<T> const& i) noexcept {
    return i.size()==0;
}
#endif


}}}

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

    #if (CXXOMFORT_CXX_STD < 2017)
    namespace std {
        using ::cxxomfort::cxxostd::iterator::size;
    }
    #endif

#endif // no std using

#endif

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
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
#ifndef CXXOMFORT_IMPL_MAKE_FROM_TUPLE_HPP
#define CXXOMFORT_IMPL_MAKE_FROM_TUPLE_HPP
/**
 * @file
 * @brief Implementation header for C++17's make_from_tuple
 */

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

namespace cxxomfort {
namespace tuple {

// 
// make_from_tuple
//
#if (CXXOMFORT_CXX_STD >= 2014)
namespace detail {
template <class T, class Tuple, std::size_t... I>
................................................................................
        using std::get;
        return R( get<0>(tt), get<1>(tt), get<2>(tt), get<3>(tt), get<4>(tt) );
    }
    
};
    

}

template <typename T, typename Tuple>
T make_from_tuple (Tuple const& t) {
    detail::maker_from_tuple_t<T> M;
    return M(t);
}

#endif

} // tuple
} // cxxomfort




#if (CXXOMFORT_CXX_STD < 2017)
#if (!defined(CXXOMFORT_NO_STD_USING))
namespace std {
    using cxxomfort::tuple::make_from_tuple;
}
#endif
#endif


#if defined(DOXYGN_DOC)
namespace cxxomfort {
namespace tuple {
    /**
     * @brief Create an object from a tuple expression
     * @ingroup cxx17-backports
     * @return An object, constructed via a constructor call using a tuple as arguments.



     */
    template <typename T, typename... TupleArgs>
    T make_from_tuple (std::tuple<TupleArgs...> const& Tuple) {}
    
}
}

#endif

#endif




<







|







 







|












>
>
>
|
<
|
|
|
|
|




|



|
>
>
>










1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
#ifndef CXXOMFORT_IMPL_MAKE_FROM_TUPLE_HPP
#define CXXOMFORT_IMPL_MAKE_FROM_TUPLE_HPP
/**
 * @file

 */

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

namespace cxxomfort {
namespace cxxostd {

// 
// make_from_tuple
//
#if (CXXOMFORT_CXX_STD >= 2014)
namespace detail {
template <class T, class Tuple, std::size_t... I>
................................................................................
        using std::get;
        return R( get<0>(tt), get<1>(tt), get<2>(tt), get<3>(tt), get<4>(tt) );
    }
    
};
    

} // detail

template <typename T, typename Tuple>
T make_from_tuple (Tuple const& t) {
    detail::maker_from_tuple_t<T> M;
    return M(t);
}

#endif

} // tuple
} // cxxomfort

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

    #if (CXXOMFORT_CXX_STD < 2017)

    namespace std {
        using cxxomfort::cxxostd::make_from_tuple;
    }
    #endif
#endif // using std


#if defined(DOXYGN_DOC)
namespace cxxomfort {
namespace cxxostd {
    /**
     * @brief Create an object from a tuple expression
     * @ingroup cxx17-backports
     * @return An object of type @a T , constructed via a constructor call using a tuple as arguments.
     * 
     * The call <code>make_from_tuple<T>( footuple )</code> is 
     * equivalent to the call <code>T (get<0>(footuple), get<1>(footuple), get<2>(footuple), ...)</code>.
     */
    template <typename T, typename... TupleArgs>
    T make_from_tuple (std::tuple<TupleArgs...> const& Tuple) {}
    
}
}

#endif

#endif

Deleted cxxomfort/cxxomfort/impl/17-size.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
#ifndef CXXOMFORT_IMPL_17_SIZE_HPP
#define CXXOMFORT_IMPL_17_SIZE_HPP

#include <cxxomfort/config.hpp>

// TODO fix "size" for compatibility with C++17's name
//
// From proposal N4017
//
// This implements a nonmember size() that calls member .size().
// For containers that somehow don't have size() (looking at you forward_list >_>)
// let's do distance(.begin(),.end())

namespace cxxomfort {
namespace cxxostd {
namespace iterator {

namespace detail_size {
template <typename C, bool F=false> struct call_size_has {
    typename C::difference_type operator() (C const& c) const { 
        return std::distance(c.begin() , c.end());
    }
}; // call_size_has

template <typename C> struct call_size_has<C,true> {
    typename C::difference_type operator() (C const& c) const { 
        return c.size();
    }
}; // call_size_has

} // detail_size

template <typename C> inline
typename C::difference_type
size (C & c) {
    typedef typename C::iterator iterator;
    (void)iterator();
    typedef typename C::difference_type difference_type;
    (void)difference_type();
    typedef typename C::value_type value_type;
    (void)value_type();
    const detail_size::call_size_has< C, ::cxxomfort::iterator::iterator_accessors_helper<C>::has_size > s={};
    return s(c);
}

// overload for native arrays
template <typename T, size_t N> inline
size_t size (T(&arr)[N]) {
    (void)arr;
    return N;
}

}}}

#if (CXXOMFORT_CXX_STD < 2017)
namespace std {
	using ::cxxomfort::cxxostd::iterator::size;
}
#endif

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


























































































































cxxomfort/cxxomfort/impl/17-tuple_apply.hpp became a regular file.

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

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
#define CXXOMFORT_IMPLEMENTS_n3911 CXXO_BACKPORT()

#if (CXXOMFORT_CXX_STD < 2017)

// void_t and make_void for c++03, c++11, c++14

namespace cxxomfort {
namespace type_traits {
#if (CXXOMFORT_CXX_STD < 2011)
    template <typename T0=void, typename T1=void, typename T2=void, typename T3=void, typename T4=void, typename T5=void, typename T6=void, typename T7=void, typename T8=void, typename T9=void>
#else
    //! @internal
    template <typename... Types>
#endif
    
    struct make_void {
        typedef void type;
    };

/**
 * @struct make_void
 * @brief Metaprogramming helper that exposes @c void  as a type, for transformations.
 */
}
}

#if (!defined(CXXOMFORT_NO_STD_USING))

namespace std {
    using ::cxxomfort::type_traits::make_void;
}

// "void_t" is an alias, so it doesn't work in c++03
// Also it has to go in std:: because it is use in template arguments
#if (CXXOMFORT_CXX_STD >= 2011)
namespace std {
    template <typename... Ts> 
    using void_t = typename make_void<Ts...>::type;
}
#endif
























#endif // CXXOMFORT_NO_STD_USING


#endif // c++17

#if defined(DOXYGEN_DOC)
namespace std {
    //! @brief Metaprogramming tool that delivers @c void  as a type.
    //! @ingroup cxx17-backports
    template <typename...> struct make_void { typedef void type; };
    //! @ingroup cxx17-backports
    template <typename... Ts> using void_t = typename make_void<Ts...>::type;

}

#endif

#endif







|










<
<
<
<
<



|
>

|










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






<
<
<
<
<
<
<
<
<
<

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


#define CXXOMFORT_IMPLEMENTS_n3911 CXXO_BACKPORT()

#if (CXXOMFORT_CXX_STD < 2017)

// void_t and make_void for c++03, c++11, c++14

namespace cxxomfort {
namespace cxxostd {
#if (CXXOMFORT_CXX_STD < 2011)
    template <typename T0=void, typename T1=void, typename T2=void, typename T3=void, typename T4=void, typename T5=void, typename T6=void, typename T7=void, typename T8=void, typename T9=void>
#else
    //! @internal
    template <typename... Types>
#endif
    
    struct make_void {
        typedef void type;
    };





}
}

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
namespace std {
    using ::cxxomfort::cxxostd::make_void;
}

// "void_t" is an alias, so it doesn't work in c++03
// Also it has to go in std:: because it is use in template arguments
#if (CXXOMFORT_CXX_STD >= 2011)
namespace std {
    template <typename... Ts> 
    using void_t = typename make_void<Ts...>::type;
}
#endif

#if defined(DOXYGEN_DOC)
/**
 * @struct make_void
 * @brief Metaprogramming helper that exposes @c void  as a type, for transformations.
 * @ingroup cxx17-backports
 * @xrefitem std:type_traits "<type_traits>" ""
 */
template <typename... Arglist>
struct make_void { 
    typedef void type;  //< exports @c void as @a type .
};


/**
 * @struct void_t
 * @brief Generalized void type.
 * @ingroup cxx17-backports
 * @xrefitem std:type_traits "<type_traits>" ""
 * */


#endif

#endif // CXXOMFORT_NO_STD_USING


#endif // c++17











#endif


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

1
2
3




4
5
6
7
8
9
10
11
12
13
14
15
..
22
23
24
25
26
27
28













29
30
31
32



33
34
35
36
37
38

39
40
#ifndef CXXOMFORT_IMPL_20_ENDIAN_HPP
#define CXXOMFORT_IMPL_20_ENDIAN_HPP





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

namespace cxxomfort {
namespace std {

//struct myenum_def { enum type { member1, member2, member3 }; };
//typedef typesafe_enum<myenum_def> myenum;

namespace detail_endian {

struct e_ { enum type { 
................................................................................
    big    = __ORDER_BIG_ENDIAN__,
    native = __BYTE_ORDER__
#endif
}; // enum 
}; // struct
} // detail_endian














typedef cxxomfort::library::typesafe_enum<detail_endian::e_> endian;

}} // cxxomfort::std




#if (CXXO_COMPILER_SUPPORT_endian)
#else
namespace std { using cxxomfort::std::endian;
}

#endif


#endif


<
>
>
>
>




|







 







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




>
>
>
|
|
|
|
<
|
>


1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
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
#ifndef CXXOMFORT_IMPL_20_ENDIAN_HPP
#define CXXOMFORT_IMPL_20_ENDIAN_HPP

/**
 * @file 
 * @brief Implementation of std::endian
 * */
#include <cxxomfort/config.hpp>
#include <cxxomfort/library/typesafe_enum.hpp>

namespace cxxomfort {
namespace cxxostd {

//struct myenum_def { enum type { member1, member2, member3 }; };
//typedef typesafe_enum<myenum_def> myenum;

namespace detail_endian {

struct e_ { enum type { 
................................................................................
    big    = __ORDER_BIG_ENDIAN__,
    native = __BYTE_ORDER__
#endif
}; // enum 
}; // struct
} // detail_endian

/**
 * @brief Endianness enumeration for C++.
 * @ingroup std0type_traits
 * @xrefitem cxx20-backports "" ""
 * @see https://en.cppreference.com/w/cpp/types/endian
 * 
 * @c endian is a typed enumeration that describes the potential values 
 * for a system's endianness. The enumeration has three values: @c little , 
 * @c big and @c native . @c native will equal one of the other two 
 * when the system has that endianness, or will equal none of them 
 * in a system with a different (non-little, non-big) endianness.
 * 
 * */
typedef cxxomfort::library::typesafe_enum<detail_endian::e_> endian;

}} // cxxomfort::std

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

    #if (CXXO_COMPILER_SUPPORT_endian)
    #else
    namespace std { using cxxomfort::cxxostd::endian;
    }

    #endif
#endif // no std using

#endif

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

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

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

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

namespace cxxomfort {
namespace std {

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

}} // cxxomfort::std

#if (CXXOMFORT_CXX_STD<2020 && CXXOMFORT_CXX_EMULATION<2020)
namespace std { using cxxomfort::std::type_identity; }

#else

#endif

#endif







|






|






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

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

}} // cxxomfort::std

#if (CXXOMFORT_CXX_STD<2020 && CXXOMFORT_CXX_EMULATION<2020)
namespace std { using cxxomfort::cxxostd::type_identity; }

#else

#endif

#endif

Added cxxomfort/cxxomfort/impl/errc-posix.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
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/errc-win.hpp.

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

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
126
127
128
129
130
131
132

133
134
135
136
137
138
139
//
// Copyright 2004 Eric Niebler.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

//#include <functional>
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/meta.hpp>
#include <valarray>

namespace cxxomfort {
namespace library {
namespace detail {
................................................................................
    }
};

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


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

template <typename T>
struct type2iterator {
................................................................................
    typedef typename type2iterator<T>::iterator iter_type;
    //typedef typename T::const_iterator iter_type;
    return *auto_any_cast<iter_type>(cur);
}


} // detail::


///////////////////////////////////////////////////////////////////////////////
// FOREACH


#if defined(_MSC_VER)
// use a modified version with pragmas to suppress







|







 







|







 







>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//
// Copyright 2004 Eric Niebler.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

//#include <functional>
#include <cxxomfort/base.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/meta.hpp>
#include <valarray>

namespace cxxomfort {
namespace library {
namespace detail {
................................................................................
    }
};

// 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 {
................................................................................
    typedef typename type2iterator<T>::iterator iter_type;
    //typedef typename T::const_iterator iter_type;
    return *auto_any_cast<iter_type>(cur);
}


} // detail::
}}

///////////////////////////////////////////////////////////////////////////////
// FOREACH


#if defined(_MSC_VER)
// use a modified version with pragmas to suppress

cxxomfort/cxxomfort/impl/foreach_gcc.hpp became a regular file.

cxxomfort/cxxomfort/impl/forward_list-impl.hpp became a regular file.

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

1
2
3
4



5
6
7

8


9
10
























11
12




























13
#ifndef CXXOMFORT_IMPL_11METAPROGRAMMING_HPP
#define CXXOMFORT_IMPL_11METAPROGRAMMING_HPP

#include <cxxomfort/base.hpp>




#if (CXXOMFORT_CXX_STD < 2011)
namespace cxxomfort {





}
























#endif // c++03 mode





























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

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


namespace cxxomfort {
namespace traits {

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


template <typename T, template <class> class A1
    , template <class> class A2=keep
    , template <class> class A3=keep
    , template <class> class A4=keep
    , template <class> class A5=keep>
struct compose {
#if (0&& CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC)
    private:
    typedef typename A5<T>::type S4;
    typedef typename A4<S4>::type S3;
    typedef typename A3<S3>::type S2;
    typedef typename A2<S2>::type S1;
    public:
    typedef typename A1<S1>::type type;
#else
    typedef typename A1<
        typename A2<
            typename A3<
                typename A4<
                    typename A5<T>::type
                >::type
            >::type
        >::type 
    >::type type;
#endif

};


template 
    <typename T0, typename T1, typename T2=std::false_type, 
    typename T3=std::false_type, typename T4=std::false_type
> struct make_and 
: std::bool_constant 
<
    T0::value && T1::value && T2::value && T3::value && T4::value
>
{};

template 
    <typename T0, typename T1, typename T2=std::false_type, 
    typename T3=std::false_type, typename T4=std::false_type
> struct make_or 
: std::bool_constant 
<
    T0::value || T1::value || T2::value || T3::value || T4::value
>
{};



}}


#endif

Changes to cxxomfort/cxxomfort/impl/n3668_exchange.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
#ifndef CXXOMFORT_IMPL_n3668_HPP
#define CXXOMFORT_IMPL_n3668_HPP

#include "../config.hpp"
#include "../base.hpp" // move emulation
#include <utility>

/*

 * N3608, N3668: exchange
 * 
 * @brief assign new value and return old
 * @see N3608, N3668
 */


#if (CXXOMFORT_CXX_STD < 2014)
#define CXXOMFORT_IMPLEMENTS_n3668 1

namespace cxxomfort {
namespace utility {

/**
 * @brief Replaces a variable's value, returns the old value.
 * @sa N3668
 * @ingroup cxx14-backports
 * @ref utility
 */
template <typename T, typename U>
T exchange (T& obj, CXXO_RV_REF(U) nval) {
    T oval = std::move(obj);
    obj= std::forward<U>(nval);
    return oval;
}

/**
 * @brief Replaces a variable's value, returns the old value.
 * @sa N3668
 * @ingroup cxx14-backports
 * @ref utility
 */
template <typename T>
T exchange (T& obj, CXXO_RV_REF(T) nval) {
    T oval = std::move(obj);
    obj= std::forward<T>(nval);
    return oval;
}

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

#if (!defined(CXXOMFORT_NO_STD_USING))

namespace std {
    //! @ingroup cxx14-backports
    using ::cxxomfort::utility::exchange;
} // std::
#endif // std using

#endif


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

#include "../config.hpp"
#include "../base.hpp" // move emulation
#include <utility>

/**
 * @file 
 * N3608, N3668: exchange
 * 
 * @brief assign new value and return old
 * @see N3608, N3668
 */


#if (CXXOMFORT_CXX_STD < 2014)
#define CXXOMFORT_IMPLEMENTS_n3668 1

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief Replaces a variable's value, returns the old value.
 * @sa N3668
 * @ingroup cxx14-backports

 */
template <typename T, typename U>
T exchange (T& obj, CXXO_RV_REF(U) nval) {
    T oval = std::move(obj);
    obj= std::forward<U>(nval);
    return oval;
}

/**
 * @overload exchange



 */
template <typename T>
T exchange (T& obj, CXXO_RV_REF(T) nval) {
    T oval = std::move(obj);
    obj= std::forward<T>(nval);
    return oval;
}

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

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
namespace std {
    //! @ingroup cxx14-backports
    using ::cxxomfort::cxxostd::exchange;
} // std::
#endif // std using

#endif


#endif

cxxomfort/cxxomfort/impl/n3928_static_assert.hpp became a regular file.

Changes to cxxomfort/cxxomfort/impl/n4031_make_array.hpp.

2
3
4
5
6
7
8

9
10
11
12
13
14
15
#define CXXOMFORT_IMPL_n4031_HPP

#include "../config.hpp"
#include "../base.hpp" // move emulation
#include <utility>
#include <array>
#include <iostream>


//
// make_array
// contructs an object of std::array<T,N> type with automatically calculated N.
// See proposal:  http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4031.html
//
// http://stackoverflow.com/questions/6114067/how-to-emulate-c-array-initialization-int-arr-e1-e2-e3-behaviou







>







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

#include "../config.hpp"
#include "../base.hpp" // move emulation
#include <utility>
#include <array>
#include <iostream>
#include "../using.hpp"

//
// make_array
// contructs an object of std::array<T,N> type with automatically calculated N.
// See proposal:  http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4031.html
//
// http://stackoverflow.com/questions/6114067/how-to-emulate-c-array-initialization-int-arr-e1-e2-e3-behaviou

cxxomfort/cxxomfort/impl/pseudovariadic.hpp became a regular file.

cxxomfort/cxxomfort/impl/pstdint.h became a regular file.

cxxomfort/cxxomfort/impl/regex-esc.hpp became a regular file.

Changes to cxxomfort/cxxomfort/impl/seq_.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
#define CXXOMFORT_IMPL_SEQ_HPP
/**
 * @file
 */

// implementation of seq_<T>(), ...



#include <valarray>

namespace cxxomfort {


template <typename Ty>
struct generate_seq_t {
    private:
    struct p_notype;
    
    public:
    std::vector<Ty> elems;





    generate_seq_t () : elems() { }



















    generate_seq_t& operator, (Ty const& t) {
        elems.push_back(t);
        return *this;
    }
    
    template <typename Uy>
    generate_seq_t& operator, (Uy y) {
        elems.push_back(static_cast<Ty>(y));
        return *this;
    }

    template <typename Container>
    operator Container () const {
        return Container(std::begin(elems), std::end(elems));


    }
    
    operator std::valarray<Ty> () const {
        return std::valarray<Ty> (&elems[0], elems.size());
    }
    
};

/**
 * @brief Shorthand to generate a sequence of elements of a given type.
 * @ingroup independent-features
 * 
 * Example usage:
 * @code
vector<int> vec = seq_<int>(), 4, 5, 6, 7, 8, 9;


 * @endcode
 */
template <typename Ty>
generate_seq_t<Ty> seq_() {
    return generate_seq_t<Ty>();
}






} // cxxomfort

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

// 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:
    std::vector<Ty> elems;
    typedef Ty value_type;
    typedef typename std::vector<Ty>::difference_type difference_type;
    typedef typename std::vector<Ty>::const_iterator const_iterator;
    typedef typename std::vector<Ty>::const_iterator iterator;

    generate_seq_t () : elems() { }

    const_iterator begin () const CXXO_NOEXCEPT {
        return std::begin(elems);
    }
    const_iterator cbegin () const CXXO_NOEXCEPT {
        return std::begin(elems);
    }
    const_iterator end () const CXXO_NOEXCEPT {
        return std::end(elems);
    }
    const_iterator cend () const CXXO_NOEXCEPT {
        return std::end(elems);
    }

    generate_seq_t& operator& (Ty const& t) {
        elems.push_back(t);
        return *this;
    }

    generate_seq_t& operator, (Ty const& t) {
        elems.push_back(t);
        return *this;
    }
    
    template <typename Uy>
    generate_seq_t& operator, (Uy y) {
        elems.push_back(static_cast<Ty>(y));
        return *this;
    }

    template <typename Container>
    operator Container const () const {
        using std::begin;
        using std::end;
        return Container(begin(elems), end(elems));
    }
    
    operator std::valarray<Ty> const () const {
        return std::valarray<Ty> (&elems[0], elems.size());
    }
    
};

/**
 * @brief Shorthand to generate a sequence of elements of a given type.
 * @ingroup independent-features
 * 
 * Example usage:
 * @code
vector<int> vec = seq_<int>(), 4, 5, 6, 7, 8, 9;
list<int> lis = seq_<int>() & -4 & -5 & -6 & -7;

 * @endcode
 */
template <typename Ty>
generate_seq_t<Ty> seq_() {
    return generate_seq_t<Ty>();
}

}

//! @deprecated 
using library::seq_;

} // cxxomfort

#endif

cxxomfort/cxxomfort/impl/to_basic_string_cxx03.hpp became a regular file.

cxxomfort/cxxomfort/impl/to_basic_string_variadic.hpp became a regular file.

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

7
8
9
10
11
12
13

14
15
16
17
18
19
20
..
73
74
75
76
77
78
79

80
81
82
83
84
85
86

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

namespace cxxomfort {

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


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



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

1
2
3
4
5
6
7
8
9
10
11
...
283
284
285
286
287
288
289










290
291
292
293
294
295
296
...
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#ifndef CXXOMFORT_UNIQUE_PTR_HPP
#define CXXOMFORT_UNIQUE_PTR_HPP
/**
 * @file cxxomfort/unique_ptr.hpp
 * @brief Implements @c unique_ptr as a comfort utility for C++03.
 * @version 2012-04-04
 *
 * This file implements the @c unique_ptr smart pointer system
 * in a similar, but not fully equivalent manner,
 * to the @c unique_ptr feature of C++11,
 * thus reducing code rewrite when back/forthporting programs.
................................................................................

template <class T>
struct has_pointer_type {
    static const bool value = sizeof(pointer_type_imp::test<T>(0)) == 1;
};

namespace pointer_type_imp {











template <class T, class D, bool = has_pointer_type<D>::value>
struct pointer_type {
    typedef typename D::pointer type;
};

template <class T, class D>
................................................................................
};

}  //~namespace pointer_type_imp

template <class T, class D>
struct pointer_type {
    typedef typename pointer_type_imp::pointer_type<T,
    typename std::remove_reference<D>::type>::type type;
};

}  //~namespace detail_unique_ptr


//
// unique_ptr



|







 







>
>
>
>
>
>
>
>
>
>







 







|







1
2
3
4
5
6
7
8
9
10
11
...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
...
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#ifndef CXXOMFORT_UNIQUE_PTR_HPP
#define CXXOMFORT_UNIQUE_PTR_HPP
/**
 * @file 
 * @brief Implements @c unique_ptr as a comfort utility for C++03.
 * @version 2012-04-04
 *
 * This file implements the @c unique_ptr smart pointer system
 * in a similar, but not fully equivalent manner,
 * to the @c unique_ptr feature of C++11,
 * thus reducing code rewrite when back/forthporting programs.
................................................................................

template <class T>
struct has_pointer_type {
    static const bool value = sizeof(pointer_type_imp::test<T>(0)) == 1;
};

namespace pointer_type_imp {

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

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

template <class T, class D, bool = has_pointer_type<D>::value>
struct pointer_type {
    typedef typename D::pointer type;
};

template <class T, class D>
................................................................................
};

}  //~namespace pointer_type_imp

template <class T, class D>
struct pointer_type {
    typedef typename pointer_type_imp::pointer_type<T,
    typename pointer_type_imp::remove_reference<D>::type>::type type;
};

}  //~namespace detail_unique_ptr


//
// unique_ptr

Added cxxomfort/cxxomfort/iterator.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
#ifndef CXXOMFORT_ITERATOR_HPP
#define CXXOMFORT_ITERATOR_HPP
/**
 * @file algorithm.hpp
 */

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

// make_reverse_iterator
//#include 
// globals size, data, empty from C++17
#include "impl/17-iterator_access.hpp"


/**
 * @page std0iterator
 * 
 * Interfaces related to <code><iterator></code>.
 * 
 * * @c begin() , @c end() .
 * * @c cbegin() , @c cend() (C++14).
 * * @c size() (C++17)
 * 
 * 
 * @secreflist
 * Lista de contenidos.
 * @endsecreflist 
 * 
 *
 */

#endif

Changes to cxxomfort/cxxomfort/library.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
#ifndef CXXOMFORT_LIBRARY_HPP
#define CXXOMFORT_LIBRARY_HPP

#include <cxxomfort/utility.hpp>








// extra algorithm variants (find_last_if, count_while, etc)
#include "library/algorithmfn.hpp"
// for (x:range) emulation

#include "library/foreach.hpp"
// object-like primitive wrapper for fundamentals (int, long, etc)
// #include "library/fundamental.hpp"
// fixed_vector - the oft sought for vector without resize
#include "library/fixed_vector.hpp"
// initialization of containers and sequences
#include "library/i12n.hpp"
// extra iterator helpers (constant_iterator, etc)
#include "library/iteratorfn.hpp"
// local function emulation
#include "library/localfn.hpp"
// numeric-related stuff
#include "library/numericfn.hpp"
// functional plus<> like complements for +=, -=, ...
#include "library/operatorit.hpp"
// pair03 - movable pair type for C++03
#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"

namespace cxxomfort {
namespace library {
}
}

/**
 * @defgroup independent-features "Library Features"
 * @brief cxxomfort's own features and additions
 * 
 * The set of utilities and features specific to cxxomfort, themselves not 
 * part or backport of any Standard feature.
 * 
 */

/**
 * @page cxxo:sup Library Supplements
 * @brief Implementations and additions proper to the cxxomfort library.
 * @addtogroup independent-features
 * 
 * The @b cxxomfort library does not only implement backports to C++ features; it also brings its own set of features to supplement various functionality that, for example, can not be backported to previous version in a meaningful fashion. 
 * 
 * Including the <code><cxxomfort/library.hpp></code> header and invoking the <code>cxxomfort::</code> namespace makes these features available.
 * 
 * Implementations included from here:
 * 
 * * @subpage cxxo:sup:algorithm "Supplements for <algorithm>"
 * * @subpage cxxo:sup:functional "Supplements for <functional>"
 * * @subpage cxxo:sup:random "Supplements for <random>"
 * * @subpage cxxo:sup:string "Supplements for <string>"
 * * @subpage cxxo:sup:tuple "Supplements for <tuple>"
 * 
 * * @subpage cxxo:FOREACH "FOREACH (foreach loop)"
 * * @subpage cxxo:i12n "I12N (Container Initialization)"
 * * @subpage cxxo:fixed_vector "Fixed vector"
 * * @subpage cxxo:fundamental "Fundamental"
 * 
 * * @ref cxxo:pair03 "Pair"
 * * @ref cxxo:clstring "clString"
 * * @ref cxxo:type_name "type_name"
 * 
 */
#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
#ifndef CXXOMFORT_LIBRARY_HPP
#define CXXOMFORT_LIBRARY_HPP

namespace cxxomfort {
namespace library {
}
}

//
// extensions to cstd headers
//

// extra algorithm variants (find_last_if, count_while, etc)
#include "library/algorithmfn.hpp"

// extra binders and object wrappers
#include "library/functionalfn.hpp"






// extra iterator helpers (constant_iterator, etc)
#include "library/iteratorfn.hpp"


// numeric-related stuff
#include "library/numericfn.hpp"
// functional plus<> like complements for +=, -=, ...
#include "library/operatorit.hpp"


// extra string extensions (join, trim, etc)
#include "library/stringfn.hpp"
// extra tuple extensions (tuple_pop, etc)
#include "library/tuplefn.hpp"

// fixed_vector - the oft sought for vector without resize
//#include "library/fixed_vector.hpp"
// for (x:range) emulation
//#include "library/foreach.hpp"
// object-like primitive wrapper for fundamentals (int, long, etc)
// #include "library/fundamental.hpp"
// initialization of containers and sequences
#include "library/i12n.hpp"
// local function emulation
//#include "library/localfn.hpp"
// pair03 - movable pair type for C++03
//#include "library/pair03.hpp"
// typename to string helpers - typeid_demangle, type_name
#include "library/type_name.hpp"
// typesafe_enum
//#include "library/typesafe_enum.hpp"










































#endif

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
..
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
...
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
#ifndef CXXOMFORT_CXXO_ALGORITHMFN_HPP
#define CXXOMFORT_CXXO_ALGORITHMFN_HPP
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <algorithm>
#include <iterator>

/**
 * @file
 * @brief cxxomfort's algorithm-related functions
 */


namespace cxxomfort {
//! Namespace for the objects in @ref cxxo:sup:algorithm .
namespace algorithm {

namespace detail {

template<class It, class Pred>
It find_last_if (It ini, It fin, Pred f, std::forward_iterator_tag) {
    using namespace std;
................................................................................
    return ret;
}

} // .detail::

/**
 * @ingroup cxxo:sup:algorithm
 * @ref cxxo:sup:algorithm
 * @{
 */

/**
 * @brief Finds the latest item in a sequence that fulfills @c f .
 * @param ini,fin Delimiters to the sequence to be examined.

 * @return An iterator pointing to the latest item in <code>[ini,fin)</code> 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());
}
................................................................................
    return ret;
}



/**
 * @brief Transform elements in the range in-place via the transformation @a tf .
 * @param tf A transformation of the form <code>TF(*FIter) -> *FIter</code>.

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

/**
 * @brief Transform elements in the range conditionally.
 * @param tf A transformation of the form <code>TF(*FIter) -> *FIter</code>.
 * @param f a predicate to decide if the elements need transformation.

 */
template <typename FIter, typename TF, typename P>
FIter transform_inplace_if (FIter ini, FIter fin, TF tf, P p) {
    for (; ini != fin; ++ini) {
        if (p(*ini)) *ini= tf(*ini);
    }
    return ini;
................................................................................

/**
 * @}
 */

} // .algorithm::
}


/**
 * @page cxxo:sup:algorithm
 * 
 * This file provides supplementary features for the set of 
 * algorithms present in <code><algorithm></code> that are 
 * specific to cxxomfort, as well as functions that complete the 
 * family of <code>_n</code> functions such as <code>transform_n</code>.
 * 
 * Interfaces defined in this file:
 * 
 * * @ref count_while
 * * @ref find_inversion
 * * @ref find_last_if
 * * @ref transform_inplace
 * * @ref transform_inplace_if
 * * @ref transform_n
 * * @ref count_frequencies_map
 * * @ref count_frequencies
 * * @ref relative_search
 * 
 * 
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 * 
 */

#endif
|
|







<




|







 







|






>







 







|
>













>







 







>









|

|
|
|
<
|
|
|
<
|


|




1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20
21
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
..
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
...
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
#ifndef CXXOMFORT_CXXO_ALGORITHM_SUPP_HPP
#define CXXOMFORT_CXXO_ALGORITHM_SUPP_HPP
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <algorithm>
#include <iterator>

/**
 * @file

 */


namespace cxxomfort {
namespace library {
namespace algorithm {

namespace detail {

template<class It, class Pred>
It find_last_if (It ini, It fin, Pred f, std::forward_iterator_tag) {
    using namespace std;
................................................................................
    return ret;
}

} // .detail::

/**
 * @ingroup cxxo:sup:algorithm
 * @xrefitem cxxo:sup:algorithm "" ""
 * @{
 */

/**
 * @brief Finds the latest item in a sequence that fulfills @c f .
 * @param ini,fin Delimiters to the sequence to be examined.
 * @param f A predicate (a function from <var>ini...fin</var>'s alue type to @c bool ).
 * @return An iterator pointing to the latest item in <code>[ini,fin)</code> 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());
}
................................................................................
    return ret;
}



/**
 * @brief Transform elements in the range in-place via the transformation @a tf .
 * @param tf A transformation of the form <code>TF(value_type) → value_type</code>.
 * @return The @e end iterator of the sequence.
 */
template <typename FIter, typename TF>
FIter transform_inplace (FIter ini, FIter fin, TF tf) {
    for (; ini != fin; ++ini) {
        *ini= tf(*ini);
    }
    return ini;
}

/**
 * @brief Transform elements in the range conditionally.
 * @param tf A transformation of the form <code>TF(*FIter) -> *FIter</code>.
 * @param f a predicate to decide if the elements need transformation.
 * @return The @e end iterator of the sequence.
 */
template <typename FIter, typename TF, typename P>
FIter transform_inplace_if (FIter ini, FIter fin, TF tf, P p) {
    for (; ini != fin; ++ini) {
        if (p(*ini)) *ini= tf(*ini);
    }
    return ini;
................................................................................

/**
 * @}
 */

} // .algorithm::
}
}

/**
 * @page cxxo:sup:algorithm
 * 
 * This file provides supplementary features for the set of 
 * algorithms present in <code><algorithm></code> that are 
 * specific to cxxomfort, as well as functions that complete the 
 * family of <code>_n</code> functions such as <code>transform_n</code>.
 * 
 * Interfaces defined here:
 * 
 * * @c count_while()
 * * @c find_inversion()
 * * @c find_last_if()

 * * @c transform_inplace() , @c transform_inplace_if()
 * * @c transform_n()
 * * @c count_frequencies_map() , @c count_frequencies()

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

#endif

Added cxxomfort/cxxomfort/library/array_ref.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
#ifndef CXXOMFORT_LIBRARY_ARRAY_REF_HPP
#define CXXOMFORT_LIBRARY_ARRAY_REF_HPP
/**
 * @file 
 *  
**/

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

#define CXXOMFORT_IMPLEMENTS_n3334 CXXO_LIBRARY()

#if (defined(CXXOMFORT_NOTICES) && CXXOMFORT_NOTICES>1)
    #pragma message CXXO_NOTICE("enabled library: array_ref<T> implementation")
#endif


namespace cxxomfort {
namespace library {
namespace array_ref {

namespace ct = cxxomfort::traits;

/**
 * @brief Array view for sequences, from n3334
 * @ingroup cxxo:library
 * @anchor array_ref
 * @sa n3334
 * 
 * A @c array_ref is a non-owning view of a sequence of 
 * *contiguous* elements via a simple {pointer+length} package.
 * 
 * It provides some of the same operatios available for readable
 * sequences, in particular begin() and end().
 * 
 * This implementation is intended to be used for sequences of 
 * const elements (ie.: template argument is <code>T const</code>).
 * 
 * See also: <code>std::vector</code>, @c seq_ .
 * 
 * @c array_ref is based in the original publication by 
 * Jeffrey Yasskin at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html .
 * 
**/
template <typename T>
class array_ref {
    public:
    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
    
    CXXO_CONSTEXPR array_ref (T const* p, size_t l) CXXO_NOEXCEPTNOTHROW : ptr_(p), len_(l) {}
    
    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()) {}

/*    
    // view ref from vector; should be a std::array conversion operator but can't in C++03, C++11
    template <typename Alloc>
    array_ref (std::vector<T,Alloc> const& vec) 
    : ptr_(std::addressof(vec[0])), len_(vec.size()) {}
    
    // view ref from valarray; should be a std::array conversion operator but can't in C++03, C++11
    array_ref (std::valarray<T> const& va) 
    : ptr_(std::addressof(va[0])), len_(va.size()) {}

    // view ref from dynarray; should be a std::array conversion operator but can't in C++11
    array_ref (::cxxomfort::extras::dynarray::dynarray<T> const& da) CXXO_NOEXCEPT
    : ptr_(da.data()), len_(da.size()) {}

    // view_ref from fixed_vector; should be a fixed_vector conversion operator but that would include extras from library.
    array_ref (::cxxomfort::fixed_vector<T> const& r) CXXO_NOEXCEPT 
    : ptr_(r.data()), len_(r.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) { assert_range(i); return ptr_[i]; }
    const_reference at (size_t i) const { check_range(i); return ptr_[i]; }
    const_reference at (size_t i, std::error_code& ec) const { check_range(i,ec); return ptr_[i]; }
    //reference       operator[] (size_t len) CXXO_NOEXCEPT { return ptr_[len]; }
    const_reference operator[] (size_t len) const CXXO_NOEXCEPTNOTHROW { return ptr_[len]; }
    
    // 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_; }
    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   ptr_;
    size_t const    len_;

}; // array_ref

template <typename Ty, size_t N>
array_ref<Ty> make_array_ref(Ty(&arr)[N]) {
    return array_ref<Ty>(arr);
}

template <typename Ty, size_t N>
array_ref<Ty> make_array_ref(std::array<Ty,N> const& a) {
    return array_ref<Ty>(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 Ty>
array_ref<Ty> make_array_ref(::cxxomfort::extras::dynarray::dynarray<Ty> const& v) {
    return array_ref<Ty>(v);
}
*/

} // namespace array_ref
} // namespace extras
}

#endif

Changes to cxxomfort/cxxomfort/library/fixed_vector.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
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
129
130
131
132
133
134
135






136
137
138
139
140
141
142
...
329
330
331
332
333
334
335

336
337
338
 * @file
 * @brief Implementation of a fixed-size variant of vector<>.
 * @author Luis Machuca Bezzaza
 *
 */

#include <cxxomfort/base.hpp>



#include <cxxomfort/sequences.hpp> // is_iterator
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <memory>


namespace cxxomfort{


template <typename T, typename Alloc> class fixed_vector;


/**
 * @page library:fixed_vector
 * @brief Fixed vector (vector with size fixed at construction) container for C++.
 * @ingroup independent-features
 */

................................................................................
 * * emplace inserts.
 *
 */
template <typename T, typename Alloc=std::allocator<T> > class fixed_vector {
    typedef fixed_vector<T>  this_type;
    private:
    typedef Alloc        alloc_t;
    typedef std::allocator_traits<Alloc>     alloc_traits;
    typedef typename alloc_t::pointer        storage_pt;


    public:
    typedef T            value_type;         ///< type of contained value
    typedef size_t       size_type;
    typedef ptrdiff_t    difference_type;
................................................................................
        return m_p[idx];
    }
    //! @overload at
    reference at (size_t idx) {
        if (m_sz <= idx) throw std::out_of_range("fixed_vector at(size_t)");
        return m_p[idx];
    }







    //! direct access to elements
    const_reference operator[] (size_t idx) const CXXO_NOEXCEPT { // nothrow
        return m_p[idx];
    }
    //! @overload operator[]
    reference operator[] (size_t idx) CXXO_NOEXCEPT { // nothrow
................................................................................
}

template <typename T, typename Alloc>
inline bool operator!= (fixed_vector<T,Alloc> const& a, fixed_vector<T,Alloc> const& b) {
    return !(a==b);
}


}//~cxxomfort

#endif







>
>
>
|







>


>







 







|







 







>
>
>
>
>
>







 







>



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
...
340
341
342
343
344
345
346
347
348
349
350
 * @file
 * @brief Implementation of a fixed-size variant of vector<>.
 * @author Luis Machuca Bezzaza
 *
 */

#include <cxxomfort/base.hpp>
#include <cxxomfort/memory.hpp>
#include <cxxomfort/iterator.hpp>
#include <cxxomfort/system_error.hpp>
#include <cxxomfort/library/sequences.hpp> // is_iterator
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <memory>


namespace cxxomfort{
namespace library{

template <typename T, typename Alloc> class fixed_vector;


/**
 * @page library:fixed_vector
 * @brief Fixed vector (vector with size fixed at construction) container for C++.
 * @ingroup independent-features
 */

................................................................................
 * * emplace inserts.
 *
 */
template <typename T, typename Alloc=std::allocator<T> > class fixed_vector {
    typedef fixed_vector<T>  this_type;
    private:
    typedef Alloc        alloc_t;
    typedef ::std::allocator_traits<Alloc>     alloc_traits;
    typedef typename alloc_t::pointer        storage_pt;


    public:
    typedef T            value_type;         ///< type of contained value
    typedef size_t       size_type;
    typedef ptrdiff_t    difference_type;
................................................................................
        return m_p[idx];
    }
    //! @overload at
    reference at (size_t idx) {
        if (m_sz <= idx) throw std::out_of_range("fixed_vector at(size_t)");
        return m_p[idx];
    }
    //! checked access to elements
    const_reference at (size_t idx, std::error_code& ec) const {
        if (m_sz <= idx) ec.assign(EINVAL, std::generic_category());
        return m_p[idx];
    }
    

    //! direct access to elements
    const_reference operator[] (size_t idx) const CXXO_NOEXCEPT { // nothrow
        return m_p[idx];
    }
    //! @overload operator[]
    reference operator[] (size_t idx) CXXO_NOEXCEPT { // nothrow
................................................................................
}

template <typename T, typename Alloc>
inline bool operator!= (fixed_vector<T,Alloc> const& a, fixed_vector<T,Alloc> const& b) {
    return !(a==b);
}

}
}//~cxxomfort

#endif

Changes to cxxomfort/cxxomfort/library/foreach.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
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
#ifndef CXXOMFORT_FOREACH_HPP
#define CXXOMFORT_FOREACH_HPP

/**
 * @file
 * @brief Implements backwards-compatible range-for functionality
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces implemented in this file:
 *
 * * CXXO_FOREACH
 *
 * When in C++11 mode, the @c foreach just expands to the new
 * "range for" expression, acting natively.
 *
 * @see http://www.artima.com/cppsource/foreach.html
 */

#include <cxxomfort/config.hpp> // c++11

#if 0

// GNU C++ < 4.6 doesn't support new foreach even in C++0x mode
................................................................................
    // end c++11 / c++03
#endif

#if defined(DOXYGEN_DOC)
/**
 * @def CXXO_FOREACH(itemdecl,collection)
 * @brief Foreach loop construct that iterates over @p collection .
 * @ingroup independent-features



 *
 * A foreach macro declares iteration over @p collection , which can be
 * any STL-compatible sequence, using @p itemdecl as the iterating item.
 *
 * Usage is as follows:
 *
 * @code
 * list<int> L = {2, 3, 5, 7, 11};
 * CXXO_FOREACH (int x, L) {
 *   cout<< x<< ' ';
 * }

 * @endcode
 * 
 * * In C++11 mode, this expands to the native <code>for (itemdecl : collection)</code> 
 * range-for iteration, incurring in no cost.
 * * In C++03 mode, this expands to a type-erasure based solution similar to 
 * <code>for (unspecified_iterator b = begin(collection), e = end(collection) ; b != e ; ++b) if(itemdecl) ...</code>; 
 * this has cost of one @c virtual function call in compilers that do not offer "typeof" emulation, 





<


<
<
<
<
<
<
<
<







 







|
>
>
>







|
|
|
<
>







1
2
3
4
5

6
7








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

/**
 * @file

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *








 */

#include <cxxomfort/config.hpp> // c++11

#if 0

// GNU C++ < 4.6 doesn't support new foreach even in C++0x mode
................................................................................
    // end c++11 / c++03
#endif

#if defined(DOXYGEN_DOC)
/**
 * @def CXXO_FOREACH(itemdecl,collection)
 * @brief Foreach loop construct that iterates over @p collection .
 * @ingroup cxxo:sup
 * @see http://www.artima.com/cppsource/foreach.html
 * 
 * See also @link std0iterator "<iterator> support" @endlink .
 *
 * A foreach macro declares iteration over @p collection , which can be
 * any STL-compatible sequence, using @p itemdecl as the iterating item.
 *
 * Usage is as follows:
 *
 * @code
list<int> L = {2, 3, 5, 7, 11};
CXXO_FOREACH (int x, L) {
  cout<< x<< ' ';

}
 * @endcode
 * 
 * * In C++11 mode, this expands to the native <code>for (itemdecl : collection)</code> 
 * range-for iteration, incurring in no cost.
 * * In C++03 mode, this expands to a type-erasure based solution similar to 
 * <code>for (unspecified_iterator b = begin(collection), e = end(collection) ; b != e ; ++b) if(itemdecl) ...</code>; 
 * this has cost of one @c virtual function call in compilers that do not offer "typeof" emulation, 

Changes to cxxomfort/cxxomfort/library/functionalfn.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
#ifndef CXXOMFORT_CXXO_FUNCTIONALFN_HPP
#define CXXOMFORT_CXXO_FUNCTIONALFN_HPP
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <functional>
#include <iterator>



#include "operatorit.hpp" // supplement operator functors

namespace cxxomfort {
/**
 * @namespace 
 * @brief Supplements to functionality in <code><functional></code>.
 * @ingroup cxxo:sup:functional
 */
namespace functional {







} // .functional:
}


/**
 * @page cxxo:sup:functional "Supplements to <functional>"
 * @brief Offers cxxomfort-specific supplements to <code><functional></code> features.
 * 
 * This section offers a number of alternatives and supplements to features found in 
 * <code><functional></code> such as function objects to complete various tasks, 
 * a function-like reference wrapper, and 
 * function objects that complement the <code>plus</code> family.


















 * 
 */

#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
#ifndef CXXOMFORT_CXXO_FUNCTIONAL_SUPP_HPP
#define CXXOMFORT_CXXO_FUNCTIONAL_SUPP_HPP
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <functional>
#include <iterator>
/**
 * @file
 */
#include "operatorit.hpp" // supplement operator functors

namespace cxxomfort {
namespace library {
namespace functional {

template <typename Fn, typename Gn>
struct fncompose_t
: private std::function<Fn>, std::function<Gn> {
    public:
    typedef std::function<Fn> hf_t;
    typedef std::function<Gn> hg_t;
    
    private:
};

} // .functional:
}
}

/**
 * @page cxxo:sup:functional

 * 
 * This section offers a number of alternatives and supplements to features found in 
 * <code><functional></code> such as function objects to complete various tasks, 
 * a function-like reference wrapper, and 
 * function objects that complement the <code>plus</code> family.
 * 
 * * @c noop
 * * Supplements to named operators: 
 *   * <code>@ref preincrement</code> , @c predecrement .
 *   * Operator+assignment operators @c plus_it , @c minus_it , @c multiplies_it , @c divides_it , @c modulus_it .
 * 
 * 
 * Given a Standard C++ operator wrapper like <code>std::plus</code>, which wraps <code>operator+()</code>, 
 * cxxomfort also provides an analogue <code>@ref plus_it</code> which wraps <code>operator+=()</code>.
 * That is, they operate in the following way:
 * 
 * @code
plus<float> p;
plus_it<float,float> pa; // plus_assign
float r = p(3, M_PI); // same as r = 3 + M_PI;
pa(r, -4.12); // same as r+= -4.12;

 * @endcode
 * 
 */

#endif

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

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
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

}
} // library
} // cxxomfort


#define CXXO_I12N_BEG(Type,Name) typedef std::remove_cv<Type>::type Name##0ncv; static const Name##0ncv::value_type Name##0init []
#define CXXO_I12N_END(Type,Name) ; Type Name ((Name##0init), cxxomfort::i12n_detail::I12N_for< Name##0ncv >(Name##0init).ender)

// If compiler supports variadic macros, this can be used:
#if (CXXO_COMPILER_SUPPORT_va_args==1 )
#define CXXO_I12N_SEQ(Type,Name,...) CXXO_I12N_BEG(Type,Name) =  __VA_ARGS__ CXXO_I12N_END(Type,Name)
#endif

#else
................................................................................
// Variadic sequence initialization construct
    #define CXXO_I12N_SEQ(Type,Name,...)  Type Name ({__VA_ARGS__});

#endif // c++11

#ifdef DOXYGEN_DOC

/**
 * @addtogroup independent-features
 * @{
 */

/**
 * @def CXXO_I12N_BEG(SequenceT,Var) 
 * @brief Begins an initialization sequence.
 * @param SequenceT the type of the desired object.
 * @param Var the name of the desired object.
 * 
 * See usage case.
 * 
 */
#define CXXO_I12N_BEG(SequenceT, Var) implementation_defined

/**
 * @def CXXO_I12N_END(SequenceT,Var) 
 * @brief Finishes an initialization sequence.
 * @param SequenceT the type of the desired object.
 * @param Var the name of the desired object.
 * 
 * See usage case.
 * 
 */
#define CXXO_I12N_END(SequenceT, Var) implementation_defined


/**
 * @def CXXO_I12N_SEQ(SequenceT,Var,List...) 
 * @brief Constructs a sequence-like object.
 * @param Type the type of the desired object.
 * @param Var the name of the desired object.
 * @param List a brace-enclosed listing of elements for the object.
 * 
 * This macro wraps the usage of CXXO_I12_BEG and CXXO_I12N_END in a singular "oneliner" for compilers that have support for variadic macros.
 * 
 * 
 */
#define CXXO_I12N_SEQ(SequenceT, Var, {List...}) implementation_defined


/**
 * @}
 */

#endif // DOFS

#endif







|







 







<
<
<
<
<









|










|













|
<
<
<
<
<




83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
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

}
} // library
} // cxxomfort


#define CXXO_I12N_BEG(Type,Name) typedef std::remove_cv<Type>::type Name##0ncv; static const Name##0ncv::value_type Name##0init []
#define CXXO_I12N_END(Type,Name) ; Type Name ((Name##0init), cxxomfort::library::i12n_detail::I12N_for< Name##0ncv >(Name##0init).ender)

// If compiler supports variadic macros, this can be used:
#if (CXXO_COMPILER_SUPPORT_va_args==1 )
#define CXXO_I12N_SEQ(Type,Name,...) CXXO_I12N_BEG(Type,Name) =  __VA_ARGS__ CXXO_I12N_END(Type,Name)
#endif

#else
................................................................................
// Variadic sequence initialization construct
    #define CXXO_I12N_SEQ(Type,Name,...)  Type Name ({__VA_ARGS__});

#endif // c++11

#ifdef DOXYGEN_DOC






/**
 * @def CXXO_I12N_BEG(SequenceT,Var) 
 * @brief Begins an initialization sequence.
 * @param SequenceT the type of the desired object.
 * @param Var the name of the desired object.
 * 
 * See usage case.
 * 
 */
#define CXXO_I12N_BEG(SequenceT, Var) _implementation_defined_ SequenceT Var

/**
 * @def CXXO_I12N_END(SequenceT,Var) 
 * @brief Finishes an initialization sequence.
 * @param SequenceT the type of the desired object.
 * @param Var the name of the desired object.
 * 
 * See usage case.
 * 
 */
#define CXXO_I12N_END(SequenceT, Var) _implementation_defined_ ; (void)SequenceT 


/**
 * @def CXXO_I12N_SEQ(SequenceT,Var,List...) 
 * @brief Constructs a sequence-like object.
 * @param Type the type of the desired object.
 * @param Var the name of the desired object.
 * @param List a brace-enclosed listing of elements for the object.
 * 
 * This macro wraps the usage of CXXO_I12_BEG and CXXO_I12N_END in a singular "oneliner" for compilers that have support for variadic macros.
 * 
 * 
 */
#define CXXO_I12N_SEQ(SequenceT, Var, {List...}) _implementation_defined_ SequenceT Var = { List ... }






#endif // DOFS

#endif

cxxomfort/cxxomfort/library/iteratorfn.hpp became a regular file.

cxxomfort/cxxomfort/library/localfn.hpp became a regular file.

Changes to cxxomfort/cxxomfort/library/numericfn.hpp.

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










17
18
19
20
21
22
23
..
45
46
47
48
49
50
51












































































































52
53
54
55
56
57
58
..
62
63
64
65
66
67
68
69
70
























71
72






















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

/**
 * @file
 * @brief cxxomfort's numeric-related functions
 */


namespace cxxomfort {
//! Namespace for the objects in @ref cxxo:sup:algorithm .
namespace numeric {











template <typename It, typename T, typename F>
T accumulate_right (It ini, It fin, T v0, F f) {
    for (; ini != fin; ++ini) {
        v0 = f(*ini, v0);
    }    
    return v0;
................................................................................
/*
template <unsigned i1>
struct static_gcd_impl<i1,0U> {
    static const unsigned value= i1 ;
};
*/













































































































template <unsigned i1, unsigned i2>
struct static_gcd {
    //static const unsigned value= static_gcd_impl<i1,i2>::value;
    static const unsigned value= (i2==0U) ? i1 : static_gcd<i2, i1 % i2>::value ;
};

template <unsigned i1>
................................................................................
};

template <unsigned i1, unsigned i2>
struct static_lcm {
    static const unsigned value= i1 / static_gcd<i1,i2>::value * i2;
};

// return (b== 0) ? a : gcd(b, a % b);

























} // numeric::
}
























#endif







<


<

<

>
>
>
>
>
>
>
>
>
>







 







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







 







<

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


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



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
..
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
...
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
#include <cxxomfort/config.hpp>
#include <cxxomfort/base.hpp>
#include <numeric>
#include <iterator>

/**
 * @file

 */


namespace cxxomfort {

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;
    static const T value= v;
    operator T () const CXXO_NOEXCEPT { return v; }
};

template <typename It, typename T, typename F>
T accumulate_right (It ini, It fin, T v0, F f) {
    for (; ini != fin; ++ini) {
        v0 = f(*ini, v0);
    }    
    return v0;
................................................................................
/*
template <unsigned i1>
struct static_gcd_impl<i1,0U> {
    static const unsigned value= i1 ;
};
*/


// return (b== 0) ? a : gcd(b, a % b);

namespace detail {

template <typename T, typename T0, typename T1=void, typename T2=void, typename T3=void, typename T4=void>
struct minmax_impl_t {
    typedef minmax_impl_t<T,T0,T1,T2,T3> leftm;
    static const T min_value= leftm::min_value < T4::value ? leftm::min_value : T4::value;
    static const T max_value= leftm::max_value > T4::value ? leftm::max_value : T4::value;
};

template <typename T, typename T0, typename T1, typename T2, typename T3>
struct minmax_impl_t<T,T0,T1,T2,T3,void> {
    typedef minmax_impl_t<T,T0,T1,T2> leftm;
    static const T min_value= leftm::min_value < T3::value ? leftm::min_value : T3::value;
    static const T max_value= leftm::max_value > T3::value ? leftm::max_value : T3::value;
};

template <typename T, typename T0, typename T1, typename T2>
struct minmax_impl_t<T,T0,T1,T2,void,void> {
    typedef minmax_impl_t<T,T0,T1> leftm;
    static const T min_value= leftm::min_value < T2::value ? leftm::min_value : T2::value;
    static const T max_value= leftm::max_value > T2::value ? leftm::max_value : T2::value;
};

template <typename T, typename T0, typename T1>
struct minmax_impl_t<T,T0,T1,void,void,void> {
    static const T min_value = T0::value < T1::value ? T0::value : T1::value;
    static const T max_value = T0::value > T1::value ? T0::value : T1::value;
};

} // detail

template <typename T, T t0, T t1, T t2=t0, T t3=t0, T t4=t0>
struct static_min {
    public:
    static const T value = detail::minmax_impl_t<T, 
        T_constant<T,t0>, T_constant<T,t1>,
        T_constant<T,t2>, T_constant<T,t3>,
        T_constant<T,t4>
    >::min_value;
};

template <typename T, T t0, T t1, T t2=t0, T t3=t0, T t4=t0>
struct static_max {
    public:
    static const T value = detail::minmax_impl_t<T, 
        T_constant<T,t0>, T_constant<T,t1>,
        T_constant<T,t2>, T_constant<T,t3>,
        T_constant<T,t4>
    >::max_value;
};

template <typename T, T t0, T t1, T t2=t0, T t3=t0, T t4=t0>
struct static_minmax {
    public:
    typedef detail::minmax_impl_t<T, 
        T_constant<T,t0>, T_constant<T,t1>,
        T_constant<T,t2>, T_constant<T,t3>,
        T_constant<T,t4>
    > mm_test_t;
    static const T min_value = mm_test_t::min_value;
    static const T max_value = mm_test_t::max_value;
};


// compile-time math

namespace ctmath {

// abs

template <typename T, T u>
struct static_abs {
    static const T value = u < 0 ? -u : u;
};

// clamp

template <typename T, T t, T m, T M>
struct static_clamp {
    static const T value = 
    (t < m) ? m : (M < t ? M : t);
};

// ilog (positive)

// ipow (positive)

template <typename T, T x, unsigned y>
struct static_ipow {
    static const T t = static_ipow<T,x,y/2>::value;
    static const T value = (y%2u==0) ? t*t : x*t*t;
};

template <typename T, T x>
struct static_ipow<T,x,0u> {
    static const T value = 1;
};

template <typename T, T x>
struct static_ipow<T,x,1u> {
    static const T value = x;
};

// gcd, lcm

template <unsigned i1, unsigned i2>
struct static_gcd {
    //static const unsigned value= static_gcd_impl<i1,i2>::value;
    static const unsigned value= (i2==0U) ? i1 : static_gcd<i2, i1 % i2>::value ;
};

template <unsigned i1>
................................................................................
};

template <unsigned i1, unsigned i2>
struct static_lcm {
    static const unsigned value= i1 / static_gcd<i1,i2>::value * i2;
};



// sum

template <typename T, T t0, T t1, T t2=0, T t3=0, T t4=0, T t5=0, T t6=0, T t7=0, T t8=0, T t9=0>
struct static_sum {
    static const T value= t0+t1+t2+t3+t4+t5+t6+t7+t8+t9;
};

// left fold
/*
template <class F<typename>, typename T, T t0, T t1, T t2, T t3, T t4, T t5>
struct static_leftf {
    static const T value = F<T,t0, static_leftf<F,T,t1,t2,t3,t4>::value >::value;
};
*/

/*
template <typename F, typename T, T t0, T t1>
struct static_leftf <F,T,t0,t1> {
    static const T value = F<T, t0, t1>::value;
};
*/

} // ctmath

} // numeric::
}

/**
 * @page cxxo:sup:numeric
 * 
 * This file provides supplementary features for the set of 
 * algorithms present in <code><numeric></code> that are 
 * specific to cxxomfort, as well as functions that complete the 
 * family of <code>_n</code> functions such as <code>transform_n</code>.
 * 
 * Interfaces defined here:
 * 
 * * @c accumulate_left() , @c accumulate_right() , @c accumulate_associative()
 * * @c static_abs 
 * * @c static_min , @c static_max , @c static_minmax 
 * * @c static_gcd , @c static_lcm 
 * * @c static_sum 
 * 
 * 
 * All interfaces are defined in the namespace <code>cxxomfort::library::numeric::</code>.
 * 
 */



#endif

Changes to cxxomfort/cxxomfort/library/operatorit.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
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
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
...
108
109
110
111
112
113
114

115
116
117
118
#ifndef CXXOMFORT_CXXO_OPERATORIT_HPP
#define CXXOMFORT_CXXO_OPERATORIT_HPP

/**
 * @file 
 * @brief Implementations and additions of ${operator}_it functoids similar to <functional>.
 * 
 * Interfaces defined in this file:
 *
 * * preincrement, predecrement
 * * plus_it, minus_it, multiplies_it, divides_it, modulus_it.
 * * leftshift_it, rightshift_it.
 * * comma_it.
 * * 
 *
 */

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

namespace cxxomfort {

namespace functional {

/**
 * @ingroup cxxo:sup:functional 
 * @{
 */

//struct noop_t {
//    void operator() (...) const CXXO_NOEXCEPT {}
//};

/**
 * @brief Functoid that wraps <code>++t</code> for a given @a T .
 */
template <typename T>
struct preincrement
:std::unary_function< T&,T> {
    typedef T argument_type;
................................................................................
struct predecrement
:std::unary_function< T&,T> {
    typedef T argument_type;
    typedef T result_type;
    T& operator() (T& t) const { return --t; }
};

//! Heterogeneous (deduced) wrapper version of predecrement.
template<> struct predecrement<void> {
    template <typename T>
    T& operator() (T& t) { return --t; }

};


................................................................................
template <typename It, typename Ot=It> \
struct CXXOMFORT_JOIN(Name,_it) : std::binary_function< It& ,Ot const&,It&> {   \
    inline It& operator() (It& l, Ot const& r) const {   \
        return l Sym r;       \
    }                         \
};                            \



//! plus_it: Named functor that wraps operator+= for types <A,B>.

CXXO_DEF_OPERATORIT(plus,+=);
//! minus_it: Named functor that wraps operator-= for types <A,B>.
CXXO_DEF_OPERATORIT(minus,-=);
//! multiplies_it: Named functor that wraps operator*= for types <A,B>.
CXXO_DEF_OPERATORIT(multiplies,*=);
//! divides_it: Named functor that wraps operator/= for types <A,B>.
CXXO_DEF_OPERATORIT(divides,/=);
//! modulus_it: Named functor that wraps operator%= for types <A,B>.
CXXO_DEF_OPERATORIT(modulus,%=);

#undef CXXO_DEF_OPERATORIT








// leftshift, rightshift are defined in terms of cxxomfort-operators
//CXXO_DEF_OPERATORIT(leftshift_it,<<=);
//CXXO_DEF_OPERATORIT(rightshift_it,>>=);

template <typename It, typename Ot=It> 
struct leftshift_it : ::std::binary_function<It&,Ot const&,It&> {   
................................................................................


/**
 * @}
 */

} // functional

} // 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
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
57
58
59
60
61
62
63
64
65
66
67
68

69

70

71

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef CXXOMFORT_CXXO_OPERATORIT_HPP
#define CXXOMFORT_CXXO_OPERATORIT_HPP

/**
 * @file 










 */

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

namespace cxxomfort {
namespace library {
namespace functional {

/**
 * @ingroup cxxo:sup:functional 
 * @{
 */





/**
 * @brief Functoid that wraps <code>++t</code> for a given @a T .
 */
template <typename T>
struct preincrement
:std::unary_function< T&,T> {
    typedef T argument_type;
................................................................................
struct predecrement
:std::unary_function< T&,T> {
    typedef T argument_type;
    typedef T result_type;
    T& operator() (T& t) const { return --t; }
};

//! Heterogeneous (deduced) wrapper version of @ref predecrement.
template<> struct predecrement<void> {
    template <typename T>
    T& operator() (T& t) { return --t; }

};


................................................................................
template <typename It, typename Ot=It> \
struct CXXOMFORT_JOIN(Name,_it) : std::binary_function< It& ,Ot const&,It&> {   \
    inline It& operator() (It& l, Ot const& r) const {   \
        return l Sym r;       \
    }                         \
};                            \

/** 
 * @struct plus_it
 * @brief Named functor that wraps <code>operator+=</code> for types <A,B>. 
 * */ 
CXXO_DEF_OPERATORIT(plus,+=);

CXXO_DEF_OPERATORIT(minus,-=);

CXXO_DEF_OPERATORIT(multiplies,*=);

CXXO_DEF_OPERATORIT(divides,/=);

CXXO_DEF_OPERATORIT(modulus,%=);

#undef CXXO_DEF_OPERATORIT


/** 
 * @struct minus_it
 * @brief Named functor that wraps <code>operator-=</code> for types <A,B>. 
 * */ 


// leftshift, rightshift are defined in terms of cxxomfort-operators
//CXXO_DEF_OPERATORIT(leftshift_it,<<=);
//CXXO_DEF_OPERATORIT(rightshift_it,>>=);

template <typename It, typename Ot=It> 
struct leftshift_it : ::std::binary_function<It&,Ot const&,It&> {   
................................................................................


/**
 * @}
 */

} // functional
} // library
} // cxxomfort

#endif

cxxomfort/cxxomfort/library/pair03.hpp became a regular file.

Added cxxomfort/cxxomfort/library/randomfn.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
#ifndef CXXOMFORT_CXXO_RANDOM_SUPP_HPP
#define CXXOMFORT_CXXO_RANDOM_SUPP_HPP
/**
 * @file
 */

#include <cxxomfort/random.hpp>
//#include CXXO_INCLUDE_SYS(random)

namespace cxxomfort { namespace library {

/*
 * Usage:
 * @code

 * @endcode
 * */
template <typename TD, typename TG>
struct random_wrapper {
    random_wrapper (TD& d, TG& g)
    : tg(g), td(d) {}

    typename TD::result_type operator() () {
        return td((TG&)tg);
    }

    std::reference_wrapper<TG> tg;
    TD td;
};

template <typename TD, typename TG>
random_wrapper<TD,TG> make_random_wrap (TD& d, TG& g) {
    return random_wrapper<TD,TG>(d,g);
}

//! PRNG acorde a xkcd #221 "Random Number"
typedef 
std::linear_congruential_engine<uint16_t, 0, 4, 0>
xkcd221_g;




}}

/**
 * @page cxxo:sup:random
 *
 * This file provides supplementary features to the ones
 * present in <code><random></code> that are
 * specific to cxxomfort.
 *
 * * @c xkcd221_g - xkcd's pseudorandom number generator.
 *
 *
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 * 
 * Also see @link std0random <random> @endlink .
 *
 */


#endif

Added cxxomfort/cxxomfort/library/sequences.hpp.



















































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#ifndef CXXOMFORT_LIBRARY_SEQUENCES_HPP
#define CXXOMFORT_LIBRARY_SEQUENCES_HPP

/**
 * @file
 * 
 */

#include "../config.hpp"
#include <array>
#include <vector>
#include <type_traits>
#include "../util/type_traits.hpp"
#include "../library/i12n.hpp"
#include "../impl/17-bool_constant.hpp"
#include "../using.hpp"

/**
 * @page Sequence Helpers
 * @ingroup independent-features
 * 
 * Interfaces defined in this file:
 * 
 * * @c is_std_array
 * * @c is_sequence_container
 * * @c is_indexable_like_array
 * * @c is_iterator
 * * @c make_array
 * * @c seq_ , @c generic_sequence_t
 * 
 * Pending:
 * 
 * * @c array<> in C++03 mode with NO_TR1 defined
 *

 */


//
// is_std_array
//

namespace cxxomfort {

/**
 * @brief Type identification trait for <code>std::array<...></code> types.
 */
template <typename T> struct is_std_array 
: std::false_type {};

template <typename T, size_t N> struct is_std_array< std::array<T,N> > 
: std::true_type {};

} // cxxomfort

//
// is_indexable_like_array operator
//
// A type is considered indexable like an array if it exposes a value_type 
// and a []-operator (returning value_type [const] &).
namespace cxxomfort {
namespace detail {

template <typename T> struct bracket_indexable_helper {

    typedef struct { int a; } yes;
    typedef char no;

    private:
    template <typename U, U> struct really_has;

    template <typename C> static yes& Test_op(really_has <typename C::value_type const& (C::*)() const,
                            &C::operator[] >*);

    template <typename> static no& Test_op(...);
    
    public:
    static const bool has_op    = (sizeof(Test_op<T>(0)) == sizeof(yes));

};


} // detail

/**
 * @brief Type identification trait for types that 
 * are indexable via an array-like <code>operator[]</code>.
 */
template <typename T> struct is_indexable_like_array 
: std::conditional< detail::bracket_indexable_helper<T>::has_op, std::true_type, std::false_type>::type
{};

template <typename T, size_t N> struct is_indexable_like_array< T[N] >
: std::true_type 
{};


} //cxxomfort::

// sequence_t and seq_ generator
#include "../impl/seq_.hpp"

//
// is_sequence -- for specializations based on ability to provide 
// access to a sequence of objects
//
#include <iterator>
#include <type_traits>

namespace cxxomfort {

//
// is_iterator
//

namespace detail {

// detect iterator_category member
template <typename T> struct has_member_iterator_category {
private:
    typedef char                      yes;
    typedef yes no[2];

    template <typename C> static yes& test_ic(typename C::iterator_category*);
    template <typename C> static no&  test_ic(...);

    public:
    // iterator_category
    static const bool value = sizeof(test_ic<T>(0)) == sizeof(yes);
};

} // detail::

// Given a type @p T , inherit from @c true_type  if @p T  is a type 
// considered an iterator by iterator_traits.
/*
template<typename T, typename = void>
 struct is_iterator : std::false_type {};

template<typename T>
struct is_iterator<
    T, typename std::enable_if<
        detail::has_member_iterator_category< std::iterator_traits<T> >::value 
        and !std::is_same<typename std::iterator_traits<T>::value_type, void>::value 
    >::type> : std::true_type {};
*/


/**
 * @struct is_iterator
 * @brief Type identification trait for iterator types as defined by the <code><iterator></code> interface.
 */
template<class T>
struct is_iterator {   
    static T makeT();
    typedef void * twoptrs[2];  // sizeof(twoptrs) > sizeof(void *)
    static twoptrs & test(...); // Common case
    template<class R> static typename R::iterator_category * test(R); // Iterator
    template<class R> static void * test(R *); // Pointer

    static const bool value = sizeof(test(makeT())) == sizeof(void *); 
};



/* A type S is considered a sequence if:
 * * the calls std::begin(s) and std::end(s) make sense
 * * the return type of those calls is specialized by iterator_traits
 * * alternatively, S is a native C array
 */

namespace detail {

    template <typename T> struct has_sequence_members {
    private:
        typedef char                      yes;
        typedef yes no[2];

        template <typename C> static yes& test_ci(typename C::const_iterator*);
        template <typename C> static no&  test_ci(...);
        template <typename C> static yes& test_vt(typename C::value_type*);
        template <typename C> static no&  test_vt(...);

        public:
        // const_iterator
        static const bool value_ci = sizeof(test_ci<T>(0)) == sizeof(yes);
        // value_type
        static const bool value_vt = sizeof(test_vt<T>(0)) == sizeof(yes);
        typedef T type;

        private:
        template <typename U, U> struct really_has;

        template <typename C> static yes& Test_begin(really_has <typename C::const_iterator (C::*)() const,
                                            &C::begin>*);
        template <typename C> static yes& Test_begin(really_has <typename C::iterator (C::*)() const,
                                            &C::begin>*);

        template <typename C> static yes& Test_end(really_has <typename C::const_iterator (C::*)() const,
                                            &C::end>*);
        template <typename C> static yes& Test_end(really_has <typename C::iterator (C::*)() const,
                                            &C::end>*);

        template <typename C> static yes& Test_data(really_has <typename C::const_pointer (C::*)() const,
                                            &C::data>*);

        template <typename> static no& Test_begin(...);
        template <typename> static no& Test_end(...);
        template <typename> static no& Test_data(...);
        
        public:
        static bool const value_begin_end = (
            sizeof(Test_begin<T>(0)) == sizeof(yes) )
            && ( sizeof(Test_end<T>(0)) == sizeof(yes)
            );

        static bool const has_data = (
            sizeof(Test_data<T>(0)) == sizeof(yes)
            );
    };

template <typename T, bool=false>
struct is_sequence_impl: traits::false_type {};

template <typename T> struct is_sequence_impl<T,true> 
: traits::integral_constant<bool, is_iterator<typename T::const_iterator>::value > {};

} // detail::

// at present, a type S is a sequence if:
// 1.- has a const_iterator and value_type member types
// 1b.- has begin, end member functions returning type iterator or const_iterator (other overloads are ignored)
// 2.- or is a C array.

/**
 * @brief Type identification trait for sequence-like types:
 * * have a @c const_iterator member type.
 * * have a @c begin  and @c end  member function.
 */
template <typename S> struct is_sequence 
: detail::is_sequence_impl<S, 
    detail::has_sequence_members<S>::value_ci 
    && detail::has_sequence_members<S>::value_vt
    && detail::has_sequence_members<S>::value_begin_end 
> {};

// arrays are sequences
template <typename T, size_t N>
struct is_sequence< T[N] > : traits::true_type {};

// starting C++11, valarrays are sequences

#if (CXXOMFORT_CXX_STD >= 2011)
template <typename T>
struct is_sequence< std::valarray<T> >: std::true_type {};
#endif


//
// maybe_contiguous
//


/*
 * criteria for a sequence type to maybe be contiguous:
 * 
 * 1.- is a sequence according to is_sequence
 * 2.- supports member operator[]
 * 3a.- iterator == add_pointer<value_type>
 * 3b.- iterator has random_access_iterator_tag AND sequence has a .data member that returns pointer
 * 4.- the type is registered with register_contiguous_sequence
 * 
 * */

namespace {

template <typename S, typename = void>
struct contiguous_helper {
    typedef typename S::iterator I;
    typedef typename S::value_type V;
    typedef typename std::add_pointer<V>::type P;
    enum { clause1 = is_sequence<S>::value };
    enum { clause2 = is_sequence<S>::value };
    enum { clause3a = std::is_same< I, P >::value };
    enum { clause3b = std::is_same< std::random_access_iterator_tag, typename std::iterator_traits<I>::iterator_category>::value 
        && detail::has_sequence_members<S>::has_data
        };
    
    enum { value = clause1 && clause2 && (clause3a || clause3b) };
};

template <typename T>
struct contiguous_helper<T, typename std::enable_if< std::is_fundamental<T>::value >::type > 
: std::false_type {};

template <typename T, size_t N>
struct contiguous_helper <T[N], typename std::enable_if<true> ::type > {
    enum { value = true };
};

template <typename T>
struct contiguous_helper <std::valarray<T> , typename std::enable_if<true>::type > {
    enum { value = true };
};

}

template <typename T>
struct registered_contiguous 
: std::bool_constant<contiguous_helper<T>::value> {
};


template <typename S>
struct is_maybe_contiguous_sequence
: public std::bool_constant<
 (false==std::is_fundamental<S>::value) && registered_contiguous<S>::value
> {
};

} // cxxomfort

// make_array
//#include "impl/n4031_make_array.hpp"



#endif

Changes to cxxomfort/cxxomfort/library/stringfn.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
..
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
...
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
...
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
...
214
215
216
217
218
219
220
221
222
223




















224
#ifndef CXXOMFORT_CXXO_STRINGFN_HPP
#define CXXOMFORT_CXXO_STRINGFN_HPP

/**
 * @file stringfn.hpp
 * @brief cxxomfort's string-related functions
 */

#include <cstring>
#include <string>
#include <sstream>
#include <cxxomfort/algorithm.hpp>

#include "../impl/to_basic_string_variadic.hpp"

/**
 * @page cxxo:sup:string
 * 
 * This file provides supplementary features to the ones
 * present in <code><string></code> that are 
 * specific to cxxomfort.
 * 
 * Interfaces defined in this file:
 * 
 * * @ref cxxomfrt::string::chr
 * * @ref cxxomfort::string::utf8chr
 * * @ref codepoint
 * * @ref join
 * * @ref split_to
 * * @ref split_to_n
 * * @ref explode
 * * @ref l_trim
 * * @ref r_trim
 * * @ref trim
 * 
 * 
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 * 
 */


namespace cxxomfort {

/**
 * @addtogroup cxxo:sup:string
 * @{
 */
namespace string {


/**
 * @brief Returns a string representation of an ASCII ordinal.


 * @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")
    );
................................................................................
}

static inline std::string utf8chr (uint32_t cp) {
	using namespace std;
	char chu[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
	if (false) {
	} else if (cp <= 0x7f) {
		chu[0] = cp;
	} else if (cp <= 0x07ff)  {
        chu[0]= (cp>>6)+192;
        chu[1]= (cp&63)+128;
        }
    else if (cp <= 0xffff) {
		chu[0]= (uint8_t)(cp>>12)+224;
		chu[1]= ((cp>>6)&63)+128;
		chu[2]= (cp&63)+128 ;
	}
	else if (cp <= 0x1fffff) {
		chu[0]= (cp>>18)+240;
		chu[1]= ((cp>>12)&63)+128;
		chu[2]= ((cp>>6)&63)+128;
		chu[3]= (cp&63)+128;
	}
	// if($num<=0x1FFFFF)   return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128).chr(($num&63)+128);
	//cerr<< hex<< cp<< " utf8chr -> { "<< chr[0]<< ' '<< chr[1]<< ' '<< chr[2]<< ' '<< chr[3]<< ' '<< chr[4]<< " }; "<< endl;
	return (chu);
................................................................................
        ret= ss.str();
    }
    return ret;
}

// is this one necessary?
//! @overload join
template <typename Iterator1, typename Iterator2> inline 
std::string join (std::string const& sep, Iterator1 ini, Iterator2 fin) {
    return join<std::string>(sep,ini,fin);
}

/**
 * @brief Splits a string into a list of strings according to a separator.
 * @param sep Separator string.
 * @param ini Writable iterator where to deposit elements.
 * @return The value of the writable iterator after splitting is done.
 * 
 */
template <typename String, typename Iterator1, typename Number>
Iterator1 split_to (String const& sep, String const& str, Iterator1 ini, Number lim=0) {
    lim= 0;
    (void)lim;
    using namespace std;
    //typedef std::vector<String> VT;
................................................................................
}


/**
 * @brief Trims a string removing a selected character class from the left.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 * 
 */
template <typename String, typename Pred>
void l_trim (String& s, Pred p) {
    using namespace std;
    // we find L = first position in s where p(L) is false
    // we use string's erase function (or just a copy constructor)
    typename String::iterator L = find_if_not(begin(s), end(s), p);
................................................................................
}


/**
 * @brief Trims a string removing a selected character class from the right.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 * 
 */
template <typename String, typename Pred>
void r_trim (String& s, Pred p) {
    using namespace std;
    // we find L = last position in s where p(L) is true
    // we use string's erase function (or just a copy constructor)
    typename String::reverse_iterator L = find_if_not(s.rbegin(), s.rend(), p);
................................................................................


} // string
/**
 * @}
 */

} // 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
..
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
..
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
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
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
#ifndef CXXOMFORT_CXXO_STRINGFN_HPP
#define CXXOMFORT_CXXO_STRINGFN_HPP

/**
 * @file stringfn.hpp

 */
#include <cxxomfort/base.hpp>
#include <cstring>
#include <string>
#include <sstream>
#include <cxxomfort/algorithm.hpp>

#include "../impl/to_basic_string_variadic.hpp"



























namespace cxxomfort { namespace library {

/**
 * @ingroup cxxo:sup:string
 * @{
 */
namespace string {


/**
 * @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")
    );
................................................................................
}

static inline std::string utf8chr (uint32_t cp) {
	using namespace std;
	char chu[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
	if (false) {
	} else if (cp <= 0x7f) {
		chu[0] = (char)cp;
	} else if (cp <= 0x07ff)  {
        chu[0]= (char)((cp>>6)+192);
        chu[1]= (char)((cp&63)+128);
        }
    else if (cp <= 0xffff) {
		chu[0]= (uint8_t)(cp>>12)+224;
		chu[1]= ((cp>>6)&63)+128;
		chu[2]= (cp&63)+128 ;
	}
	else if (cp <= 0x1fffff) {
		chu[0]= (uint8_t)(cp>>18)+240;
		chu[1]= ((cp>>12)&63)+128;
		chu[2]= ((cp>>6)&63)+128;
		chu[3]= (cp&63)+128;
	}
	// if($num<=0x1FFFFF)   return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128).chr(($num&63)+128);
	//cerr<< hex<< cp<< " utf8chr -> { "<< chr[0]<< ' '<< chr[1]<< ' '<< chr[2]<< ' '<< chr[3]<< ' '<< chr[4]<< " }; "<< endl;
	return (chu);
................................................................................
        ret= ss.str();
    }
    return ret;
}

// is this one necessary?
//! @overload join
template <typename Iterator1, typename Iterator2> inline
std::string join (std::string const& sep, Iterator1 ini, Iterator2 fin) {
    return join<std::string>(sep,ini,fin);
}

/**
 * @brief Splits a string into a list of strings according to a separator.
 * @param sep Separator string.
 * @param ini Writable iterator where to deposit elements.
 * @return The value of the writable iterator after splitting is done.
 *
 */
template <typename String, typename Iterator1, typename Number>
Iterator1 split_to (String const& sep, String const& str, Iterator1 ini, Number lim=0) {
    lim= 0;
    (void)lim;
    using namespace std;
    //typedef std::vector<String> VT;
................................................................................
}


/**
 * @brief Trims a string removing a selected character class from the left.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 *
 */
template <typename String, typename Pred>
void l_trim (String& s, Pred p) {
    using namespace std;
    // we find L = first position in s where p(L) is false
    // we use string's erase function (or just a copy constructor)
    typename String::iterator L = find_if_not(begin(s), end(s), p);
................................................................................
}


/**
 * @brief Trims a string removing a selected character class from the right.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 *
 */
template <typename String, typename Pred>
void r_trim (String& s, Pred p) {
    using namespace std;
    // we find L = last position in s where p(L) is true
    // we use string's erase function (or just a copy constructor)
    typename String::reverse_iterator L = find_if_not(s.rbegin(), s.rend(), p);
................................................................................


} // string
/**
 * @}
 */

}} // cxxomfort::library


/**
 * @page cxxo:sup:string
 *
 * This file provides supplementary features to the ones
 * present in <code><string></code> that are
 * specific to cxxomfort.
 *
 * * @c chr() , @c utf8chr()  - Conversion from integer/codepoint to character.
 * * @c codepoint() - Conversion from character to integer/codepoint.
 * * @c join() - Joins elements into a string.
 * * @c split_to() , @c split_to_n() - Split elements from a string.
 * * @c explode() - Splits elements from a string.
 * * @c l_trim() , @c r_trim() , @c trim()  - Removes elements from a string's ends.
 * * @c to_string() - Variadic for of to_string.
 *
 *
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 *
 */

#endif

Changes to cxxomfort/cxxomfort/library/tuplefn.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
..
94
95
96
97
98
99
100
101

102
103
104









































































































































































































105

106














































































107
108
109
110
111
112
113
...
166
167
168
169
170
171
172

173
174
175
176
177
178
179
180
181
182
183
184
185
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
...
310
311
312
313
314
315
316






317
318
319
320
321
322
323
...
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354






















355
#ifndef CXXOMFORT_CXXO_TUPLEFN_HPP
#define CXXOMFORT_CXXO_TUPLEFN_HPP
/**
 * @file library/tuplefn.hpp
 * @brief cxxomfort's tuple-related functions
 *
 * Interfaces defined:
 * 
 * * is_tuple
 * * tuple_pop
 * * tuple_shift
 * * tuple_foreach
 * * tuple_call
 */

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

namespace cxxomfort {
/**
 * @page cxxo:sup:tuple
 * 
 * This file provides supplementary features for the tuple-related 
 * utilities present in <code><tuple></code>.
 * 
 * Interfaces defined here
 * 
 * * @ref is_tuple
 * * @ref tuple_pop
 * * @ref tuple_shift
 * * @ref tuple2function_t
 * * @ref function2tuple_t
 * * @ref tuple_call
 * 
 * 
 * All interfaces are defined in the namespace <code>cxxomfort::algorithm::</code>.
 * 
 */

namespace tuple {
}
}


//
// is_tuple -- for specializations of calls based on tuples in C++03
namespace cxxomfort {
namespace tuple {
//

//! @addtogroup cxxo:sup:tuple
template <typename T> struct is_tuple: traits::false_type {};

#if (CXXOMFORT_CXX_STD >= 2011) || \
 (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_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...> >
................................................................................
        , 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

}

} // cxxomfort











































































































































































































namespace cxxomfort {

namespace tuple {















































































/*
 * @brief Convert from tuple type to function signature.
 * @ingroup cxxo:sup:tuple
 * 
 * Given a tuple of the form T<T1,T2,...>,
 * obtain a function signature R(T1,T2,...) 
................................................................................
    typename T5, typename T6, typename T7, typename T8, typename T9> 
struct tuple2function_t< R,std::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> > { 
    typedef R(type)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9); 
};

#endif


}
} // cxxomfort


namespace cxxomfort {
namespace tuple {

/**
 * @brief Convert from function signature type to tuple type.
 * @ingroup cxxo:sup:tuple
 * 
 * Given a function signature R(T1,T2,...), 
 * obtain a tuple of the form T<T1,T2,...>
................................................................................
        typename T5, typename T6, typename R>
    struct function2tuple_t<R(T0,T1,T2,T3,T4,T5,T6)> {
        typedef std::tuple<T0,T1,T2,T3,T4,T5,T6> type;
    };

#endif

}
} // cxxomfort


namespace cxxomfort {
namespace tuple {

#ifdef DOXYGEN_DOC
/**
 * @brief Removes the last type from a tuple
 * @ingroup cxxo:sup:tuple
 * 
 */
................................................................................
    return std::make_tuple( get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
}

// c++03 impl
#endif

}
} // cxxomfort

namespace cxxomfort {
namespace tuple {

/*
 * tuple_shift: removes the first type from a tuple
 */

#if (0 && CXXOMFORT_CXX_STD >= 2011)

................................................................................
template <typename A1, typename... Args, typename... Indices>
std::tuple<Args...> tuple_shift (std::tuple<A1,Args...> && _tuple) {
    using namespace std;
    return make_tuple( forward<Args...>(get<Indices...>(_tuple));
}
#else
// c++03 impl






template <typename A0, typename A1>
std::tuple<A1> tuple_shift (std::tuple<A0,A1> const& t) {
    using std::get;
    return std::make_tuple( get<1>(t) );
}
template <typename A0, typename A1, typename A2>
std::tuple<A1,A2> tuple_shift (std::tuple<A0,A1,A2> const& t) {
................................................................................
    using std::get;
    return std::make_tuple( get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
}

#endif

}
} // cxxomfort


//
// tuple_call (f, Tuple)
// calls f for each member of Tuple
//
#include "../impl/tuple_call.hpp"























#endif



|
<

<
|
<
<
<
<
<
<




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


|



<







 







|
>



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

>

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







 







>




|
<







 







|



|
<







 







|

|
<







 







>
>
>
>
>
>







 







|








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

1
2
3
4

5

6






7
8
9
10


























11
12
13
14
15
16

17
18
19
20
21
22
23
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
...
412
413
414
415
416
417
418
419
420
421
422
423
424

425
426
427
428
429
430
431
...
470
471
472
473
474
475
476
477
478
479
480
481

482
483
484
485
486
487
488
...
535
536
537
538
539
540
541
542
543
544

545
546
547
548
549
550
551
...
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#ifndef CXXOMFORT_CXXO_TUPLEFN_HPP
#define CXXOMFORT_CXXO_TUPLEFN_HPP
/**
 * @file 

 *

 */







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



























//
// is_tuple -- for specializations of calls based on tuples in C++03
namespace cxxomfort { namespace library {
namespace tuple {
//


template <typename T> struct is_tuple: traits::false_type {};

#if (CXXOMFORT_CXX_STD >= 2011) || \
 (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_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...> >
................................................................................
        , 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

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


//
// tuple2array
//

namespace cxxomfort { namespace library { namespace tuple {

template <typename Tuple>
struct _tuple2array_cnv_t {
    // Tuple is a tuple
    static_assert (is_tuple<Tuple>::value, "tuple_to_array: T must be a tuple");
    typedef /* typename std::decay<Tuple>::type */ Tuple InTuple;
    static const size_t _S = std::tuple_size<InTuple>::value;
    typedef typename std::tuple_element<0,Tuple>::type U;
    private:
    
    template <unsigned U>
    struct _notenabled;
    
    public:
    
    _tuple2array_cnv_t (Tuple const& t): _t(t) {}
    // conversion operator to an array of the same size as the tuple
#if (1 && ( CXXOMFORT_CXX_STD >= 2011 || (CXXOMFORT_CXX_EMULATION == 2011 && CXXO_EMULATION_variadic && CXXO_EMULATION_rvref)))
    template<size_t... I>
    std::array<U,_S> get_array (std::index_sequence<I...>) const {
        using std::get;
        using std::forward;
        return std::array<U,_S> { { get<I>((_t))... } };
    }


    template <typename Indices = std::make_index_sequence<std::tuple_size<InTuple>::value> >
    operator std::array<U,_S> () const {
        return get_array(Indices());
    }


#else
#define CXXO_m_cnv_array(n) operator typename std::conditional< _S==n, std::array<U,n> , _notenabled<n> >::type
    CXXO_m_cnv_array(1) () const {
        using namespace std;
        array<U,1> ret= { get<0>(_t) };
        return ret;
    }
    CXXO_m_cnv_array(2) () const {
        using namespace std;
        array<U,2> ret= { get<0>(_t), get<1>(_t) };
        return ret;
    }
    CXXO_m_cnv_array(3) () const {
        using namespace std;
        array<U,3> ret= { get<0>(_t), get<1>(_t), get<2>(_t) };
        return ret;
    }
    CXXO_m_cnv_array(4) () const {
        using namespace std;
        array<U,4> ret= { get<0>(_t), get<1>(_t), get<2>(_t), get<3>(_t) };
        return ret;
    }

    CXXO_m_cnv_array(5) () const {
        using namespace std;
        array<U,5> ret= { get<0>(_t), get<1>(_t), get<2>(_t), get<3>(_t), get<4>(_t) };
        return ret;
    }

#undef CXXO_m_cnv_array
#endif
    private:
    Tuple const& _t;
};

template <typename T>
_tuple2array_cnv_t<T> tuple2array (T const& t) {
    return _tuple2array_cnv_t<T>(t);
}

}}}

//
// tuple2array
//

namespace cxxomfort { namespace library { namespace tuple {

/*
 * array to tuple
 */

template <typename T> struct tuple_of_array_size;

template <typename T0> struct tuple_of_array_size< std::array<T0,1> > {
    typedef std::tuple<T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,2> > {
    typedef std::tuple<T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,3> > {
    typedef std::tuple<T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,4> > {
    typedef std::tuple<T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,5> > {
    typedef std::tuple<T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,6> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,7> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,8> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,9> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,10> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0,T0,T0,T0>  type;
};


template <typename T>
struct _array2tuple_cnv_t {};

template <typename T, size_t N>
struct _array2tuple_cnv_t< std::array<T,N> > {
    private:
    // Tuple is a tuple
    //static_assert (is_tuple<Tuple>::value, "tuple_to_array: T must be a tuple");
    private:
    std::array<T,N> const& _a;

    typedef /* typename std::decay<Tuple>::type */ std::array<T,N> InArray;
    typedef typename InArray::value_type U;
    template <unsigned U>
    struct _notenabled;
    public:


    _array2tuple_cnv_t (InArray const& a): _a(a) {}


#if (1 && ( CXXOMFORT_CXX_STD >= 2011 || (CXXOMFORT_CXX_EMULATION == 2011 && CXXO_EMULATION_variadic && CXXO_EMULATION_rvref)))
    template <size_t... I>
    typename tuple_of_array_size< InArray>::type get_tuple (std::index_sequence<I...>) const {
        return std::make_tuple(_a[I]...);
    }

    template <typename Indices = std::make_index_sequence<N> >
    operator typename tuple_of_array_size< InArray >::type () const {
        return std::move(get_tuple(Indices()));
    }

#else

#define CXXO_m_cnv_tuple(n) operator typename std::conditional< N==n \
    , typename tuple_of_array_size< std::array<T,n> >::type, _notenabled<n> > \
    ::type

    CXXO_m_cnv_tuple(1) () const { return std::make_tuple( _a[0] ); }
    CXXO_m_cnv_tuple(2) () const { return std::make_tuple( _a[0], _a[1] ); }
    CXXO_m_cnv_tuple(3) () const { return std::make_tuple( _a[0], _a[1], _a[2] ); }
    CXXO_m_cnv_tuple(4) () const { return std::make_tuple( _a[0], _a[1], _a[2], _a[3] ); }
    CXXO_m_cnv_tuple(5) () const { return std::make_tuple( 
        _a[0], _a[1], _a[2], _a[3], _a[4] 
    ); }
    CXXO_m_cnv_tuple(6) () const { return std::make_tuple( 
        _a[0], _a[1], _a[2], _a[3], _a[4], _a[5] 
    ); }
    CXXO_m_cnv_tuple(7) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6] 
    ); }
    CXXO_m_cnv_tuple(8) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6], _a[7] 
    ); }
    CXXO_m_cnv_tuple(9) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6], _a[7], _a[8] 
    ); }
    CXXO_m_cnv_tuple(10) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6], _a[7], _a[8], _a[9] 
    ); }
    
#undef CXXO_m_cnv_tuple

#endif

};

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 cxxomfort {
namespace library {
namespace tuple {


namespace detail {

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


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

// this makes recursion stop, as the "value" needed to keep computing is not found.
template <typename C, int N, typename Tuple>
struct tuple_element2index_helper<C,-1,N,Tuple> {
};

// this *also* makes recursion stop, as the "value" needed to keep computing is not found.
template <typename C, int N, typename Tuple>
struct tuple_element2index_helper<C,-2,N,Tuple> {
};

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, int N, int M, 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,M,Tuple>::value
    };
};

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

} // namespace detail

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

/*
 * Given a type C and tuple type Tuple
 * set ::value to the index of the type C in Tuple.
 * If C does not appear in Tuple or appears more than once, fail with compilation error.
 */
template <typename C, typename Tuple>
struct tuple_index {
    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.");
    enum { value = detail::tuple_element2index_helper<C,0,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,...>,
 * obtain a function signature R(T1,T2,...) 
................................................................................
    typename T5, typename T6, typename T7, typename T8, typename T9> 
struct tuple2function_t< R,std::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> > { 
    typedef R(type)(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9); 
};

#endif

}
}
} // cxxomfort


namespace cxxomfort { namespace library { namespace tuple {


/**
 * @brief Convert from function signature type to tuple type.
 * @ingroup cxxo:sup:tuple
 * 
 * Given a function signature R(T1,T2,...), 
 * obtain a tuple of the form T<T1,T2,...>
................................................................................
        typename T5, typename T6, typename R>
    struct function2tuple_t<R(T0,T1,T2,T3,T4,T5,T6)> {
        typedef std::tuple<T0,T1,T2,T3,T4,T5,T6> type;
    };

#endif

}}
} // cxxomfort


namespace cxxomfort { namespace library { namespace tuple {


#ifdef DOXYGEN_DOC
/**
 * @brief Removes the last type from a tuple
 * @ingroup cxxo:sup:tuple
 * 
 */
................................................................................
    return std::make_tuple( get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
}

// c++03 impl
#endif

}
}} // cxxomfort

namespace cxxomfort { namespace library { namespace tuple {


/*
 * tuple_shift: removes the first type from a tuple
 */

#if (0 && CXXOMFORT_CXX_STD >= 2011)

................................................................................
template <typename A1, typename... Args, typename... Indices>
std::tuple<Args...> tuple_shift (std::tuple<A1,Args...> && _tuple) {
    using namespace std;
    return make_tuple( forward<Args...>(get<Indices...>(_tuple));
}
#else
// c++03 impl

template <typename A0>
std::tuple<> tuple_shift (std::tuple<A0> const&) {
    using std::get;
    return std::make_tuple<>( );
}
template <typename A0, typename A1>
std::tuple<A1> tuple_shift (std::tuple<A0,A1> const& t) {
    using std::get;
    return std::make_tuple( get<1>(t) );
}
template <typename A0, typename A1, typename A2>
std::tuple<A1,A2> tuple_shift (std::tuple<A0,A1,A2> const& t) {
................................................................................
    using std::get;
    return std::make_tuple( get<1>(t), get<2>(t), get<3>(t), get<4>(t), get<5>(t) );
}

#endif

}
}} // cxxomfort


//
// tuple_call (f, Tuple)
// calls f for each member of Tuple
//
#include "../impl/tuple_call.hpp"

/**
 * @page cxxo:sup:tuple
 * 
 * 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>.
 * 
 */


#endif

Changes to cxxomfort/cxxomfort/library/type_name.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
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
#ifndef CXXOMFORT_TYPE_NAME_HPP
#define CXXOMFORT_TYPE_NAME_HPP
#include <cxxomfort/base.hpp>

/**
 * @file library/type_name.hpp
 * @brief Type naming and identification utilities in cxxomfort.
 * @ingroup independent-utilities
 * @anchor library:type_name
 */

#include <typeinfo>
#include <type_traits> // remove_reference, etc
#include "../util/type_traits.hpp"
#include "../type_traits.hpp"
#include "../using.hpp"
................................................................................
    return (name);
#endif
}


} //detail_demangle::


//! Demangle a @c typeid() expression if demangling is available
//! @ingroup independent-features


static inline std::string typeid_demangle (std::type_info const& ti) {
    return detail_demangle::job( ti.name() );
}

/**
 * @brief Demangle a typename, recovering information about const / volatile too.
 * @ingroup independent-features
 * @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 () {
    using namespace std;
    typedef typename remove_reference<T>::type TnR;
    std::string r( typeid_demangle(typeid(T)) );




    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+= "&&"; }



    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
..
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
#ifndef CXXOMFORT_TYPE_NAME_HPP
#define CXXOMFORT_TYPE_NAME_HPP
#include <cxxomfort/base.hpp>

/**
 * @file



 */

#include <typeinfo>
#include <type_traits> // remove_reference, etc
#include "../util/type_traits.hpp"
#include "../type_traits.hpp"
#include "../using.hpp"
................................................................................
    return (name);
#endif
}


} //detail_demangle::

/**
 * @brief Demangle a @c typeid() expression if demangling is available
 * @ingroup cxxo:sup
 * @return A demangled version of a <code>typeid(...)</code> return, if available.
 **/
static inline std::string typeid_demangle (std::type_info const& ti) {
    return detail_demangle::job( ti.name() );
}

/**
 * @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 () {
    using namespace std;
    typedef typename remove_reference<T>::type TnR;
    std::string r( typeid_demangle(typeid(T)) );
    // this code section can generate "conditional expression is constant" warnings in some compilers
#if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC)
    #pragma warning (disable:4127)
#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_VALUE_COMPILER_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/typesafe_enum.hpp.

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
...
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271

/*
}//~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; \
................................................................................
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








|
>



|

|




>


<







 







<







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
...
258
259
260
261
262
263
264

265
266
267
268
269
270
271

/*
}//~namespace 
*/

/* begin section: underlying type specialization */

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

namespace std {

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

} // std::



/* end section: underlying_type */


#ifndef CXXOMFORT_CXX11_MODE
#define CXXO_ENUM_BEGIN(Name,Storage) struct Name##0_def { \
    typedef Storage storage_type; \
................................................................................
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

Changes to cxxomfort/cxxomfort/limits.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CXXOMFORT_LIMITS_HPP
#define CXXOMFORT_LIMITS_HPP
/**
 * @file
 * @brief Compile-time expressions for integral @c <limits> values in C++
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * @ingroup independent-features
 *
 * Interfaces defined in this header:
 *
 * * cxxomfort::integral_limits
 *




<







1
2
3
4

5
6
7
8
9
10
11
#ifndef CXXOMFORT_LIMITS_HPP
#define CXXOMFORT_LIMITS_HPP
/**
 * @file

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * @ingroup independent-features
 *
 * Interfaces defined in this header:
 *
 * * cxxomfort::integral_limits
 *

Changes to cxxomfort/cxxomfort/memory.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
..
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
...
168
169
170
171
172
173
174
175













176
#ifndef CXXOMFORT_MEMORY_HPP
#define CXXOMFORT_MEMORY_HPP
/**
 * @file cxxomfort/memory.hpp
 * @brief Implementations and additions tied to <memory>.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
 * - addressof
 * - alignof (as a compiler-dependent macro)
 * - alignas (in C++03-mode only)
................................................................................

#if defined(CXXOMFORT_USING_MEMTOOLS)
//
// Using the above features, we can implement aligned_storage as per cppreference.com
//
namespace cxxomfort {

#if (0 && !defined(CXXOMFORT_ALIGNMENT_TOOLS_SUPPORTED))
template <size_t S, size_t A = -1> struct aligned_storage {
    typedef union { 
        unsigned char storage[S]; 
        struct struct_;
        double dd[2]; 
        long double ld;
        double d;
        long l;
        int i;
        char c;
        void (*fn_a)();
        int struct_::memobj;
        double (struct_::*memfn)(int);
    } type;
};
#else
    #if defined(__GNUC__) && (CXXOMFORT_COMPILER_VERSION >= 406)
    // in GCC >= 4.6, __attribute__(aligned) can take compile-time constants
    #elif defined(__GNUC__) && (CXXOMFORT_COMPILER_VERSION >= 402)
    // in GCC >= 4.2, __attribute__(aligned) can only take numeric literals
    #elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG) 
    // in MSC (tested versions), __declspec(aligned) can only take numeric literals

    #elif defined(_MSC_VER)
    #else
    #error ("Unidentified method for aligned_storage.");

    #endif
#endif

//
// uninitialized_copy_n
//
template<class InpIt, class Size, class FwdIt>
FwdIt uninitialized_copy_n (InpIt ini, Size n, FwdIt dest) {
    typedef typename std::iterator_traits<FwdIt>::value_type Value;
................................................................................
}


#endif // c++03/11


#include "impl/14-make_unique.hpp"














#endif // file




<







 







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







 








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

1
2
3
4

5
6
7
8
9
10
11
..
95
96
97
98
99
100
101






























102
103
104
105
106
107
108
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef CXXOMFORT_MEMORY_HPP
#define CXXOMFORT_MEMORY_HPP
/**
 * @file cxxomfort/memory.hpp

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header:
 *
 * - addressof
 * - alignof (as a compiler-dependent macro)
 * - alignas (in C++03-mode only)
................................................................................

#if defined(CXXOMFORT_USING_MEMTOOLS)
//
// Using the above features, we can implement aligned_storage as per cppreference.com
//
namespace cxxomfort {
































//
// uninitialized_copy_n
//
template<class InpIt, class Size, class FwdIt>
FwdIt uninitialized_copy_n (InpIt ini, Size n, FwdIt dest) {
    typedef typename std::iterator_traits<FwdIt>::value_type Value;
................................................................................
}


#endif // c++03/11


#include "impl/14-make_unique.hpp"

/**
 * @page std0memory
 * @brief Implementations and additions tied to <memory>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c addressof() (C++11)
 * * <code>@ref aligned_storage</code> (C++11)
 * * <code>@ref unique_ptr</code> (C++11)
 * * @c make_unique() (C++14)
 *
 */

#endif // file

Changes to cxxomfort/cxxomfort/numeric.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
#ifndef CXXOMFORT_NUMERIC_HPP
#define CXXOMFORT_NUMERIC_HPP
/**
 * @file numeric.hpp
 * @brief Header file for the <algorithm>-related backports.
 * @ingroup numeric
 */

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


namespace cxxomfort {
namespace numeric {

//! Fills the sequence <var>[ini,fin)</var> with an incrementing sequence starting from @p i0 .
template <typename FwIt, typename T>
FwIt iota (FwIt ini, FwIt fin, T i0) {
    for(; ini!=fin; ++ini, ++i0) {*ini= i0; }
    return ini;
}

//! Fills @p n elements with an incrementing sequence starting from @p i0 .
template <typename FwIt, typename Integer, typename T>
FwIt iota_n (FwIt ini, Integer n, T i0) {
    while (n-->0) { *ini= i0; ++ini; ++i0; }
    return ini;
}


} //~namespace numeric
} //~namespace cxxomfort

namespace cxxomfort {
namespace numeric {

// see: https://en.cppreference.com/w/cpp/numeric/gcd 

template <typename IM, typename IN>
CXXO_CONSTEXPR IM gcd (IM m, IN n) CXXO_NOEXCEPT {
    return (n== 0) ? m : gcd(n, m % n);
}


template <typename IM, typename IN>
CXXO_CONSTEXPR IM lcm (IM m, IN n) CXXO_NOEXCEPT {
    return m / gcd(m,n) * n;
}

} // numeric
................................................................................
}


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



#if (CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_std_cxx11_algorithms == 0)
#if (!defined(CXXOMFORT_NO_STD_USING))
namespace std {
    using ::cxxomfort::numeric::iota;
}
#endif // std using

#endif // using emulation

#if (!defined(CXXOMFORT_NO_STD_USING))


#if (CXXOMFORT_CXX_STD < 2017)
namespace std {
    using ::cxxomfort::numeric::gcd;
    using ::cxxomfort::numeric::lcm;
}
#endif
#endif // no std using








#endif



|
<
<
|



|



|

<






<







|
|


|

<





>







 







>
>
|
<
|
|
|
|

|

<
>
>
|
|
|
|
|
|


>
>
>
>
>
>
>

1
2
3
4


5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
..
47
48
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef CXXOMFORT_NUMERIC_HPP
#define CXXOMFORT_NUMERIC_HPP
/**
 * @file


 **/

#include "base.hpp"
#include "util/meta.hpp" // conditional
#include <numeric>


namespace cxxomfort {
namespace cxxostd {


template <typename FwIt, typename T>
FwIt iota (FwIt ini, FwIt fin, T i0) {
    for(; ini!=fin; ++ini, ++i0) {*ini= i0; }
    return ini;
}


template <typename FwIt, typename Integer, typename T>
FwIt iota_n (FwIt ini, Integer n, T i0) {
    while (n-->0) { *ini= i0; ++ini; ++i0; }
    return ini;
}


} // ~namespace cxxostd
} // ~namespace cxxomfort

namespace cxxomfort {
namespace cxxostd {



template <typename IM, typename IN>
CXXO_CONSTEXPR IM gcd (IM m, IN n) CXXO_NOEXCEPT {
    return (n== 0) ? m : gcd(n, m % n);
}


template <typename IM, typename IN>
CXXO_CONSTEXPR IM lcm (IM m, IN n) CXXO_NOEXCEPT {
    return m / gcd(m,n) * n;
}

} // numeric
................................................................................
}


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

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_std_cxx11_algorithms == 0)

    namespace std {
        using ::cxxomfort::cxxostd::iota;
    }
    #endif // c++

#endif // std using


#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2017)
    namespace std {
        using ::cxxomfort::cxxostd::gcd;
        using ::cxxomfort::cxxostd::lcm;
    }
    #endif
#endif // no std using

/**
 * @page std0numeric
 * 
 * Empty of content.
 * 
 */

#endif

Changes to 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
















30
31
32
33



34



















35



36
37
38
39
40








41
42
43
44
45







46
47
48
49







50


















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

namespace cxxomfort {


















template <typename TD, typename TG>
struct random_wrapper {
    random_wrapper (TD& d, TG& g)
    : tg(g), td(d) {}























    typename TD::result_type operator() () {



        return td((TG&)tg);
    }

    std::reference_wrapper<TG> tg;
    TD td;








};

template <typename TD, typename TG>
random_wrapper<TD,TG> make_random_wrap (TD& d, TG& g) {
    return random_wrapper<TD,TG>(d,g);







}

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

 * @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 <array>
#include <ctime>

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

// TBA: Backport discrete_distribution to c++03

// C++03 approach to random_device
// #include "impl/11-random_device.hpp"

namespace cxxomfort {
namespace cxxostd {

/**
 * @brief An adapter that caches and returns results from a generator in a random-ish order.
 * @ingroup cxx11-backports
 * @xrefitem std0random "" ""
 * @anchor shuffle_order_engine
 * 
 * Given an @a Engine such as @c ranlux24_base , the instantiation 
 * <code>Foo : shuffle_order_engine<ranlux24_base,44></code> creates an 
 * adaptor that acts as an Engine, except that it caches @a 44 values 
 * that are then returned randomly instead of in the order given by the 
 * generator. Each new invocation of <code>::operator()</code> replaces 
 * the value returned from the cache with a new value from the @a Engine .
 * 
 * C++11 defines a specific instantiation with the name @c knuth_b .
 * 
 */
template <typename Engine, size_t K>



class shuffle_order_engine {
    public:
    typedef typename Engine::result_type result_type;

    shuffle_order_engine ()
    : cache_(), engine_() {}

    shuffle_order_engine (result_type s)
    : cache_(), engine_(s) {
        using namespace std;
        generate_n (begin(cache_), K-1, engine_);
    }
    shuffle_order_engine (Engine const& e)
    : cache_(), engine_(e) {}


    void seed () { engine_.seed(); }
    void seed (result_type s) { engine_.seed(s); }

    Engine const& base () const CXXO_NOEXCEPT {
        return engine_;
    }

    result_type operator() () {
        result_type ri = engine_();
        size_t idx= (ri ^ time(0)) % K;
        std::swap(ri, cache_[idx]);
        return ri;
    }




    result_type min () const { return engine_.min(); }
    result_type max () const { return engine_.max(); }

    private:
    std::array<typename Engine::result_type, K> cache_;
    Engine engine_;

};




/**
 * @c knuth_b as per C++11.
 * @ingroup cxx11-backports
 * @xrefitem std0random "" ""
 * @anchor knuth_b
 */
typedef shuffle_order_engine<std::minstd_rand0, 256> knuth_b;

}
} // cxxomfort

#if (defined(CXXOFLAG_NO_STD_USING) && CXXOFLAG_NO_STD_USING>0 )
#else
    #if (CXXOMFORT_CXX_STD < 2011)
    namespace std {
        using ::cxxomfort::cxxostd::shuffle_order_engine;
        using ::cxxomfort::cxxostd::knuth_b;
    }
    #endif
#endif

/**
 * @page std0random
 * @brief Implementations and additions tied to <random>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c shuffle_order_engine  , @c knuth_b  .
 * 
 * Pending:
 * 
 * * @c uniform_int_distribution
 * * @c discrete_distribution
 *
 */

#endif

Changes to cxxomfort/cxxomfort/sequences.hpp.

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

#include "config.hpp"
#include <array>
#include <vector>
#include <type_traits>
#include "library/i12n.hpp"
#include "using.hpp"

/**
 * @page Sequence Helpers
 * @ingroup independent-features
 * 
 * Interfaces defined in this file:
 * 
 * * @c is_std_array
 * * @c is_sequence_container
 * * @c is_indexable_like_array
 * * @c is_iterator
 * * @c make_array
 * * @c seq_ , @c generic_sequence_t
 * 
 * Pending:
 * 
 * * @c array<> in C++03 mode with NO_TR1 defined
 *

 */


//
// is_std_array
//

namespace cxxomfort {

/**
 * @brief Type identification trait for <code>std::array<...></code> types.
 */
template <typename T> struct is_std_array 
: std::false_type {};

template <typename T, size_t N> struct is_std_array< std::array<T,N> > 
: std::true_type {};

} // cxxomfort

//
// is_indexable_like_array operator
//
// A type is considered indexable like an array if it exposes a value_type 
// and a []-operator (returning value_type [const] &).
namespace cxxomfort {
namespace detail {

template <typename T> struct bracket_indexable_helper {

    typedef struct { int a; } yes;
    typedef char no;

    private:
    template <typename U, U> struct really_has;

    template <typename C> static yes& Test_op(really_has <typename C::value_type const& (C::*)() const,
                            &C::operator[] >*);

    template <typename> static no& Test_op(...);
    
    public:
    static const bool has_op    = (sizeof(Test_op<T>(0)) == sizeof(yes));

};


} // detail

/**
 * @brief Type identification trait for types that 
 * are indexable via an array-like <code>operator[]</code>.
 */
template <typename T> struct is_indexable_like_array 
: std::conditional< detail::bracket_indexable_helper<T>::has_op, std::true_type, std::false_type>::type
{};

template <typename T, size_t N> struct is_indexable_like_array< T[N] >
: std::true_type 
{};


} //cxxomfort::

// sequence_t and seq_ generator
#include "impl/seq_.hpp"

//
// is_sequence -- for specializations based on ability to provide 
// access to a sequence of objects
//
#include <iterator>
#include <type_traits>

namespace cxxomfort {

//
// is_iterator
//

namespace detail {

// detect iterator_category member
template <typename T> struct has_member_iterator_category {
private:
    typedef char                      yes;
    typedef yes no[2];

    template <typename C> static yes& test_ic(typename C::iterator_category*);
    template <typename C> static no&  test_ic(...);

    public:
    // iterator_category
    static const bool value = sizeof(test_ic<T>(0)) == sizeof(yes);
};

} // detail::

// Given a type @p T , inherit from @c true_type  if @p T  is a type 
// considered an iterator by iterator_traits.
/*
template<typename T, typename = void>
 struct is_iterator : std::false_type {};

template<typename T>
struct is_iterator<
    T, typename std::enable_if<
        detail::has_member_iterator_category< std::iterator_traits<T> >::value 
        and !std::is_same<typename std::iterator_traits<T>::value_type, void>::value 
    >::type> : std::true_type {};
*/


/**
 * @brief Type identification trait for iterator types
 * as defined by the <code><iterator></code> interface.
 */
template<class T>
struct is_iterator {   
    static T makeT();
    typedef void * twoptrs[2];  // sizeof(twoptrs) > sizeof(void *)
    static twoptrs & test(...); // Common case
    template<class R> static typename R::iterator_category * test(R); // Iterator
    template<class R> static void * test(R *); // Pointer

    static const bool value = sizeof(test(makeT())) == sizeof(void *); 
};



/* A type S is considered a sequence if:
 * * the calls std::begin(s) and std::end(s) make sense
 * * the return type of those calls is specialized by iterator_traits
 * * alternatively, S is a native C array
 */

namespace detail {

    template <typename T> struct has_sequence_members {
    private:
        typedef char                      yes;
        typedef yes no[2];

        template <typename C> static yes& test_ci(typename C::const_iterator*);
        template <typename C> static no&  test_ci(...);
        template <typename C> static yes& test_vt(typename C::value_type*);
        template <typename C> static no&  test_vt(...);

        public:
        // const_iterator
        static const bool value_ci = sizeof(test_ci<T>(0)) == sizeof(yes);
        // value_type
        static const bool value_vt = sizeof(test_vt<T>(0)) == sizeof(yes);
        typedef T type;

        private:
        template <typename U, U> struct really_has;

        template <typename C> static yes& Test_begin(really_has <typename C::const_iterator (C::*)() const,
                                            &C::begin>*);

        template <typename C> static yes& Test_begin(really_has <typename C::iterator (C::*)() const,
                                            &C::begin>*);

        template <typename C> static yes& Test_end(really_has <typename C::const_iterator (C::*)() const,
                                            &C::end>*);

        template <typename C> static yes& Test_end(really_has <typename C::iterator (C::*)() const,
                                            &C::end>*);

        template <typename> static no& Test_begin(...);
        template <typename> static no& Test_end(...);
        
        public:
        static bool const value_begin_end = (
            sizeof(Test_begin<T>(0)) == sizeof(yes) )
            && ( sizeof(Test_end<T>(0)) == sizeof(yes)
            );

    };

template <typename T, bool=false>
struct is_sequence_impl: traits::false_type {};

template <typename T> struct is_sequence_impl<T,true> 
: traits::integral_constant<bool, is_iterator<typename T::const_iterator>::value > {};

} // detail::

// at present, a type S is a sequence if:
// 1.- has a const_iterator and value_type member types
// 1b.- has begin, end member functions returning type iterator or const_iterator (other overloads are ignored)
// 2.- or is a C array.

/**
 * @brief Type identification trait for sequence-like types:
 * * have a @c const_iterator member type.
 * * have a @c begin  and @c end  member function.
 */
template <typename S> struct is_sequence 
: detail::is_sequence_impl<S, 
    detail::has_sequence_members<S>::value_ci 
    && detail::has_sequence_members<S>::value_vt
    && detail::has_sequence_members<S>::value_begin_end 
> {};

// arrays are sequences
template <typename T, size_t N>
struct is_sequence< T[N] > : traits::true_type {};

// starting C++11, valarrays are sequences

#if (CXXOMFORT_CXX_STD >= 2011)
template <typename T>
struct is_sequence< std::valarray<T> >: std::true_type {};
#endif

} // cxxomfort

// make_array
#include "impl/n4031_make_array.hpp"
// fixed_vector
#include "library/fixed_vector.hpp"


#endif
|
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
1
2

3































































































































































































































































#include <cxxomfort/config.hpp>
#pragma message CXXO_WARNING("this header is deprecated. New header is <cxxomfort/library/sequences.hpp>")

#include <cxxomfort/library/sequences.hpp>































































































































































































































































Changes to cxxomfort/cxxomfort/string.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
..
18
19
20
21
22
23
24
25













26
#ifndef CXXOMFORT_STRING_HPP
#define CXXOMFORT_STRING_HPP
/**
 * @file
 * @brief Implementations and backports related to <code><string></code>.
 * 
 * Interfaces defined in this header:
 *
 * * to_string() (C++11) and others
 *
 */

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

#include "impl/11-to_string.hpp"
//#include "impl/14-string_literal.hpp"














#endif




<







 








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

1
2
3
4

5
6
7
8
9
10
11
..
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef CXXOMFORT_STRING_HPP
#define CXXOMFORT_STRING_HPP
/**
 * @file

 * 
 * Interfaces defined in this header:
 *
 * * to_string() (C++11) and others
 *
 */

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

#include "impl/11-to_string.hpp"
//#include "impl/14-string_literal.hpp"

/**
 * @page std0string
 * 
 * Implementations and additions tied to <code><string></code>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c to_string() (C++11)
 * * @c strtoll() , @c strtoull() (C++11)
 *
 */


#endif

Added cxxomfort/cxxomfort/system_error.hpp.

















































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#ifndef CXXOMFORT_SYSTEM_ERROR_HPP
#define CXXOMFORT_SYSTEM_ERROR_HPP
/**
 * @file
 * 
 * Interfaces defined in this file:
 * 
 */

#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 (CXXOMFORT_CXX_STD < 2011)

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 
 * provided by eg.: @c errc , and an error category 
 * as provided by @c error_category. 
 * 
 * In C++11 onwards @c error_condition and others are used by the 
 * 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
//

class error_code {
    public:
    
    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
: public std::runtime_error {
    public:

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

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

#endif


    ~system_error () CXXO_NOEXCEPTNOTHROW {}

    error_code const& code() const CXXO_NOEXCEPTNOTHROW {
        return E;
    }
    
    private:
    error_code const E;
    std::string W;
};


//
// out-of-class members
//

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

// nonmember helpers

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

// end namespaces

}}

#endif // c++11

#if (CXXOMFORT_CXX_STD < 2011)
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;
    
}
#else
#include <system_error>

#endif

#endif

Changes to cxxomfort/cxxomfort/tuple.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
..
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
#ifndef CXXOMFORT_TUPLE_HPP
#define CXXOMFORT_TUPLE_HPP
/**
 * @file
 * @brief Implementations and additions for <tuple> in C++
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * 
 * Interfaces defined in this header:
 *
 * * cxxomfort::is_tuple
 * * tuple2array
 * * get<T> for std::tuple (c++14)
................................................................................
#endif

#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 {
//! @brief Components related to <tuple>
namespace tuple {

template <typename Tuple>
struct _tuple2array_cnv_t {
    // Tuple is a tuple
    static_assert (is_tuple<Tuple>::value, "tuple_to_array: T must be a tuple");
    typedef /* typename std::decay<Tuple>::type */ Tuple InTuple;
    static const size_t _S = std::tuple_size<InTuple>::value;
    typedef typename std::tuple_element<0,Tuple>::type U;
    private:
    
    template <unsigned U>
    struct _notenabled;
    
    public:
    
    _tuple2array_cnv_t (Tuple const& t): _t(t) {}
    // conversion operator to an array of the same size as the tuple
#if (1 && ( CXXOMFORT_CXX_STD >= 2011 || (CXXOMFORT_CXX_EMULATION == 2011 && CXXO_EMULATION_variadic && CXXO_EMULATION_rvref)))
    template<size_t... I>
    std::array<U,_S> get_array (std::index_sequence<I...>) const {
        using std::get;
        using std::forward;
        return std::array<U,_S> { { get<I>((_t))... } };
    }


    template <typename Indices = std::make_index_sequence<std::tuple_size<InTuple>::value> >
    operator std::array<U,_S> () const {
        return get_array(Indices());
    }


#else
#define CXXO_m_cnv_array(n) operator typename std::conditional< _S==n, std::array<U,n> , _notenabled<n> >::type
    CXXO_m_cnv_array(1) () const {
        using namespace std;
        array<U,1> ret= { get<0>(_t) };
        return ret;


    }
    CXXO_m_cnv_array(2) () const {
        using namespace std;
        array<U,2> ret= { get<0>(_t), get<1>(_t) };
        return ret;
    }
    CXXO_m_cnv_array(3) () const {
        using namespace std;
        array<U,3> ret= { get<0>(_t), get<1>(_t), get<2>(_t) };
        return ret;
    }
    CXXO_m_cnv_array(4) () const {
        using namespace std;
        array<U,4> ret= { get<0>(_t), get<1>(_t), get<2>(_t), get<3>(_t) };
        return ret;
    }

    CXXO_m_cnv_array(5) () const {
        using namespace std;
        array<U,5> ret= { get<0>(_t), get<1>(_t), get<2>(_t), get<3>(_t), get<4>(_t) };
        return ret;
    }

#undef CXXO_m_cnv_array
#endif
    private:
    Tuple const& _t;
};

template <typename T>
_tuple2array_cnv_t<T> tuple2array (T const& t) {
    return _tuple2array_cnv_t<T>(t);
}

/*
 * array to tuple
 */

template <typename T> struct tuple_of_array_size;

template <typename T0> struct tuple_of_array_size< std::array<T0,1> > {
    typedef std::tuple<T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,2> > {
    typedef std::tuple<T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,3> > {
    typedef std::tuple<T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,4> > {
    typedef std::tuple<T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,5> > {
    typedef std::tuple<T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,6> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,7> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,8> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,9> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0,T0,T0>  type;
};
template <typename T0> struct tuple_of_array_size< std::array<T0,10> > {
    typedef std::tuple<T0,T0,T0,T0,T0,T0,T0,T0,T0,T0>  type;
};


template <typename T>
struct _array2tuple_cnv_t {};

template <typename T, size_t N>
struct _array2tuple_cnv_t< std::array<T,N> > {
    private:
    // Tuple is a tuple
    //static_assert (is_tuple<Tuple>::value, "tuple_to_array: T must be a tuple");
    private:
    std::array<T,N> const& _a;

    typedef /* typename std::decay<Tuple>::type */ std::array<T,N> InArray;
    typedef typename InArray::value_type U;
    template <unsigned U>
    struct _notenabled;
    public:


    _array2tuple_cnv_t (InArray const& a): _a(a) {}


#if (1 && ( CXXOMFORT_CXX_STD >= 2011 || (CXXOMFORT_CXX_EMULATION == 2011 && CXXO_EMULATION_variadic && CXXO_EMULATION_rvref)))
    template <size_t... I>
    typename tuple_of_array_size< InArray>::type get_tuple (std::index_sequence<I...>) const {
        return std::make_tuple(_a[I]...);
    }

    template <typename Indices = std::make_index_sequence<N> >
    operator typename tuple_of_array_size< InArray >::type () const {
        return std::move(get_tuple(Indices()));
    }

#else

#define CXXO_m_cnv_tuple(n) operator typename std::conditional< N==n \
    , typename tuple_of_array_size< std::array<T,n> >::type, _notenabled<n> > \
    ::type

    CXXO_m_cnv_tuple(1) () const { return std::make_tuple( _a[0] ); }
    CXXO_m_cnv_tuple(2) () const { return std::make_tuple( _a[0], _a[1] ); }
    CXXO_m_cnv_tuple(3) () const { return std::make_tuple( _a[0], _a[1], _a[2] ); }
    CXXO_m_cnv_tuple(4) () const { return std::make_tuple( _a[0], _a[1], _a[2], _a[3] ); }
    CXXO_m_cnv_tuple(5) () const { return std::make_tuple( 
        _a[0], _a[1], _a[2], _a[3], _a[4] 
    ); }
    CXXO_m_cnv_tuple(6) () const { return std::make_tuple( 
        _a[0], _a[1], _a[2], _a[3], _a[4], _a[5] 
    ); }
    CXXO_m_cnv_tuple(7) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6] 
    ); }
    CXXO_m_cnv_tuple(8) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6], _a[7] 
    ); }
    CXXO_m_cnv_tuple(9) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6], _a[7], _a[8] 
    ); }
    CXXO_m_cnv_tuple(10) () const { return std::make_tuple
        ( _a[0], _a[1], _a[2], _a[3], _a[4], _a[5], _a[6], _a[7], _a[8], _a[9] 
    ); }
    
#undef CXXO_m_cnv_tuple

#endif

};

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

} //cxxomfort::tuple
} //

/**
 * @page std:tuple
 * 
 * Features part of the <tuple>-related backports:

 * 
 * * @ref get<tuple>()
 * * @ref tupple_apply()
 * * @ref make_from_tuple()
 * 
 * See also: @ref std:utility .
 * 
 */

#endif





<







 







<
|

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



|

<
>

|
|
|

|





1
2
3
4

5
6
7
8
9
10
11
..
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
#ifndef CXXOMFORT_TUPLE_HPP
#define CXXOMFORT_TUPLE_HPP
/**
 * @file

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 * 
 * Interfaces defined in this header:
 *
 * * cxxomfort::is_tuple
 * * tuple2array
 * * get<T> for std::tuple (c++14)
................................................................................
#endif

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

/**
 * @page std0tuple
 * 

 * Features related to <code><tuple></code>.
 * 
 * * @c get<tuple>() (C++14)
 * * @c tupple_apply() (C++17)
 * * @c make_from_tuple() (C++17)
 * 
 * See also: @ref std0utility .
 * 
 */

#endif

Changes to cxxomfort/cxxomfort/type_traits.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
..
46
47
48
49
50
51
52




53
54
55
56
57
58
59
..
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
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
407
408
409
410
411
412
413
414
415

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433

434





435




436
437
438
439
440
441

442
443
444
445
446
447
448
449
450
451
452

453
454
455
456
457
458
459
#ifndef CXXOMFORT_TYPE_TRAITS_HPP
#define CXXOMFORT_TYPE_TRAITS_HPP
/**
 * @file cxxomfort/type_traits.hpp
 * @brief Implementations and additions tied to <type_traits>.
 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header in namespace std:
 * 
 * * @c is_lvalue_reference (in c++03 mode)
 * * @c {add,remove}_lvalue_reference (in c++03 mode)
 * * @c decay  (in c++03 mode)
................................................................................
    #if (!defined(__GXX_EXPERIMENTAL_CXX0X__) )
        #define CXXO_LACKS_make_signed 1
    #endif
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_CLANG)
    #if (CXXOMFORT_CXX_STD < 2011)
        #define CXXO_LACKS_make_signed 1
    #endif




#else 
#endif

#if defined(CXXO_LACKS_make_signed)
namespace std { namespace tr1 {
    using cxxomfort::traits::make_signed;
    using cxxomfort::traits::make_unsigned;
................................................................................
    template <typename T>
    struct is_rvalue_reference { static const bool value = false; };

}
#endif
#undef CXXO_MIRROR_LVALUE_REFERENCE

/*
 * decay for C++03
 */

#if ( (CXXOMFORT_CXX_STD < 2011) && (CXXOMFORT_CXX_EMULATION == 0 ) )
namespace std {
template< typename T >
struct decay {
    private:
    typedef typename std::remove_reference<T>::type U;
    public:
    typedef typename std::conditional< 
        std::is_array<U>::value,
        typename std::remove_extent<U>::type*,
        typename std::conditional< 
            std::is_function<U>::value,
            typename std::add_pointer<U>::type,
            typename std::remove_cv<U>::type
        >::type
    >::type type;
};





}
#endif

/*
 * Triviality / Throwness traits
 * (is_trivially_..., is_nothrow_...)
 * 
 */
#include "util/traits_tn.hpp"
................................................................................

    template <typename T> struct is_trivially_destructible
    : integral_constant<bool, __has_trivial_destructor(T)> {};

}
#endif

/*
 * Common_type
 */
#include "util/traits_ct.hpp"


#if 0 // -- is_constructible
//
// "variadic" is_constructible, is_assignable implementation
//

................................................................................
        is_scalar<T>::value && !(is_same<T,void>::value) 
    > {};

}
#endif



//

// underlying_type
//
#include "various.hpp" // integral_of_size

#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_GCC)
    // Add underlying_type approximation for GCC < 4.7 in any mode
    // see http://stackoverflow.com/questions/9343329/how-to-know-underlying-type-of-class-enum/10956467#10956467
    #if (CXXOMFORT_COMPILER_VERSION < 407)
        #define CXXOMFORT_USING_underlying_type 1
    #elif (CXXOMFORT_COMPILER_VERSION >= 407 && CXXOMFORT_CXX_STD < 2011 )
        #define CXXOMFORT_USING_underlying_type 1
    #endif
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_CLANG)
    #if (CXXOMFORT_CXX_STD >= 2011)
    #else
        #define CXXOMFORT_USING_underlying_type 1
    #endif







#endif // support for underlying_type





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


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


    }

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

#endif // #include guard




<







 







>
>
>
>







 







<
<
<

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

>
>
>

<
<







 







<
<
<
<







 







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

|
<
<
<
<

1
2
3
4

5
6
7
8
9
10
11
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
92
93
94
95
96
97
98



99

















100
101
102
103
104


105
106
107
108
109
110
111
...
130
131
132
133
134
135
136




137
138
139
140
141
142
143
...
387
388
389
390
391
392
393

394
395
396


397














398
399
400
401
402
403
404
405
406
407
408
409
410





411
412










413
414
415




416
#ifndef CXXOMFORT_TYPE_TRAITS_HPP
#define CXXOMFORT_TYPE_TRAITS_HPP
/**
 * @file cxxomfort/type_traits.hpp

 * @author Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 *
 * Interfaces defined in this header in namespace std:
 * 
 * * @c is_lvalue_reference (in c++03 mode)
 * * @c {add,remove}_lvalue_reference (in c++03 mode)
 * * @c decay  (in c++03 mode)
................................................................................
    #if (!defined(__GXX_EXPERIMENTAL_CXX0X__) )
        #define CXXO_LACKS_make_signed 1
    #endif
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_CLANG)
    #if (CXXOMFORT_CXX_STD < 2011)
        #define CXXO_LACKS_make_signed 1
    #endif
#elif (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC)
    #if (CXXOMFORT_COMPILER_VERSION < 140)
        #define CXXO_LACKS_make_signed 1
    #endif
#else 
#endif

#if defined(CXXO_LACKS_make_signed)
namespace std { namespace tr1 {
    using cxxomfort::traits::make_signed;
    using cxxomfort::traits::make_unsigned;
................................................................................
    template <typename T>
    struct is_rvalue_reference { static const bool value = false; };

}
#endif
#undef CXXO_MIRROR_LVALUE_REFERENCE























#include "impl/11-decay.hpp"
#include "impl/11-underlying_type.hpp"
#include "util/traits_ct.hpp"




/*
 * Triviality / Throwness traits
 * (is_trivially_..., is_nothrow_...)
 * 
 */
#include "util/traits_tn.hpp"
................................................................................

    template <typename T> struct is_trivially_destructible
    : integral_constant<bool, __has_trivial_destructor(T)> {};

}
#endif







#if 0 // -- is_constructible
//
// "variadic" is_constructible, is_assignable implementation
//

................................................................................
        is_scalar<T>::value && !(is_same<T,void>::value) 
    > {};

}
#endif



/**
 * @page std0type_traits
 * @brief Implementations and additions tied to <type_traits>.


 * 














 * Interfaces defined in this file:
 * 
 * * @ref @c enable_if , @ref @c conditional (C++11)
 * * @c @ref is_lvalue_reference , @c ¢ref is_rvalue_reference and sibling transformations (C++11)
 * * @c @ref is_trivially_copy_constructible and sibling "triviality" traits (C++11)
 * * @c @ref is_trivial , @c @ref is_literal_type (C++11)
 * * @ref @c decay (C++11)
 * * @ref @c underlying_type (C++11)
 * * @ref @c is_null_pointer (C++14)
 * * @ref @c void_t , @ref @c make_void (C++17)
 * * <code>@ref bool_constant</code> (C++17)
 * * ...And others.
 * 





 * See also @ref std0utility , @ref cxxomfort-metaprogramming .
 *










 */






#endif // #include guard

cxxomfort/cxxomfort/using.hpp became a regular file.

cxxomfort/cxxomfort/util/memtraits.hpp became a regular file.

cxxomfort/cxxomfort/util/meta.hpp became a regular file.

Changes to cxxomfort/cxxomfort/util/traits_ct.hpp.

218
219
220
221
222
223
224















225
226
227
228
 : common_type<T> 
 {};


}    // namespace std
#endif // _IMPLEMENT_

















#endif









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




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
 : common_type<T> 
 {};


}    // namespace std
#endif // _IMPLEMENT_

#if defined(DOXYGEN_DOC)

/**
 * @struct common_type
 * @brief Calculates the common type between two types.
 * @ingroup cxx11-backports
 * @xrefitem std:type_traits "<type_traits>" ""
 * 
**/
template <typename... Types>
struct common_type {
    typedef _implementation_defined_ type;
};

#endif

#endif


cxxomfort/cxxomfort/util/traits_tn.hpp became a regular file.

Changes to cxxomfort/cxxomfort/util/type_traits.hpp.

74
75
76
77
78
79
80
81
82
83
84




85
86
87
88
89
90
91
92
93
94
95
96
97
/**
 * integral_constant
 */
template <typename Integral, Integral I> struct integral_constant {
    typedef Integral value_type;
    typedef integral_constant<Integral,I> type;
    static const Integral value= I;
    CXXOMFORT_CXX11_CODE(constexpr,) operator value_type () const { return value; }
    CXXOMFORT_CXX11_CODE(constexpr,) value_type operator() () const { return value; } // from C++14
};





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



//
// is_void
//
template <typename T> struct is_void : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_void,void);








|
|


>
>
>
>




<
<







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

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

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



//
// is_void
//
template <typename T> struct is_void : false_type {};
TR1LITE_DEF_SPECIALIZE_CV_TRUE(is_void,void);

Changes to cxxomfort/cxxomfort/utility.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
..
62
63
64
65
66
67
68
69















70
#ifndef CXXOMFORT_UTILITY_HPP
#define CXXOMFORT_UTILITY_HPP
/**
 * @file
 * @page std:utility
 * @brief Implementations and additions tied to <utility>.
 * 
 * Interfaces defined in this file:
 * 
 * * declval()
 * * exchange()
 * * move (from util/move)
 * * forward (from util/move)
 * * as_const() (from c++17)
 * 
 * Interfaces reflected in namespace @b std : 
 * 
 * * declval
 * * exchange
 * * as_const 
 * 
 */

#include "base.hpp"   // move, forward
#include "util/meta.hpp"
#include "util/type_traits.hpp"
#include <type_traits>

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


namespace cxxomfort {
namespace cxxostd {

    //! Unevaluated context.
    //! @ingroup utility
    //! @ingroup cxx11-backports


    template <typename T> typename cxxomfort::traits::add_reference<T>::type declval();
}
}

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC && CXXOMFORT_COMPILER_VERSION==150)
    // MSVC 2010 does not ship with a declval
................................................................................
#define CXXOMFORT_IMPLEMENTS_n1978 CXXO_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n2343 CXXO_BACKPORT()


#include "impl/n3668_exchange.hpp"
#include "impl/14-integer_sequence.hpp"
#include "impl/17-as_const.hpp"
















#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
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef CXXOMFORT_UTILITY_HPP
#define CXXOMFORT_UTILITY_HPP
/**
 * @file


 * 
 * Interfaces defined in this file:
 * 












 */

#include "base.hpp"   // move, forward
#include "util/meta.hpp"
#include "util/type_traits.hpp"
#include <type_traits>

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


namespace cxxomfort {
namespace cxxostd {
    /** 
     * @brief Expression for an unevaluated context.

     * @ingroup cxx11-backports
     * @xrefitem std:utility "<utility>" ""
     */
    template <typename T> typename cxxomfort::traits::add_reference<T>::type declval();
}
}

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC && CXXOMFORT_COMPILER_VERSION==150)
    // MSVC 2010 does not ship with a declval
................................................................................
#define CXXOMFORT_IMPLEMENTS_n1978 CXXO_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n2343 CXXO_BACKPORT()


#include "impl/n3668_exchange.hpp"
#include "impl/14-integer_sequence.hpp"
#include "impl/17-as_const.hpp"

/**
 * @page std0utility
 * @brief Implementations and additions tied to <code><utility></code>.
 * 
 * A listing of the interfaces from <code><utility></code> backported in this library.
 * 
 * * @c declval() (C++11)
 * * @c exchange() (C++14)
 * * @c @ref integer_sequence (C++14) (down to C++11 only)
 * * @c as_const() (C++17)
 *
 * See also @ref std0type_traits , @ref std0tuple .
 */


#endif

Changes to cxxomfort/cxxomfort/various.hpp.

21
22
23
24
25
26
27



28
29
30
31
32
33
34
 */

#include "config.hpp"
#include "base.hpp"   // sized integer types
#if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
#pragma message CXXO_NOTICE("enabled various built-in utilities")
#endif



//////////////////////////////////////////////////
// The purpose of the utilities here is, for the most part, to assist in 
// choosing types or functions programatically for the types of objects, 
// so as to avoid depending on "auto"-like features to make code readable
// (and writable!).

namespace cxxomfort {







>
>
>







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

#include "config.hpp"
#include "base.hpp"   // sized integer types
#if defined (CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
#pragma message CXXO_NOTICE("enabled various built-in utilities")
#endif

#include <iso646.h>

//////////////////////////////////////////////////
// The purpose of the utilities here is, for the most part, to assist in 
// choosing types or functions programatically for the types of objects, 
// so as to avoid depending on "auto"-like features to make code readable
// (and writable!).

namespace cxxomfort {