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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d22509b55b60dac8d898fddd7015ee31b86379d2
User & Date: luismachuca 2018-08-22 04:58:58
Context
2018-09-23
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
2018-08-17
04:41
Commit 2018-08-17 - Corrections for MSVC 2010/2012 compat.
  • config: Fixed detection of MSVC 2010, 2012 features.
  • random: Fixed C++03 feature renames that are for GCC only.
  • string: Fixed missing strto(u)ll in MSVC 2010,2012 fixed.
  • string: Fixed to_string for MSVC 2012.
  • string: Fixed to_string, strtoull overloads for MSVC 2012.
  • type_traits: Added enable_if, conditional moved to their own file and fixed for C++03 support.
  • library: string: Fixed utf8chr function calls.
  • extras: array_ref: Fixed the fixed_vector constructor.
  • Upcoming Changes:
  • Changes to <functional>: functors.
  • Changes to <type_traits>: minimal TR1.
  • Additions to <cstddef>: user defined literals.
  • Additions to <functional>: not_fn.
  • Additions to cstd: <optional>.
  • Additions to cstd: <variant>.
  • Additions to <library/random>: distributor wrappers.
  • Additions to <library/string>: strsprintf.
check-in: 6fe18ebc user: luismachuca tags: trunk
Changes

Changes to cxxomfort/cxxomfort/VERSION.txt.

1
cxxomfort 0.70 2018-07-01
|
1
cxxomfort 0.72 2018-07-01

Changes to cxxomfort/cxxomfort/algorithm.hpp.

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
...
218
219
220
221
222
223
224

225
226
227
228
229
230
231
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
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);
}


//
// 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::make_pair(b, a) : std::make_pair(a, b)
    ;
}

//! @overload minmax
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;

    if (less(*ini, *result.ini)) {
        result.second = result.ini;
        result.ini = ini;
    } else {
        result.second = ini;
    }
    while (++ini != fin) {
        FIterator i = ini;
        if (++ini == fin) {
            if (less(*i, *result.ini)) result.ini = i;
            else if (!(less(*i, *result.second))) result.second = i;
            break;
        } else {
            if (less(*ini, *i)) {
                if (less(*ini, *result.ini)) result.ini = ini;
                if (!(less(*i, *result.second))) result.second = i;
            } else {
                if (less(*i, *result.ini)) result.ini = i;
                if (!(less(*ini, *result.second))) result.second = ini;
            }
        }
    }
    return result;

}

//! @overload minmax_element
template <typename FIterator>
std::pair<FIterator,FIterator> 
minmax_element (FIterator ini, FIterator fin) {
    std::less <typename std::iterator_traits<FIterator>::value_type> less;
    return minmax_element(ini, fin, less);
}


// detail helpers for shuffle
namespace detail_algorithm {

    template <typename URNG, typename E>
    E uniform_in (URNG& u, E m1, E m2) {
................................................................................

#define CXXOMFORT_IMPLEMENTS_n1990 CXXO_BACKPORT()

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

#include "impl/11-permutations.hpp"
// c++14 onwards
#include "impl/14-algorithm-equal.hpp"
// pending: #include "impl/modifying.hpp"
// c++17 onwards(?)
#include "impl/17-clamp.hpp"

................................................................................
    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::minmax;
    using ::cxxomfort::algorithm::minmax_element;
    using ::cxxomfort::algorithm::shuffle;
    
    using ::cxxomfort::algorithm::for_each_n;
    
}
#endif // std using








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







 







>







 







<
<







101
102
103
104
105
106
107






























































108
109
110
111
112
113
114
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
182
183
184
185
186
187
188


189
190
191
192
193
194
195
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) {
................................................................................

#define CXXOMFORT_IMPLEMENTS_n1990 CXXO_BACKPORT()

// These are in their own files
//#include "impl/03-minmax.hpp"
// included in c++11 onwards
#include "impl/11-is_xxx_of.hpp"
#include "impl/11-minmax.hpp"
#include "impl/11-permutations.hpp"
// c++14 onwards
#include "impl/14-algorithm-equal.hpp"
// pending: #include "impl/modifying.hpp"
// c++17 onwards(?)
#include "impl/17-clamp.hpp"

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

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

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
...
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
...
339
340
341
342
343
344
345
346
347
348


349
, typename std::iterator_traits<FIterator>::difference_type n = 1
) {
    std::advance(i, -n);
    return i;
}


//
// 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 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, 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_COMPILER_ID==CXXO_VALUE_COMPILER_GCC \
    && CXXOMFORT_COMPILER_VERSION >= 408)
#pragma GCC diagnostic pop
#endif

/**
................................................................................
/*
 * Provide begin, end support for std::valarray as well.
 */
namespace std {
template <typename T> class valarray;
}

namespace cxxomfort {

template <typename T> inline
T* begin (std::valarray<T> & c) { return addressof(c[0]); }

template <typename T> inline
T const* begin (std::valarray<T> const& c) { return addressof(c[0]); }

................................................................................
template <typename T> inline
T* end (std::valarray<T> & c) { return addressof(c[0])+c.size(); }

template <typename T> inline
T const* end (std::valarray<T> const& c) { return addressof(c[0])+c.size(); }



} //~::cxxomfort


#endif // valarray support


namespace std {
................................................................................
    using ::cxxomfort::iterator::prev;
    #endif

#else
	using ::cxxomfort::iterator::cbegin;
	using ::cxxomfort::iterator::cend;
#endif
    //using ::cxxomfort::size; // not enabled yet
}



#endif







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







 







|







 







>







 







<


>
>

231
232
233
234
235
236
237









































238
239
240
241
242
243
244
...
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
...
299
300
301
302
303
304
305

306
307
308
309
310
, typename std::iterator_traits<FIterator>::difference_type n = 1
) {
    std::advance(i, -n);
    return i;
}












































#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC \
    && CXXOMFORT_COMPILER_VERSION >= 408)
#pragma GCC diagnostic pop
#endif

/**
................................................................................
/*
 * Provide begin, end support for std::valarray as well.
 */
namespace std {
template <typename T> class valarray;
}

namespace cxxomfort { namespace iterator {

template <typename T> inline
T* begin (std::valarray<T> & c) { return addressof(c[0]); }

template <typename T> inline
T const* begin (std::valarray<T> const& c) { return addressof(c[0]); }

................................................................................
template <typename T> inline
T* end (std::valarray<T> & c) { return addressof(c[0])+c.size(); }

template <typename T> inline
T const* end (std::valarray<T> const& c) { return addressof(c[0])+c.size(); }


}
} //~::cxxomfort


#endif // valarray support


namespace std {
................................................................................
    using ::cxxomfort::iterator::prev;
    #endif

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

}

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

#endif

Changes to cxxomfort/cxxomfort/config.hpp.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 * @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 20180701UL
//! Defines the library version (WARNING: to be deprecated)
#define CXXOMFORT_VERSION 60

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

//
// Standard Mode
................................................................................
//
// 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/type_traits header in c++03 mode
#define CXXO_COMPILER_SUPPORT_tr1_type_traits 0
//! If compiler provides support for @c __typeof__ in C++03.
#define CXXO_COMPILER_SUPPORT_typeof 0
//! If compiler provides support for variadic macros (<code>__VA_ARG__</code>).
#define CXXO_COMPILER_SUPPORT_va_args 0

//! 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 @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr (CXXOMFORT_CXX_STD>=2011)


//! If compiler supports @c decltype(expr) .
#define CXXO_COMPILER_SUPPORT_decltype (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code>=default</code>-ed and <code>=delete</code>-d members.
#define CXXO_COMPILER_SUPPORT_default_delete (CXXOMFORT_CXX_STD>=2011)


//! 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 @c std::initializer_list .
#define CXXO_COMPILER_SUPPORT_initializer_list (CXXOMFORT_CXX_STD>=2011)


//! 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 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_cxx11_constructible_traits 0
//! If compiler provides support for trailing return types.
#define CXXO_COMPILER_SUPPORT_trailing_returns (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for @c unique_ptr<T> .
#define CXXO_COMPILER_SUPPORT_unique_ptr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for variadic templates.
#define CXXO_COMPILER_SUPPORT_variadic (CXXOMFORT_CXX_STD>=2011)

//! If compiler provides support for C++14's relaxed form of @c constexpr .
#define CXXO_COMPILER_SUPPORT_constexpr_relaxed (CXXOMFORT_CXX_STD>=2014)
//! If compiler supports <functional> 's transparent functors.
#define CXXO_COMPILER_SUPPORT_functional_transparent (CXXOMFORT_CXX_STD >= 2014)
//! If compiler provides support for "integer_sequence".
#define CXXO_COMPILER_SUPPORT_integer_sequence (CXXOMFORT_CXX_STD >= 2014)



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

// Detect CXX_STD and operation mode (initial)








|

|







 







|
|
|
|
<
<
<








>
>


>
>




>
>






>
>
>
>


>
>








>
>







 







<
<
<
<
<
|
|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
...
110
111
112
113
114
115
116





117
118
119
120
121
122
123
124
125
 * @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
................................................................................
//
// 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_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)

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

70
71
72
73
74
75
76


77
78
79
80
81
82
83
..
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
...
136
137
138
139
140
141
142


143
144
145
146
147
148
149
        // Note: *Unsupported* c++0x emulation mode
        #define CXXOMFORT_CXX_EMULATION 2011
        #pragma message CXXO_WARNING( "Configuration not supported (nullptr and other basic features are missing)" )
        #undef  CXXO_COMPILER_SUPPORT_alignof
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #undef  CXXO_COMPILER_SUPPORT_auto
        #define CXXO_COMPILER_SUPPORT_auto 1


        #undef  CXXO_COMPILER_SUPPORT_default_delete
        #define CXXO_COMPILER_SUPPORT_default_delete 1
        #undef  CXXO_COMPILER_SUPPORT_enum_class
        #define CXXO_COMPILER_SUPPORT_enum_class 1
        #undef  CXXO_COMPILER_SUPPORT_rvref
        #define CXXO_COMPILER_SUPPORT_rvref 1
        #undef  CXXO_COMPILER_SUPPORT_static_assert
................................................................................
        //#define CXXO_COMPILER_SUPPORT_std_iterator_helpers 1
        #define CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers 1
        #undef  CXXO_COMPILER_SUPPORT_unique_ptr
        #define CXXO_COMPILER_SUPPORT_unique_ptr 1
        #undef  CXXO_COMPILER_SUPPORT_variadic
        #define CXXO_COMPILER_SUPPORT_variadic 1
    #else




        
    #endif
#endif
#if (CXXOMFORT_COMPILER_VERSION >= 406)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        #undef  CXXOMFORT_CXX_EMULATION
        #define CXXOMFORT_CXX_EMULATION 2011
        #undef  CXXO_COMPILER_SUPPORT_alignof
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #undef  CXXO_COMPILER_SUPPORT_auto
        #define CXXO_COMPILER_SUPPORT_auto 1


        #undef  CXXO_COMPILER_SUPPORT_default_delete
        #define CXXO_COMPILER_SUPPORT_default_delete 1
        #undef  CXXO_COMPILER_SUPPORT_enum_class
        #define CXXO_COMPILER_SUPPORT_enum_class 1
        #undef  CXXO_COMPILER_SUPPORT_explicit_operator
        #define CXXO_COMPILER_SUPPORT_explicit_operator 1
        #undef  CXXO_COMPILER_SUPPORT_foreach
................................................................................
        #undef  CXXO_COMPILER_SUPPORT_variadic
        #define CXXO_COMPILER_SUPPORT_variadic 1
    #else
        #undef  CXXO_COMPILER_SUPPORT_tr1_random
        #define CXXO_COMPILER_SUPPORT_tr1_random 1
        #undef  CXXO_COMPILER_SUPPORT_tr1_type_traits
        #define CXXO_COMPILER_SUPPORT_tr1_type_traits 1


    #endif
#endif

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







>
>







 







>
>
>
>











>
>







 







>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
..
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
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
        // Note: *Unsupported* c++0x emulation mode
        #define CXXOMFORT_CXX_EMULATION 2011
        #pragma message CXXO_WARNING( "Configuration not supported (nullptr and other basic features are missing)" )
        #undef  CXXO_COMPILER_SUPPORT_alignof
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #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_default_delete
        #define CXXO_COMPILER_SUPPORT_default_delete 1
        #undef  CXXO_COMPILER_SUPPORT_enum_class
        #define CXXO_COMPILER_SUPPORT_enum_class 1
        #undef  CXXO_COMPILER_SUPPORT_rvref
        #define CXXO_COMPILER_SUPPORT_rvref 1
        #undef  CXXO_COMPILER_SUPPORT_static_assert
................................................................................
        //#define CXXO_COMPILER_SUPPORT_std_iterator_helpers 1
        #define CXXO_COMPILER_SUPPORT_std_metaprogramming_helpers 1
        #undef  CXXO_COMPILER_SUPPORT_unique_ptr
        #define CXXO_COMPILER_SUPPORT_unique_ptr 1
        #undef  CXXO_COMPILER_SUPPORT_variadic
        #define CXXO_COMPILER_SUPPORT_variadic 1
    #else
        #undef  CXXO_COMPILER_SUPPORT_tr1_random
        #undef  CXXO_COMPILER_SUPPORT_tr1_tuple
        #define CXXO_COMPILER_SUPPORT_tr1_random 1
        #define CXXO_COMPILER_SUPPORT_tr1_tuple 1
        
    #endif
#endif
#if (CXXOMFORT_COMPILER_VERSION >= 406)
    #if defined(__GXX_EXPERIMENTAL_CXX0X__)
        #undef  CXXOMFORT_CXX_EMULATION
        #define CXXOMFORT_CXX_EMULATION 2011
        #undef  CXXO_COMPILER_SUPPORT_alignof
        #define CXXO_COMPILER_SUPPORT_alignof 1
        #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_default_delete
        #define CXXO_COMPILER_SUPPORT_default_delete 1
        #undef  CXXO_COMPILER_SUPPORT_enum_class
        #define CXXO_COMPILER_SUPPORT_enum_class 1
        #undef  CXXO_COMPILER_SUPPORT_explicit_operator
        #define CXXO_COMPILER_SUPPORT_explicit_operator 1
        #undef  CXXO_COMPILER_SUPPORT_foreach
................................................................................
        #undef  CXXO_COMPILER_SUPPORT_variadic
        #define CXXO_COMPILER_SUPPORT_variadic 1
    #else
        #undef  CXXO_COMPILER_SUPPORT_tr1_random
        #define CXXO_COMPILER_SUPPORT_tr1_random 1
        #undef  CXXO_COMPILER_SUPPORT_tr1_type_traits
        #define CXXO_COMPILER_SUPPORT_tr1_type_traits 1
        #undef  CXXO_COMPILER_SUPPORT_tr1_tuple
        #define CXXO_COMPILER_SUPPORT_tr1_tuple 1
    #endif
#endif

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

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

43
44
45
46
47
48
49


50
51
52
53
54
55
56
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#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


#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
................................................................................
    #define CXXO_COMPILER_SUPPORT_constexpr 1
    #undef  CXXO_COMPILER_SUPPORT_explicit_operator
    #define CXXO_COMPILER_SUPPORT_explicit_operator 1
    #undef  CXXO_COMPILER_SUPPORT_integer_sequence
    #define CXXO_COMPILER_SUPPORT_integer_sequence 1
    #undef  CXXO_COMPILER_SUPPORT_variadic
    #define CXXO_COMPILER_SUPPORT_variadic 1
    
    
    

#endif


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







>
>







 







<
<
<






43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
..
98
99
100
101
102
103
104



105
106
107
108
109
110
#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
................................................................................
    #define CXXO_COMPILER_SUPPORT_constexpr 1
    #undef  CXXO_COMPILER_SUPPORT_explicit_operator
    #define CXXO_COMPILER_SUPPORT_explicit_operator 1
    #undef  CXXO_COMPILER_SUPPORT_integer_sequence
    #define CXXO_COMPILER_SUPPORT_integer_sequence 1
    #undef  CXXO_COMPILER_SUPPORT_variadic
    #define CXXO_COMPILER_SUPPORT_variadic 1




#endif


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

Changes to cxxomfort/cxxomfort/functional.hpp.

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

// The bit_and and sibling functors from <functional> are missing in MSVC 2008
#if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC && CXXOMFORT_COMPILER_VERSION <= 150)
    #include "impl/03-functional_bit.hpp"
#endif

namespace cxxomfort {
//! @brief Components related to <functional>
namespace functional {
}
}


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

#endif







<
|









21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37

// The bit_and and sibling functors from <functional> are missing in MSVC 2008
#if (CXXOMFORT_COMPILER_ID == CXXO_VALUE_COMPILER_MSC && CXXOMFORT_COMPILER_VERSION <= 150)
    #include "impl/03-functional_bit.hpp"
#endif

namespace cxxomfort {

namespace cxxostd {
}
}


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

#endif

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

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
44
45
46
47
48
49
50

51
52
 */

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

namespace std {
namespace tr1 {

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

//! @ingroup cxx11-backports
template <typename II, II _w, II _s, II _r>
................................................................................
    : uniform_real<Real>(a,b) {}
};


} // namespace tr1
} // namespace std


#endif // fix
#endif







>







 







>


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
45
46
47
48
49
50
51
52
53
54
 */

#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>
................................................................................
    : uniform_real<Real>(a,b) {}
};


} // namespace tr1
} // namespace std

#endif // c++0x emulation
#endif // fix
#endif

Added cxxomfort/cxxomfort/impl/11-minmax.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
#ifndef CXXOMFORT_IMPL_MINMAX_HPP
#define CXXOMFORT_IMPL_MINMAX_HPP
/**
 * @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)
    ;
}

//! @overload minmax
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;

    if (less(*ini, *result.ini)) {
        result.second = result.ini;
        result.ini = ini;
    } else {
        result.second = ini;
    }
    while (++ini != fin) {
        FIterator i = ini;
        if (++ini == fin) {
            if (less(*i, *result.ini)) result.ini = i;
            else if (!(less(*i, *result.second))) result.second = i;
            break;
        } else {
            if (less(*ini, *i)) {
                if (less(*ini, *result.ini)) result.ini = ini;
                if (!(less(*i, *result.second))) result.second = i;
            } else {
                if (less(*i, *result.ini)) result.ini = i;
                if (!(less(*ini, *result.second))) result.second = ini;
            }
        }
    }
    return result;

}

//! @overload minmax_element
template <typename FIterator>
std::pair<FIterator,FIterator> 
minmax_element (FIterator ini, FIterator fin) {
    std::less <typename std::iterator_traits<FIterator>::value_type> less;
    return minmax_element(ini, fin, less);
}

/**
 * @}
 */

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

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

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
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

//
// MSVC 2010 implements incorrect to_string, with only three overloads
// https://stackoverflow.com/questions/10664699/stdto-string-more-than-instance-of-overloaded-function-matches-the-argument
//

namespace cxxomfort {
namespace string {

namespace detail_string {

template <typename T> struct printfmask {};

template <> struct printfmask<signed int> {
    static char const * /*const*/ mask () { return "%d"; };
................................................................................

    size_t* _p;
    const int _b;
    convertfn _pfn;
};


} //cxxomfort::string::detail_string


/**
 * @brief Returns a @c string expression of an integral.
 * @ingroup cxx11-backports
 */
static inline std::string to_string (unsigned short u) {
................................................................................
//    return strtoll (str.c_str(), pinv, base);
}

/**
 * @}
 */

} //~namespace string
} //~namespace cxxomfort


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

    //! using to_string (backport to c++03)
    //! @ref cxx03-backports
    using ::cxxomfort::string::to_string;

    using ::cxxomfort::string::stoul;
    using ::cxxomfort::string::stol;
    using ::cxxomfort::string::stoull;
    using ::cxxomfort::string::stoll;
}
#elif (CXXOMFORT_CXX_EMULATION>0)
namespace std {
    // GCC already brings those names
    #if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC)
    // MSC brings some of them
    #elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC)
        #if (CXXOMFORT_COMPILER_VERSION==160)
        // MSVC 2010 has failing overloads for to_string
            #if (CXXOMFORT_NOTICES > 2)
                #pragma message CXXO_NOTICE("adding missing overloads to to_string")
            #endif
        using ::cxxomfort::string::to_string;
    // MSVC 2010 already has stol, stoul, but lacks the long long versions
        #elif (CXXOMFORT_COMPILER_VERSION < 160)
        using ::cxxomfort::string::stol;
        using ::cxxomfort::string::stoul;
        using ::cxxomfort::string::to_string;
        #endif
    using ::cxxomfort::string::stoll;
    using ::cxxomfort::string::stoull;
    #endif
}
#endif // (c++11)

#endif

#endif







|







 







|







 







|









|

|
|
|
|












|


|
|
|

|
|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
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

//
// MSVC 2010 implements incorrect to_string, with only three overloads
// https://stackoverflow.com/questions/10664699/stdto-string-more-than-instance-of-overloaded-function-matches-the-argument
//

namespace cxxomfort {
namespace cxxostd {

namespace detail_string {

template <typename T> struct printfmask {};

template <> struct printfmask<signed int> {
    static char const * /*const*/ mask () { return "%d"; };
................................................................................

    size_t* _p;
    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 strtoll (str.c_str(), pinv, base);
}

/**
 * @}
 */

} //~namespace cxxostd
} //~namespace cxxomfort


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

    //! using to_string (backport to c++03)
    //! @ref cxx03-backports
    using ::cxxomfort::cxxostd::to_string;

    using ::cxxomfort::cxxostd::stoul;
    using ::cxxomfort::cxxostd::stol;
    using ::cxxomfort::cxxostd::stoull;
    using ::cxxomfort::cxxostd::stoll;
}
#elif (CXXOMFORT_CXX_EMULATION>0)
namespace std {
    // GCC already brings those names
    #if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC)
    // MSC brings some of them
    #elif (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC)
        #if (CXXOMFORT_COMPILER_VERSION==160)
        // MSVC 2010 has failing overloads for to_string
            #if (CXXOMFORT_NOTICES > 2)
                #pragma message CXXO_NOTICE("adding missing overloads to to_string")
            #endif
        using ::cxxomfort::cxxostd::to_string;
    // MSVC 2010 already has stol, stoul, but lacks the long long versions
        #elif (CXXOMFORT_COMPILER_VERSION < 160)
        using ::cxxomfort::cxxostd::stol;
        using ::cxxomfort::cxxostd::stoul;
        using ::cxxomfort::cxxostd::to_string;
        #endif
    using ::cxxomfort::cxxostd::stoll;
    using ::cxxomfort::cxxostd::stoull;
    #endif
}
#endif // (c++11)

#endif

#endif

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

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
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
#endif

#include <type_traits> // common_type
#include "../type_traits.hpp"
#include "../util/traits_ct.hpp"

namespace cxxomfort {
namespace functional {

/**
 * @ingroup cxx14-backports
 * @{
 */
template <typename T = void> struct less 
: std::less<T> {};
................................................................................
#undef LPP_SPEC_FUNCTIONAL_VOID


/**
 * @}
 */

} //cxxomfort::extras
} //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.
    template<> struct equal_to<void>  : ::cxxomfort::functional::equal_to<void> {}; ///< transparent specialization for @c std::equal_to
    //! Transparent @em not_equal_to functor.
    template<> struct not_equal_to<void>  : ::cxxomfort::functional::not_equal_to<void> {};
    //! Transparent @em less functor.
    template<> struct less<void>      : ::cxxomfort::functional::less<void> {};
    //! Transparent @em greater functor.
    template<> struct greater<void>   : ::cxxomfort::functional::greater<void> {};
    //! Transparent @em less_equal functor.
    template<> struct less_equal<void>    : ::cxxomfort::functional::less_equal<void> {};
    //! Transparent @em greater_equal functor.
    template<> struct greater_equal<void> : ::cxxomfort::functional::greater_equal<void> {};
    //! Transparent @em bit_or functor.
    template<> struct bit_or<void>    : ::cxxomfort::functional::bit_or<void> {};
    //! Transparent @em bit_and functor.
    template<> struct bit_and<void>   : ::cxxomfort::functional::bit_and<void> {};
    //! Transparent @em bit_xor functor.
    template<> struct bit_xor<void>   : ::cxxomfort::functional::bit_xor<void> {};

    //! Transparent @em plus functor.
    template<> struct plus<void>   : ::cxxomfort::functional::plus<void> {}; ///< transparent specialization for @c std::plus
    //! Transparent @em minus functor.
    template<> struct minus<void>   : ::cxxomfort::functional::minus<void> {};
    //! Transparent @em multiplies functor.
    template<> struct multiplies<void>   : ::cxxomfort::functional::multiplies<void> {};
    //! Transparent @em divides functor.
    template<> struct divides<void>   : ::cxxomfort::functional::divides<void> {};
    //! Transparent @em modulus functor.
    template<> struct modulus<void>   : ::cxxomfort::functional::modulus<void> {};

}
#endif // c++14
#endif // no std

#endif // CXXOMFORT_EXTRAS_14FUNCTORS_HPP







|







 







|












|

|

|

|

|

|

|

|

|


|

|

|

|

|






35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
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
#endif

#include <type_traits> // common_type
#include "../type_traits.hpp"
#include "../util/traits_ct.hpp"

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup cxx14-backports
 * @{
 */
template <typename T = void> struct less 
: std::less<T> {};
................................................................................
#undef LPP_SPEC_FUNCTIONAL_VOID


/**
 * @}
 */

} //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.
    template<> struct equal_to<void>  : ::cxxomfort::cxxostd::equal_to<void> {}; ///< transparent specialization for @c std::equal_to
    //! Transparent @em not_equal_to functor.
    template<> struct not_equal_to<void>  : ::cxxomfort::cxxostd::not_equal_to<void> {};
    //! Transparent @em less functor.
    template<> struct less<void>      : ::cxxomfort::cxxostd::less<void> {};
    //! Transparent @em greater functor.
    template<> struct greater<void>   : ::cxxomfort::cxxostd::greater<void> {};
    //! Transparent @em less_equal functor.
    template<> struct less_equal<void>    : ::cxxomfort::cxxostd::less_equal<void> {};
    //! Transparent @em greater_equal functor.
    template<> struct greater_equal<void> : ::cxxomfort::cxxostd::greater_equal<void> {};
    //! Transparent @em bit_or functor.
    template<> struct bit_or<void>    : ::cxxomfort::cxxostd::bit_or<void> {};
    //! Transparent @em bit_and functor.
    template<> struct bit_and<void>   : ::cxxomfort::cxxostd::bit_and<void> {};
    //! Transparent @em bit_xor functor.
    template<> struct bit_xor<void>   : ::cxxomfort::cxxostd::bit_xor<void> {};

    //! Transparent @em plus functor.
    template<> struct plus<void>   : ::cxxomfort::cxxostd::plus<void> {}; ///< transparent specialization for @c std::plus
    //! Transparent @em minus functor.
    template<> struct minus<void>   : ::cxxomfort::cxxostd::minus<void> {};
    //! Transparent @em multiplies functor.
    template<> struct multiplies<void>   : ::cxxomfort::cxxostd::multiplies<void> {};
    //! Transparent @em divides functor.
    template<> struct divides<void>   : ::cxxomfort::cxxostd::divides<void> {};
    //! Transparent @em modulus functor.
    template<> struct modulus<void>   : ::cxxomfort::cxxostd::modulus<void> {};

}
#endif // c++14
#endif // no std

#endif // CXXOMFORT_EXTRAS_14FUNCTORS_HPP

Added 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



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

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// -----

#if (defined(CXXOMFORT_USING_stdbyte))

#include "../library/typesafe_enum.hpp"

namespace cxxomfort {
namespace cstddef {

namespace detail { // detail

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

}

/**
 * @brief "byte" type for C++17.
 * @ingroup cxx17-backports
................................................................................
 */
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( from_underlying<detail::byteimpl>(c) ) {}

    //using byteimpl::byteimpl;
    using detail::byteimpl::underlying;
    //using detail::byteimpl::operator=;
    using detail::byteimpl::equals;

    byte& operator= (byte const& b) CXXO_NOEXCEPT {
................................................................................
}
// cxxomfort
}

#if (!defined(CXXOMFORT_NO_STD_USING))
namespace std {
    //! @ref cxx17-backports
    using cxxomfort::cstddef::byte;
    using cxxomfort::cstddef::to_byte;
    using cxxomfort::cstddef::to_integer;
}
#endif

#endif // stdbyte

#if (defined(DOXYGEN_DOC))
namespace std {
    //! byte object representation
    struct byte {};
}
#endif

#endif







|




|







 







|







 







|
|
|













29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// -----

#if (defined(CXXOMFORT_USING_stdbyte))

#include "../library/typesafe_enum.hpp"

namespace cxxomfort {
namespace cxxostd {

namespace detail { // detail

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

}

/**
 * @brief "byte" type for C++17.
 * @ingroup cxx17-backports
................................................................................
 */
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) ) {}

    //using byteimpl::byteimpl;
    using detail::byteimpl::underlying;
    //using detail::byteimpl::operator=;
    using detail::byteimpl::equals;

    byte& operator= (byte const& b) CXXO_NOEXCEPT {
................................................................................
}
// 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

#endif // stdbyte

#if (defined(DOXYGEN_DOC))
namespace std {
    //! byte object representation
    struct byte {};
}
#endif

#endif

Deleted cxxomfort/cxxomfort/impl/17-endian.hpp.

Added 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

Added cxxomfort/cxxomfort/impl/20-endian.hpp.

















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#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 { 
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_MSC || defined(_WIN32))
    little = 0,
    big = 1,
    native = little
#else
    little = __ORDER_LITTLE_ENDIAN__,
    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

Added cxxomfort/cxxomfort/impl/20-type_identity.hpp.















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef CXXOMFORT_IMPL_20_IDENTITY_FINALLY_HPP
#define CXXOMFORT_IMPL_20_IDENTITY_FINALLY_HPP

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

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

namespace cxxomfort {
namespace 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

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

11
12
13
14
15
16
17

18
19
20
21
22
23
24
...
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
//#include <functional>
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/meta.hpp>
#include <valarray>

namespace cxxomfort {

namespace detail {

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

struct auto_any_base {
    operator bool() const { return false; }
................................................................................
    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
// "assignment within conditional" warnings
#define CXXO_FOREACH(item, container)                  \
__pragma(warning(suppress:4706)) __pragma(warning(suppress:6001)) \
if(::cxxomfort::detail::auto_any_base const& bX = ::cxxomfort::detail::begin(container)) {} else   \
if(::cxxomfort::detail::auto_any_base const& eX = ::cxxomfort::detail::end(container)) {} else     \
for(bool more = true;                                   \
    more && !::cxxomfort::detail::done(bX,eX,ENCODED_TYPEOF(container));                       \
    more ? ::cxxomfort::detail::next(bX,ENCODED_TYPEOF(container)) : (void)0)                 \
    __pragma(warning(suppress:4706))                       \
    if ((more = false)!=0) {} else                           \
    for(item = ::cxxomfort::detail::deref(bX,ENCODED_TYPEOF(container)); !more; more = true)

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

#endif // foreach macro definition

#undef Suppress_








>







 







<



<







|
|

|
|


|




|
|

|
|

|





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

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

struct auto_any_base {
    operator bool() const { return false; }
................................................................................
    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
// "assignment within conditional" warnings
#define CXXO_FOREACH(item, container)                  \
__pragma(warning(suppress:4706)) __pragma(warning(suppress:6001)) \
if(::cxxomfort::library::detail::auto_any_base const& bX = ::cxxomfort::library::detail::begin(container)) {} else   \
if(::cxxomfort::library::detail::auto_any_base const& eX = ::cxxomfort::library::detail::end(container)) {} else     \
for(bool more = true;                                   \
    more && !::cxxomfort::library::detail::done(bX,eX,ENCODED_TYPEOF(container));                       \
    more ? ::cxxomfort::library::detail::next(bX,ENCODED_TYPEOF(container)) : (void)0)                 \
    __pragma(warning(suppress:4706))                       \
    if ((more = false)!=0) {} else                           \
    for(item = ::cxxomfort::library::detail::deref(bX,ENCODED_TYPEOF(container)); !more; more = true)

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

#endif // foreach macro definition

#undef Suppress_

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

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/util/meta.hpp>
//#include <cxxomfort/memory.hpp> // alignof, aligned_storage

namespace cxxomfort {
namespace extras {

struct seq2iter_base {
    operator bool () const { return false; }
};

template <typename T, bool B=false>
struct seq2iter_impl {
................................................................................
    : _i(i) {}
    
};

// for compilers that support __typeof__

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


}
}








|







 







|
|









12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp> // global begin, end
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/util/meta.hpp>
//#include <cxxomfort/memory.hpp> // alignof, aligned_storage

namespace cxxomfort {
namespace library {

struct seq2iter_base {
    operator bool () const { return false; }
};

template <typename T, bool B=false>
struct seq2iter_impl {
................................................................................
    : _i(i) {}
    
};

// for compilers that support __typeof__

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


}
}

Changes to cxxomfort/cxxomfort/impl/to_basic_string_cxx03.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
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
345
346
347
348
349
350
351
352
353
354
#ifndef CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP
#define CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP


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

namespace cxxomfort {
namespace string {

namespace detail_string {

const struct no_t {
    template <typename Ch, typename Tr, typename Alloc>
    friend std::basic_ostringstream<Ch,Tr,Alloc>& 
    operator<< (std::basic_ostringstream<Ch,Tr,Alloc>& os, no_t const& n) {
        (void)n;
        return os;
}

} noitem = {};


template <
typename Stream
>
struct streamizer {
    streamizer (Stream& s)
    : stream(s) 
    {
        using namespace std;
        stream.exceptions(ios_base::failbit | ios_base::badbit);
    }
................................................................................
    }

    Stream& stream;
    
};


} // cxxomfort::string::detail_string


template <typename Ch, typename Tr, typename Alloc
, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9
>
std::basic_string<Ch,Tr,Alloc> 
to_basic_string
................................................................................
template <typename T0, typename T1>
std::string  to_string
(T0 const& t0, T1 const& t1) {
    return to_basic_string_defaults<char>(t0,t1);
}

} // string
} // cxxomfort

#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
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
344
345
346
347
348
349
350
351
352
353
#ifndef CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP
#define CXXOMFORT_IMPL_TO_BASIC_STRING_03_HPP


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

namespace cxxomfort { namespace library {
namespace string {

namespace detail_string {

const struct no_t {
    template <typename Ch, typename Tr, typename Alloc>
    friend std::basic_ostringstream<Ch,Tr,Alloc>& 
    operator<< (std::basic_ostringstream<Ch,Tr,Alloc>& os, no_t const& n) {
        (void)n;
        return os;
}

} noitem = {};



template <typename Stream>

struct streamizer {
    streamizer (Stream& s)
    : stream(s) 
    {
        using namespace std;
        stream.exceptions(ios_base::failbit | ios_base::badbit);
    }
................................................................................
    }

    Stream& stream;
    
};


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


template <typename Ch, typename Tr, typename Alloc
, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9
>
std::basic_string<Ch,Tr,Alloc> 
to_basic_string
................................................................................
template <typename T0, typename T1>
std::string  to_string
(T0 const& t0, T1 const& t1) {
    return to_basic_string_defaults<char>(t0,t1);
}

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

#endif

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

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

#if (CXXOMFORT_CXX_STD >= 2011)

namespace cxxomfort {
namespace string {

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

} // cxxomfort::string
} // cxxomfort

#else
#include "to_basic_string_cxx03.hpp"
#endif

#if defined(DOXYGEN_DOC)








|







 







|







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

#if (CXXOMFORT_CXX_STD >= 2011)

namespace cxxomfort { namespace library {
namespace string {

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

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

#else
#include "to_basic_string_cxx03.hpp"
#endif

#if defined(DOXYGEN_DOC)

Changes to cxxomfort/cxxomfort/library/functionalfn.hpp.

4
5
6
7
8
9
10



11

12
13
14
15
16
17
18
19
20
#include <cxxomfort/base.hpp>
#include <functional>
#include <iterator>

#include "operatorit.hpp" // supplement operator functors

namespace cxxomfort {



//! Namespace for the objects in @ref cxxo:sup:functional .

namespace functional {


} // .functional:
}

/**
 * @page cxxo:sup:functional "Supplements to <functional>"
 * @brief Offers cxxomfort-specific supplements to <code><functional></code> features.







>
>
>
|
>

<







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

17
18
19
20
21
22
23
#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.

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

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE ("enabled container initialization helper")
    #endif

#include <iterator>
#include <valarray>

namespace cxxomfort {
namespace i12n_detail {

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

};

}
}



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







|







 







|
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    #if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE ("enabled container initialization helper")
    #endif

#include <iterator>
#include <valarray>

namespace cxxomfort { namespace library {
namespace i12n_detail {

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

};

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

Changes to cxxomfort/cxxomfort/library/operatorit.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
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
 * * comma_it.
 * * 
 *
 */

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


namespace cxxomfort {

/**
 * @namespace 
 * @brief Supplements to functionality in <code><functional></code>.
 * @ingroup cxxo:sup:functional
 */
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;
    typedef T result_type;
    T& operator() (T& t) const { ++t; return t; }
};

//! Heterogeneous (deduced) wrapper for @ref preincrement .
template<> struct preincrement<void> {
    template <typename T>
    T& operator() (T& t) const { ++t; return t; }
};

/**
 * @brief Functoid that wraps <code>--t</code> for a given @a T .
 */
template <typename T>
struct predecrement
:std::unary_function<T,T> {
    typedef T argument_type;
    typedef T result_type;
    T& operator() (T& t) const { --t; return t; }
};

//! Heterogeneous (deduced) wrapper version of predecrement.
template<> struct predecrement<void> {
    template <typename T>
    T& operator() (T& t) { --t; return t; }

};


#define CXXO_DEF_OPERATORIT(Name,Sym) \
template <typename It, typename Ot=It> \
struct Name : plus<int> {              \
    typedef It result_type;            \
    inline It& operator() (It& l, Ot const& r) const {   \
        return l Sym r;       \
    }                         \
};                            \



CXXO_DEF_OPERATORIT(plus_it,+=);

CXXO_DEF_OPERATORIT(minus_it,-=);

CXXO_DEF_OPERATORIT(multiplies_it,*=);

CXXO_DEF_OPERATORIT(divides_it,/=);

CXXO_DEF_OPERATORIT(modulus_it,%=);




CXXO_DEF_OPERATORIT(leftshift_it,<<=);
CXXO_DEF_OPERATORIT(rightshift_it,>>=);

#undef CXXO_DEF_OPERATORIT















/**
 * @}
 */

} // functional
} // cxxomfort

#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

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
 * * 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;
    typedef T result_type;
    T& operator() (T& t) const { return ++t; }
};

//! Heterogeneous (deduced) wrapper for @ref preincrement .
template<> struct preincrement<void> {
    template <typename T>
    T& operator() (T& t) const { return ++t; }
};

/**
 * @brief Functoid that wraps <code>--t</code> for a given @a T .
 */
template <typename T>
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; }

};


#define CXXO_DEF_OPERATORIT(Name,Sym) \
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&> {   
    inline It& operator() (It& l, Ot const& r) const { 
        return l<<=r;
    }
};

template <typename It, typename Ot=It> 
struct rightshift_it : ::std::binary_function<It&,Ot const&,It&> {   
    inline It& operator() (It& l, Ot const& r) const { 
        return l>>=r;
    }
};


/**
 * @}
 */

} // functional
} // cxxomfort

#endif

Changes to cxxomfort/cxxomfort/library/stringfn.hpp.

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
/**
 * @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::string::to_string("cxxomfort::string::chr: ascii(", static_cast<uint16_t>(ascii), ") out of range")
    );
    char q[]= "0";
    q[0]= ascii;
    return q;
}


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

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

static std::string utf8chr (unsigned long 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;







|










|




|

|




|







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
/**
 * @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")
    );
    char q[]= "0";
    q[0]= ascii;
    return q;
}


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

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

static inline std::string utf8chr (uint32_t cp) {
	using namespace std;
	char chu[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
	if (false) {
	} else if (cp <= 0x7f) {
		chu[0] = cp;
	} else if (cp <= 0x07ff)  {
        chu[0]= (cp>>6)+192;

Changes to cxxomfort/cxxomfort/library/type_name.hpp.

16
17
18
19
20
21
22

23
24
25
26
27
28
29
..
62
63
64
65
66
67
68
69
70



71


72
#include "../using.hpp"
#include <string>
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC || CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG)
    #include <cxxabi.h>
#endif

namespace cxxomfort {

namespace detail_demangle {

// Thanks much to ′灵魂L.眼神 for making me notice this had to be made static!
static std::string job (const char* name) {
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC || \
     CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG)
    char buf[1024];
................................................................................
    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;
}

} //cxxomfort::







#endif







>







 







|

>
>
>

>
>

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "../using.hpp"
#include <string>
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC || CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG)
    #include <cxxabi.h>
#endif

namespace cxxomfort {
namespace library {
namespace detail_demangle {

// Thanks much to ′灵魂L.眼神 for making me notice this had to be made static!
static std::string job (const char* name) {
#if (CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_GCC || \
     CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG)
    char buf[1024];
................................................................................
    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

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

6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
38
39
40
41
42
43
44

45


46
47
48
49
50
51
52
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
180
181
182
183
184
185
186

187
188
189
190
191
192
193
 @see http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 @see http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using/11856721#11856721
**/
#include <cxxomfort/base.hpp>
#include <type_traits>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp>


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

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

#endif

/* Section: declaration of safe_enum */

namespace cxxomfort {

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


template<typename def, typename inner = typename def::type>
................................................................................
    public: 
    typedef typename def::type enum_type;
    typedef inner underlying_type;
 
    public:
    CXXO_CONSTEXPR typesafe_enum () CXXO_NOEXCEPT {}
    CXXO_CONSTEXPR typesafe_enum (typename def::type v) : val(v) {}

    CXXO_CONSTEXPR explicit typesafe_enum (underlying_type v) : val(v) {}


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

    /*{
        enum { T_is_compatible_type = std::is_same<T, enum_type>::value };
................................................................................
#else

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



} // cxxomfort::


/* End section: safe_enum */

/* Begin section: is_scoped_enum */

namespace cxxomfort {

template <bool isenum, typename T>
struct is_typesafeenum_helper;

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

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

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


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

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

#endif


} // cxxomfort::

/* End section: safe_enum */

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







>







|
|






|







 







>
|
>
>







 







|







|







 







|







 







>







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
..
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
...
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
 @see http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum
 @see http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using/11856721#11856721
**/
#include <cxxomfort/base.hpp>
#include <type_traits>
#include <cxxomfort/util/type_traits.hpp>
#include <cxxomfort/impl/11-conditional.hpp>
#include <cxxomfort/using.hpp>

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

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

#endif

/* Section: declaration of safe_enum */

namespace cxxomfort { namespace library {

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


template<typename def, typename inner = typename def::type>
................................................................................
    public: 
    typedef typename def::type enum_type;
    typedef inner underlying_type;
 
    public:
    CXXO_CONSTEXPR typesafe_enum () CXXO_NOEXCEPT {}
    CXXO_CONSTEXPR typesafe_enum (typename def::type v) : val(v) {}
    template <typename Q>
    CXXO_CONSTEXPR explicit typesafe_enum (Q v
    , typename std::enable_if< false==std::is_same<Q,underlying_type>::value, Q>::type* = nullptr) 
    : val(v) {}
    CXXO_CONSTEXPR enum_type value() const CXXO_NOEXCEPT { return val; }
    CXXO_CONSTEXPR underlying_type underlying() const CXXO_NOEXCEPT { return val; }
    
    CXXO_EXPLICIT_OPERATOR(underlying_type) () const CXXO_NOEXCEPT { return val; }

    /*{
        enum { T_is_compatible_type = std::is_same<T, enum_type>::value };
................................................................................
#else

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


} // library
} // cxxomfort::


/* End section: safe_enum */

/* Begin section: is_scoped_enum */

namespace cxxomfort { namespace library {

template <bool isenum, typename T>
struct is_typesafeenum_helper;

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

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

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


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

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

#endif

} // library
} // cxxomfort::

/* End section: safe_enum */

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

Changes to cxxomfort/cxxomfort/string.hpp.

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


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

namespace cxxomfort {
/**
 * @namespace
 * @brief Namespace for <string>-related utilities in cxxomfort.
 */
namespace string {
}
}

#include "impl/11-to_string.hpp"
//#include "impl/14-string_literal.hpp"

/**
 * @{
 */

/**
 * @}
 */

#endif







<
|
<
<
<






<
<
<
<
<
<
<
<

12
13
14
15
16
17
18

19



20
21
22
23
24
25








26


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

namespace cxxomfort {

namespace cxxostd {



}
}

#include "impl/11-to_string.hpp"
//#include "impl/14-string_literal.hpp"









#endif

Changes to cxxomfort/cxxomfort/type_traits.hpp.

360
361
362
363
364
365
366





367
368
369
370
371
372
373

/*
 * make_void (c++17)
 */
#include "impl/17-void_t.hpp"







/*
 * is_move_constructible for C++03, we seek for RV_REF constructors
 */

#if (CXXOMFORT_CXX_STD < 2011) \
|| /* also missing in clang in C++11 mode */ \
(CXXOMFORT_CXX_STD==2011 && CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG && CXXOMFORT_COMPILER_VERSION<=304)  \







>
>
>
>
>







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

/*
 * make_void (c++17)
 */
#include "impl/17-void_t.hpp"


/*
 * bool_constant (c++17)
 */
#include "impl/17-bool_constant.hpp"

/*
 * is_move_constructible for C++03, we seek for RV_REF constructors
 */

#if (CXXOMFORT_CXX_STD < 2011) \
|| /* also missing in clang in C++11 mode */ \
(CXXOMFORT_CXX_STD==2011 && CXXOMFORT_COMPILER_ID==CXXO_VALUE_COMPILER_CLANG && CXXOMFORT_COMPILER_VERSION<=304)  \

Changes to cxxomfort/cxxomfort/utility.hpp.

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

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


namespace cxxomfort {
/**
 * @namespace
 * @brief Namespace for the <utility>-related backports and features in cxxomfort.
 */
namespace utility {
    //! Unevaluated context.
    //! @ingroup utility
    //! @ingroup cxx11-backports
    template <typename T> typename cxxomfort::traits::add_reference<T>::type declval();
}
}

................................................................................
            #define CXXO_ADD_declval
        #endif
    #else
        #define CXXO_ADD_declval
    #endif
    #if defined(CXXO_ADD_declval)
namespace std { 
    using ::cxxomfort::utility::declval;
} //std::
        #undef CXXO_ADD_declval
    #endif

#endif
#define CXXOMFORT_IMPLEMENTS_n1978 CXXO_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n2343 CXXO_BACKPORT()







<
|
<
<
<







 







|







28
29
30
31
32
33
34

35



36
37
38
39
40
41
42
..
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

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

................................................................................
            #define CXXO_ADD_declval
        #endif
    #else
        #define CXXO_ADD_declval
    #endif
    #if defined(CXXO_ADD_declval)
namespace std { 
    using ::cxxomfort::cxxostd::declval;
} //std::
        #undef CXXO_ADD_declval
    #endif

#endif
#define CXXOMFORT_IMPLEMENTS_n1978 CXXO_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_n2343 CXXO_BACKPORT()

Changes to cxxomfort/tags/cxxomfort.cpp.tags.

32
33
34
35
36
37
38

39
40
41
42
43


44





45
46
47
48
49
50
CXXO_TYPEOF|type?|(expression)|
make_array_ref|array_ref<T>|(T[N])|
make_array_ref|array_ref<T>|(array / dynarray / valarray / vector)|
seq_|"sequence type"|<T>(...sequence of T)|
typeid_demangle|std::string|(typeid construct)|
type_name|std::string|<T>() [parametrized on T]|
#algorithm

find_last_if|Iterator|(Iterator ini, Iterator fin, Predicate f)|
transform_inplace|Iterator|(Iterator ini, Iterator fin, Function f)|
transform_inplace_if|Iterator|(Iterator ini, Iterator fin, Function f, Predicate p)|
transform_n|Iterator|(Iterator ini, Integer n, DestIterator out, Function f)|
#functional


#string





to_string|std::string|(expressions..., )|
to_wstring|std::wstring|(expressions..., )|
#tuple
tuple_shift|tuple<A_2,...,A_(n)>|(tuple<A_1,A_2,...,A_(n)>)|
tuple_pop|tuple<A_1,A_2,...,A_(n-1)>|(tuple<A_1,A_2,...,A_(n-1),A_(n)>)|
#utility







>





>
>

>
>
>
>
>



|
|

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
CXXO_TYPEOF|type?|(expression)|
make_array_ref|array_ref<T>|(T[N])|
make_array_ref|array_ref<T>|(array / dynarray / valarray / vector)|
seq_|"sequence type"|<T>(...sequence of T)|
typeid_demangle|std::string|(typeid construct)|
type_name|std::string|<T>() [parametrized on T]|
#algorithm
count_frequencies_map|Iterator|(Iterator ini, Iterator fin, ValueMapIndex[]& v)|
find_last_if|Iterator|(Iterator ini, Iterator fin, Predicate f)|
transform_inplace|Iterator|(Iterator ini, Iterator fin, Function f)|
transform_inplace_if|Iterator|(Iterator ini, Iterator fin, Function f, Predicate p)|
transform_n|Iterator|(Iterator ini, Integer n, DestIterator out, Function f)|
#functional
#numeric
#random
#string
chr|std::string|(uint16_t ord)|
wchr|std::wstring|(uint32_t ord)|
utf8chr|std::string|(uint32_t ord)|
join|String|(String const& sep, Iterator1 ini, Iterator2 fin)|
split_to|Iterator|(String const& sep, String const& src, Iterator ini)|
to_string|std::string|(expressions..., )|
to_wstring|std::wstring|(expressions..., )|
#tuple
tuple_shift|tuple<A_{2...n}>|(tuple<A_{1...n}>)|
tuple_pop|tuple<A_{1...n-1}>|(tuple<A_{1...n}>)|
#utility