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

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

Changes to cxxomfort/cxxomfort/VERSION.txt.

1
cxxomfort 0.80 2018-11-11
|
1
cxxomfort 0.81 2018-11-25

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

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
...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

209
210
211
212
213
214
215
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
typename C::const_iterator
begin (C const& c) {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.begin();
}

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

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

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

//! Returns the "end" iterator for a container-like object.
//! @ref cxx11-backports
template <typename C> inline
typename C::iterator
end (C & c) {
    static_assert(sizeof(typename C::iterator), "");
    static_assert(sizeof(typename C::value_type), "");
................................................................................
end (C const& c) {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    using namespace std;
    return c.end();
}

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

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

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

//! @ref cxx14-backports
template <typename C>
typename C::reverse_iterator inline
rbegin (C & c) {
    static_assert(sizeof(typename C::reverse_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.rbegin();
}

//! @ref cxx14-backports
template <typename C>
typename C::reverse_iterator inline
rend (C & c) {
    static_assert(sizeof(typename C::reverse_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.rend();
}

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

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



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


namespace std {

#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_std_iterator_helpers == 0)
    using ::cxxomfort::iterator::begin;
    using ::cxxomfort::iterator::end;
    using ::cxxomfort::iterator::cbegin;
    using ::cxxomfort::iterator::cend;
    using ::cxxomfort::iterator::rbegin;
    using ::cxxomfort::iterator::rend;
// GCC 4.4 already has next, prev in c++0x mode
    #if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC && CXXOMFORT_CXX_EMULATION == 2011)
    #else
    using ::cxxomfort::iterator::next;
    using ::cxxomfort::iterator::prev;
    #endif

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

#endif







<
<
<
<
<
<
<
<
<
<
<




<
<
<
<







 







<
<
<
<
<
<
<
<
<




|
<
<

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







 







<
<
<
<








|
<




121
122
123
124
125
126
127











128
129
130
131




132
133
134
135
136
137
138
...
145
146
147
148
149
150
151









152
153
154
155
156


157

























158
159
160
161
162
163
164
165
...
238
239
240
241
242
243
244




245
246
247
248
249
250
251
252
253

254
255
256
257
typename C::const_iterator
begin (C const& c) {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.begin();
}












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





//! Returns the "end" iterator for a container-like object.
//! @ref cxx11-backports
template <typename C> inline
typename C::iterator
end (C & c) {
    static_assert(sizeof(typename C::iterator), "");
    static_assert(sizeof(typename C::value_type), "");
................................................................................
end (C const& c) {
    static_assert(sizeof(typename C::const_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    using namespace std;
    return c.end();
}










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

// cbegin, cend moved to impl/14-iterator-access.hpp




























// rbegin, rend moved to impl/14-iterator-access.hpp


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


namespace std {

#if (CXXOMFORT_CXX_STD < 2011 && CXXO_COMPILER_SUPPORT_std_iterator_helpers == 0)
    using ::cxxomfort::iterator::begin;
    using ::cxxomfort::iterator::end;




// GCC 4.4 already has next, prev in c++0x mode
    #if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC && CXXOMFORT_CXX_EMULATION == 2011)
    #else
    using ::cxxomfort::iterator::next;
    using ::cxxomfort::iterator::prev;
    #endif

#else


#endif
}

#endif

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

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

//
//                            move()
//

template <class T>
inline typename
std::enable_if<!has_move_emulation_enabled_aux<T>::value, T&>::type move(T& x) {

  return x;
}

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

  return *static_cast<rv<T>* >(move_detail::addressof(x));
}

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

  return x;
}

//
//                            forward()
//

template <typename T> inline 
typename std::enable_if<
    enable_move_utility_emulation<T>::value && is_rv<T>::value, T &

>::type forward (const typename ::cxxomfort::identity<T>::type &x) noexcept {
    return const_cast<T&>(x);
}

template <typename T> inline
typename std::enable_if<
    enable_move_utility_emulation<T>::value && !is_rv<T>::value, T const&

>::type forward (const typename ::cxxomfort::identity<T>::type &x) noexcept {
    return x;
}

#undef noexcept

} //::cxxomfort::








|
>





|
>





|
>










>
|






>
|







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

//
//                            move()
//

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

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

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

//
//                            forward()
//

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

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

#undef noexcept

} //::cxxomfort::

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

45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
      return *this;
    }
};
*/

#include <cxxomfort/config.hpp> // c++11
#define CXXOMFORT_IMPLEMENTS_n1377 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_move_emulation CXXOMFORT_IMPLEMENTS_n1377
#define CXXOMFORT_IMPLEMENTS_n2118 CXXO_IMPLSTATUS_EMULATION()




#if ((CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_rvref==0))
    #define CXXOMFORT_USING_MOVE_EMULATION 1
#endif








<

>







45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
60
      return *this;
    }
};
*/

#include <cxxomfort/config.hpp> // c++11
#define CXXOMFORT_IMPLEMENTS_n1377 CXXO_IMPLSTATUS_EMULATION()

#define CXXOMFORT_IMPLEMENTS_n2118 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_move_emulation CXXOMFORT_IMPLEMENTS_n1377



#if ((CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_rvref==0))
    #define CXXOMFORT_USING_MOVE_EMULATION 1
#endif

Changes to cxxomfort/cxxomfort/config.hpp.

145
146
147
148
149
150
151

152
153
154
155

156




157
158
159
160

161
162
163
164
165
166
167
//
// Macros that conditionally generate code for C++11, C++14
//

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


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







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


#endif

//
// Set the local arch name from a series of recognized values
//
#define CXXO_VALUE_ARCH_arm      9000







>




>

>
>
>
>

|
|

>







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
//
// Macros that conditionally generate code for C++11, C++14
//

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

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

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

#elif (CXXOMFORT_CXX_STD >= 2017)
    #define CXXOMFORT_CXX11_CODE(cxx11,none) cxx11
    #define CXXOMFORT_CXX14_CODE(cxx14,none) cxx14
    #define CXXOMFORT_CXX17_CODE(cxx17,none) cxx17

#endif

//
// Set the local arch name from a series of recognized values
//
#define CXXO_VALUE_ARCH_arm      9000

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

40
41
42
43
44
45
46


47
48
49
50
51
52
53
#define CXXO_COMPILER_SUPPORT_constexpr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cinttypes> header
#define CXXO_COMPILER_SUPPORT_cstd_cinttypes (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cstdint> header
#define CXXO_COMPILER_SUPPORT_cstd_cstdint (CXXOMFORT_CXX_STD>=2011)
//! If compiler brings <system_error> header.
#define CXXO_COMPILER_SUPPORT_cstd_system_error (CXXOMFORT_CXX_STD>=2011)


//! If compiler 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.







>
>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#define CXXO_COMPILER_SUPPORT_constexpr (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cinttypes> header
#define CXXO_COMPILER_SUPPORT_cstd_cinttypes (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides a <cstdint> header
#define CXXO_COMPILER_SUPPORT_cstd_cstdint (CXXOMFORT_CXX_STD>=2011)
//! If compiler brings <system_error> header.
#define CXXO_COMPILER_SUPPORT_cstd_system_error (CXXOMFORT_CXX_STD>=2011)
//! If compiler brings <typeindex> header.
#define CXXO_COMPILER_SUPPORT_cstd_typeindex (CXXOMFORT_CXX_STD>=2011)
//! If compiler supports @c decltype(expr) .
#define CXXO_COMPILER_SUPPORT_decltype (CXXOMFORT_CXX_STD>=2011)
//! If compiler provides support for <code>=default</code>-ed and <code>=delete</code>-d members.
#define CXXO_COMPILER_SUPPORT_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.

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

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


|

|

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

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

41
42
43
44
45
46
47

48
49
50

51
52
53
54
55
56
57
..
64
65
66
67
68
69
70
71
72


73
74
75
76
77
78
79
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//#define CXXO_PRAGMA(x) _Pragma (#x)
//#define CXXO_NOTICE(msg) CXXO_PRAGMA( message (" cxxomfort warning -- " msg ) )

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

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

    #define CXXO_WARNING(msg) CXXO_NOTICE_IMPL_( "cxxomfort warning: " msg)
#endif

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

................................................................................
// GCC advertises C++11 mode with "-std=c++0x" and a macro
#if (CXXOMFORT_CXX_STD <= 2011 && defined(__GXX_EXPERIMENTAL_CXX0X__))
    #undef  CXXOMFORT_CXX_EMULATION
    #define CXXOMFORT_CXX_EMULATION 2011
#endif


// here we take advantage that the compiler include path contains two
// subdirectories: bits/ and tr1/


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


#undef  CXXO_COMPILER_SUPPORT_typeof
................................................................................
    #endif
#endif

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

// GCC 4.8 onwards set up support for C++14 (--std=c++1y or --std=c++14)
// via usage of the __cplusplus value







>



>







 







|
|
>
>







 







<
<







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
...
190
191
192
193
194
195
196


197
198
199
200
201
202
203
//#define CXXO_PRAGMA(x) _Pragma (#x)
//#define CXXO_NOTICE(msg) CXXO_PRAGMA( message (" cxxomfort warning -- " msg ) )

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

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

................................................................................
// GCC advertises C++11 mode with "-std=c++0x" and a macro
#if (CXXOMFORT_CXX_STD <= 2011 && defined(__GXX_EXPERIMENTAL_CXX0X__))
    #undef  CXXOMFORT_CXX_EMULATION
    #define CXXOMFORT_CXX_EMULATION 2011
#endif


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


#undef  CXXO_COMPILER_SUPPORT_typeof
................................................................................
    #endif
#endif

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


        #undef  CXXO_COMPILER_SUPPORT_user_defined_literals
        #define CXXO_COMPILER_SUPPORT_user_defined_literals 1
    #endif
#endif

// GCC 4.8 onwards set up support for C++14 (--std=c++1y or --std=c++14)
// via usage of the __cplusplus value

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

38
39
40
41
42
43
44
45



46
47
48
49
50
51
52
53
54
#define CXXOMFORT_CXX_STD (__cplusplus/100)

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

// MSVC at least contains a folder named 'include' in VC.



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


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







|
>
>
>

<







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

50
51
52
53
54
55
56
#define CXXOMFORT_CXX_STD (__cplusplus/100)

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

/**
 * MSVC headers tend to be organized via a 
 * path like ${VISUAL_STUDIO}/VC/include
 */
#define CXXO_INCLUDE_SYS(NAME) <../../VC/include/NAME>

#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_WARNING("Using Windows+MSC include paths")
#endif


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

Changes to cxxomfort/cxxomfort/cstd/algorithm.

1
2
3
4
5
6

7

8



9
10
#ifndef CXXOMFORT_STD_ALGORITHM
#define CXXOMFORT_STD_ALGORITHM

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */

#include "../impl/_headers.hpp"

#include_next <algorithm>



#include "../algorithm.hpp"
#endif






>

>
|
>
>
>


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

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <algorithm>
#else
    #include CXXO_INCLUDE_SYS(algorithm)
#endif
#include "../algorithm.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstd/cstddef.

1
2
3
4
5

6

7



8
9
#ifndef CXXOMFORT_STD_CSTDDEF
#define CXXOMFORT_STD_CSTDDEF
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */

#include "../impl/_headers.hpp"

#include_next <cstddef>



#include "../cstddef.hpp"
#endif





>

>
|
>
>
>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef CXXOMFORT_STD_CSTDDEF
#define CXXOMFORT_STD_CSTDDEF
/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <cstddef>
#else
    #include CXXO_INCLUDE_SYS(cstddef)
#endif
#include "../cstddef.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstd/memory.

1
2
3
4
5
6
7

8

9



10
11
#ifndef CXXOMFORT_STD_MEMORY
#define CXXOMFORT_STD_MEMORY

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */


#include "../impl/_headers.hpp"

#include_next <memory>



#include "../memory.hpp"
#endif







>

>
|
>
>
>


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

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */

#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <memory>
#else
    #include CXXO_INCLUDE_SYS(memory)
#endif
#include "../memory.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstd/string.

1
2
3
4
5
6

7

8



9
10
#ifndef CXXOMFORT_STD_STRING
#define CXXOMFORT_STD_STRING

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */

#include "../impl/_headers.hpp"

#include_next <string>



#include "../string.hpp"
#endif






>

>
|
>
>
>


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

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <string>
#else
    #include CXXO_INCLUDE_SYS(string)
#endif
#include "../string.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstd/system_error.

1
2
3
4
5
6
7
8

9
10
11
12
13
14
#ifndef CXXOMFORT_STD_SYSTEM_ERROR
#define CXXOMFORT_STD_SYSTEM_ERROR

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include_next <system_error>
#include "../config.hpp"

#if (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
#include CXXO_INCLUDE_SYS(system_error)
#endif
#include "../system_error.hpp"
#endif







<

>

|




1
2
3
4
5
6

7
8
9
10
11
12
13
14
#ifndef CXXOMFORT_STD_SYSTEM_ERROR
#define CXXOMFORT_STD_SYSTEM_ERROR

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */

#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXO_COMPILER_SUPPORT_cstd_system_error>0)
    #include CXXO_INCLUDE_SYS(system_error)
#endif
#include "../system_error.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstd/type_traits.

1
2
3
4
5
6

7

8



9
10
#ifndef CXXOMFORT_STD_TYPE_TRAITS
#define CXXOMFORT_STD_TYPE_TRAITS

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */

#include "../impl/_headers.hpp"

#include_next <type_traits>



#include "../type_traits.hpp"
#endif






>

>
|
>
>
>


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

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <type_traits>
#else
    #include CXXO_INCLUDE_SYS(type_traits)
#endif
#include "../type_traits.hpp"
#endif

Added cxxomfort/cxxomfort/cstd/typeindex.































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

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../config.hpp"
#include "../impl/_headers.hpp"
// <typeindex> is >= C+11
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <typeindex>
#endif
#include "../typeindex.hpp"
#endif

Changes to cxxomfort/cxxomfort/cstd/utility.

1
2
3
4
5
6
7

8



9
10
#ifndef CXXOMFORT_STD_UTILITY
#define CXXOMFORT_STD_UTILITY

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

#include_next <utility>



#include "../utility.hpp"
#endif







>
|
>
>
>


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

/* 
 * Transparent header for automatic inclusion of cxxomfort library
 */
#include "../impl/_headers.hpp"
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #include_next <utility>
#else
    #include CXXO_INCLUDE_SYS(utility)
#endif
#include "../utility.hpp"
#endif

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

26
27
28
29
30
31
32


33
34
35
36
37
38
39
#include <cxxomfort/base.hpp>
#include <cxxomfort/library/sequences.hpp> // is_iterator
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <memory>
#define CXXOMFORT_IMPLEMENTS_n2648 CXXO_LIBRARY()



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







>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <cxxomfort/base.hpp>
#include <cxxomfort/library/sequences.hpp> // is_iterator
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <memory>
#define CXXOMFORT_IMPLEMENTS_n2648 CXXO_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_dynarray CXXOMFORT_IMPLEMENTS_n2648


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

Changes to cxxomfort/cxxomfort/forward_list.hpp.

27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
44
...
263
264
265
266
267
268
269
270
271
272
#include <cxxomfort/base.hpp>
#include <stdexcept>
#include <iterator>
#include <memory>
#include "memory.hpp"
#include "util/memtraits.hpp"



#if (CXXOMFORT_CXX_STD >= 2011)
#include <forward_list>
#else

namespace cxxomfort {
namespace cxxostd {

namespace detail_fwlist {
    struct sl_node_base {
        sl_node_base *next;
................................................................................
    namespace std {
        using ::cxxomfort::cxxostd::forward_list;
    }
#endif // no std using

#endif // c++11 already has <forward_list>

#endif // c++11

#endif







<
>
|
<
<







 







<


27
28
29
30
31
32
33

34
35


36
37
38
39
40
41
42
...
261
262
263
264
265
266
267

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


#define CXXOMFORT_IMPLEMENTS_n2543 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_singly_linked_list CXXOMFORT_IMPLEMENTS_n2543



namespace cxxomfort {
namespace cxxostd {

namespace detail_fwlist {
    struct sl_node_base {
        sl_node_base *next;
................................................................................
    namespace std {
        using ::cxxomfort::cxxostd::forward_list;
    }
#endif // no std using

#endif // c++11 already has <forward_list>



#endif

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







































































































































































































































































































































































































































































































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

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

#include "../util/type_traits.hpp"
#include <type_traits>
#include <ciso646>

#if (CXXOMFORT_CXX_STD >= 2011)
    // only do something if the specific compiler lacks std::common_type
#else // c++03
    #define CXXO_IMPLEMENT_COMMON_TYPE 1

    
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && (CXXOMFORT_COMPILER_VERSION>=1600 && CXXOMFORT_COMPILER_VERSION<=1800) )
        // MSVC 2010 already implements common_type, albeit broken; nothing we can do
        #undef CXXO_IMPLEMENT_COMMON_TYPE
    #elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
        // GCC ships common_type in "emulation" mode from 4.4 onwards
        #if (CXXOMFORT_COMPILER_VERSION >= 404 && CXXOMFORT_CXX_EMULATION==2011)
            #undef CXXO_IMPLEMENT_COMMON_TYPE
        #endif
    #else
        // unrecognized compiler
    
    #endif

#endif // CXXOMFORT_CXX_STD


#if defined(CXXO_IMPLEMENT_COMMON_TYPE) // _IMPLEMENT_
/*
 * Unlike other utilities, common_type has to be implemented in namespace std 
 * because clients have to be able to specialize.
 * 
 * The only way around it would be to either hack MSVC 2010's <utility> 
 * or replacing the header whole via a cstd/cxx11/utility transparent header.
 * 
 * A cxxomfort::common_type_2 could be offered as an alternative.
 * 
 */
namespace std {

#if (0 && CXXO_COMPILER_SUPPORT_variadic==1) // VARIADIC

#else

template <
 typename T1, typename T2=void, typename T3=void, typename T4=void, typename T5=void
 , typename T6=void, typename T7=void, typename T8=void, typename T9=void, typename TA=void>
struct common_type
 : public common_type <T1, typename common_type<T2,T3,T4,T5,T6,T7,T8,T9,TA>::type >
 {};

// one arg - not exactly identity
template <typename T>
struct common_type<T> { typedef typename std::decay<T>::type type; };

//
// two args - here is where the real work is done
// if we have __typeof__, we can use that
// if not but we have is_convertible, we can try to use that
// if we don't even have that, we can use a promotion chain
//


// two args - unequal case
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXO_COMPILER_SUPPORT_typeof==1)

template <typename T1, typename T2> struct common_type<T1,T2> {
	private:
	template <typename Q> static typename std::add_lvalue_reference<Q>::type dv ();
	public:
	typedef  typename common_type< __typeof__ (true ? dv<T1>() : dv<T2>() ) >::type type;
};
    

#else
// (decltype/__typeof__ not available)
// (we can try and solve some cases via eg.: is_convertible)

template <typename T1, typename T2> struct common_type <T1,T2> {
	private:
	struct common_type_cant_resolve; 
	template <typename Q> static typename std::add_lvalue_reference<Q>::type dv ();
	enum { 
		samey = is_same<T1,T2>::value, 
		convertible_12 = std::tr1::is_convertible<T1,T2>::value ,
		convertible_21 = std::tr1::is_convertible<T2,T1>::value
	};
	static_assert (convertible_12 or convertible_21, "cxxomfort: common_type<...> instantiation can not resolve");
	typedef std::conditional< 
		convertible_12, 
		T2, 
		typename std::enable_if<convertible_21, T1>::type
		> convto_t;
	
	public:
	typedef typename std::decay<typename convto_t::type>::type type;
	
};

// we specialize promotion pairs 
// that define common_type<T1,T2> -> type = T2
#define DEF_COMFORT_COMMONTYPE_PROMOTE(T1,T2) \
template <> struct common_type<T1,T2>: common_type<T2> {}; \
template <> struct common_type<T2,T1>: common_type<T2> {} 

    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,int) ;
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,long) ;
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,long long) ;
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned long long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(signed char,short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(signed char,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(signed char,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned char,unsigned short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned char,unsigned int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned char,unsigned long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(short,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(short,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(short,long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,unsigned int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,unsigned long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,unsigned long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,long long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(int,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(int,long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,unsigned long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,unsigned long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,long long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(float,double);
    DEF_COMFORT_COMMONTYPE_PROMOTE(float,long double);
    DEF_COMFORT_COMMONTYPE_PROMOTE(double,long double);

    //DEF_COMFORT_COMMONTYPE_PROMOTE(char const*, std::string);
    //DEF_COMFORT_COMMONTYPE_PROMOTE(wchar const*, std::wstring);

#undef DEF_COMFORT_COMMONTYPE_PROMOTE
// end compiler w/o typeof
    
#endif // common_case<T1,T2> resolver


// three args

template <typename T1, typename T2, typename T3>
struct common_type<T1,T2,T3>
 : public common_type< typename common_type<T1,T2>::type, T3 >
 {};


// four args

template <typename T1, typename T2, typename T3, typename T4>
struct common_type<T1,T2,T3,T4>
 : public common_type< typename common_type<T1,T2,T3>::type, T4 >
 {};


// five args

template <typename T1, typename T2, typename T3, typename T4, typename T5>
struct common_type<T1,T2,T3,T4,T5>
 : public common_type< typename common_type<T1,T2,T3,T4>::type, T5 >
 {};

// six args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
struct common_type<T1,T2,T3,T4,T5,T6>
 : public common_type< typename common_type<T1,T2,T3,T4,T5>::type, T6 >
 {};

// seven args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
struct common_type<T1,T2,T3,T4,T5,T6,T7>
 : public common_type< typename common_type<T1,T2,T3,T4,T5,T6>::type, T7 >
 {};

// eight args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
struct common_type<T1,T2,T3,T4,T5,T6,T7,T8>
 : public common_type< typename common_type<T1,T2,T3,T4,T5,T6,T7>::type, T8 >
 {};

// nine args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
struct common_type<T1,T2,T3,T4,T5,T6,T7,T8,T9>
 : public common_type< typename common_type<T1,T2,T3,T4,T5,T6,T7,T8>::type, T9 >
 {};

#endif // VARIADIC

// two args - equal case
template <typename T>
struct common_type<T,T>
 : common_type<T> 
 {};


}    // namespace std
#endif // _IMPLEMENT_

#if defined(DOXYGEN_DOC)

/**
 * @struct common_type
 * @brief Calculates the common type between two types.
 * @ingroup cxx11-backports
 * @xrefitem std:type_traits "<type_traits>" ""
 * 
**/
template <typename... Types>
struct common_type {
    typedef _implementation_defined_ type;
};

#endif

#endif


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

1
2



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




/**
 * @file 
 * @brief Implementation of std::decay
 */

#include <cxxomfort/config.hpp>


>
>
>







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

#define CXXOMFORT_IMPLEMENTS_n2069 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_decay CXXOMFORT_IMPLEMENTS_n2069

/**
 * @file 
 * @brief Implementation of std::decay
 */

#include <cxxomfort/config.hpp>

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











































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CXXOMFORT_IMPL_11_MOVE_TRAITS_HPP
#define CXXOMFORT_IMPL_11_MOVE_TRAITS_HPP
/**
 * @file
 */
#include <cxxomfort/base.hpp>
#include <cxxomfort/type_traits.hpp>

// is_trivially_move_.... for C++03
// is_nothrow_move_... for C++03
// These just return false for everything but scalar types

/*
 * is_move_constructible for C++03, we just look at scalarness
 */

namespace cxxomfort { namespace cxxostd {

template <typename T> 
struct is_trivially_move_constructible 
: std::is_scalar<T> {
};

template <typename T>
struct is_nothrow_move_constructible 
: std::is_scalar<T> {
};

template <typename T>
struct is_move_constructible
: std::integral_constant<bool,
    std::is_scalar<T>::value && !(std::is_same<T,void>::value)
> {};

} } // cxxomfort::cxxostd

#if (CXXOMFORT_CXX_STD < 2011 )
    #if (CXXOMFORT_CXX_EMULATION < 2011)
        #define CXXO_needs_move_xxxible_traits
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, < 408))
        #define CXXO_needs_move_xxxible_traits
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, < 1700))
        #define CXXO_needs_move_xxxible_traits
    #endif
#endif


#ifdef CXXO_needs_move_xxxible_traits
namespace std {
    using ::cxxomfort::cxxostd::is_trivially_move_constructible;
    using ::cxxomfort::cxxostd::is_nothrow_move_constructible;
    using ::cxxomfort::cxxostd::is_move_constructible;
}
#endif

// GCC 4.7~4.8 announce C++11 mode, but they still lack trivially_move_constructible for some reason
#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, >= 407)) \
    && (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, < 409)) \
    && (CXXOMFORT_CXX_STD == 2011)
namespace std {
    using ::cxxomfort::cxxostd::is_trivially_move_constructible;
}

#endif


#endif


Added cxxomfort/cxxomfort/impl/11-typeindex.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
#ifndef CXXOMFORT_IMPL_TYPEINDEX_TYPE_INDEX_HPP
#define CXXOMFORT_IMPL_TYPEINDEX_TYPE_INDEX_HPP
/**
 * @file
 */

/*
 * Support for getting elements of a tuple by type
 * (C++14 proposal n3584 "Wording for Addressing Tuples by Type")
 * based off of n3404 and n3584
 * http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3584.html
 * 
 * Interfaces defined in this header:
 * 
 * 
 */

#include <cxxomfort/base.hpp>
#include <typeinfo>
#include <functional> // std::hash
#include <string> // for debug of hash_code
#include <cxxomfort/impl/relationals.hpp>
#include <cxxomfort/using.hpp> // std::tr1::hash

namespace cxxomfort { namespace cxxostd { 

static inline size_t ty_id () {
    static size_t i= 0;
    return i++;
}

template <typename T>
struct impl_hash_code {
    static const size_t value;
};

template<typename T> 
const size_t impl_hash_code<T>::value = ty_id();

class type_index {
    public:
    type_index (std::type_info const& t)
    : TR(&t) {}
    
    type_index& operator= (std::type_info const& r) CXXO_NOEXCEPTNOTHROW {
        TR= &r;
        return *this;
    }
    
    char const*  name () const CXXO_NOEXCEPT { return TR->name(); }
    size_t       hash_code () const CXXO_NOEXCEPT { 
#if (CXXOMFORT_CXX_STD >= 2011)
        return TR->hash_code(); 
#else
        // in C++03 there's no type_info::hash_code
        // we go to hash<const char*>
        using namespace std;
        hash<char const*> const H;
        return H( TR->name() );
#endif
    }
    
    friend bool     operator== (type_index const& l, type_index const& r) CXXO_NOEXCEPTNOTHROW {
        return l.TR==r.TR;
    }
    friend bool     operator<  (type_index const& l, type_index const& r) CXXO_NOEXCEPTNOTHROW {
        return (l.TR)->before(*r.TR);
    }

    private:
    std::type_info const* TR;
    
};

CXXO_GENERATE_RELATIONALS(type_index);

} }

#endif // 


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

2
3
4
5
6
7
8
9
10
11




12
13
14
15
16
17
18
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP

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





#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC)
    // Add underlying_type approximation for GCC < 4.7 in any mode
    // see http://stackoverflow.com/questions/9343329/how-to-know-underlying-type-of-class-enum/10956467#10956467
    #if (CXXOMFORT_COMPILER_VERSION < 407)
        #define CXXOMFORT_USING_underlying_type 1
    #elif (CXXOMFORT_COMPILER_VERSION >= 407 && CXXOMFORT_CXX_STD < 2011 )
................................................................................
     * @brief Given an enumeration type, provides the integral type serving as its storage.
     * @ingroup cxx11-backports
     * @xrefitem std0typetraits "<type_traits>" ""
     * @anchor underlying_type
     * */
    template< typename TpEnum >
    struct underlying_type {
        typedef typename ::cxxomfort::integral_of_size<sizeof(TpEnum)>::type tsize_t;
        private:
        typedef typename make_signed< tsize_t >::type S;
        typedef typename make_unsigned< tsize_t >::type U;
        public:
        typedef typename std::conditional<
            (TpEnum( -1 ) < TpEnum( 0 )), S, U
            >::type type;







|


>
>
>
>







 







|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#define CXXOMFORT_IMPL_UNDERLYING_TYPE_HPP

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


#define CXXOMFORT_IMPLEMENTS_n2984_1055 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_underlying_type CXXOMFORT_IMPLEMENTS_n2984_1055

#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC)
    // Add underlying_type approximation for GCC < 4.7 in any mode
    // see http://stackoverflow.com/questions/9343329/how-to-know-underlying-type-of-class-enum/10956467#10956467
    #if (CXXOMFORT_COMPILER_VERSION < 407)
        #define CXXOMFORT_USING_underlying_type 1
    #elif (CXXOMFORT_COMPILER_VERSION >= 407 && CXXOMFORT_CXX_STD < 2011 )
................................................................................
     * @brief Given an enumeration type, provides the integral type serving as its storage.
     * @ingroup cxx11-backports
     * @xrefitem std0typetraits "<type_traits>" ""
     * @anchor underlying_type
     * */
    template< typename TpEnum >
    struct underlying_type {
        typedef typename ::cxxomfort::library::utility::integral_of_size<sizeof(TpEnum)>::type tsize_t;
        private:
        typedef typename make_signed< tsize_t >::type S;
        typedef typename make_unsigned< tsize_t >::type U;
        public:
        typedef typename std::conditional<
            (TpEnum( -1 ) < TpEnum( 0 )), S, U
            >::type type;

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

5
6
7
8
9
10
11



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




namespace cxxomfort {
namespace cxxostd {

//
// explicit sized ranges for equal, from C++14
//
namespace detail_algorithm {







>
>
>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * @brief Implementation of C++14's overloads for @c equal(), @c mismatch() .
 * */
#include <cxxomfort/base.hpp>
#include <type_traits>
#include "../algorithm.hpp"
// <algorithm> should have been included already

#define CXXOMFORT_IMPLEMENTS_n3671 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_two_ranges_equal_mismatch CXXOMFORT_IMPLEMENTS_n3671

namespace cxxomfort {
namespace cxxostd {

//
// explicit sized ranges for equal, from C++14
//
namespace detail_algorithm {

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

18
19
20
21
22
23
24
25


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 * * @c std::bit_or<void>
 * * @c std::bit_xor<void>
 *
 */


#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n3431 CXXO_IMPLSTATUS_BACKPORT()



#include CXXO_INCLUDE_SYS(functional)
// <functional> needs to be #included for this to make any sense
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
#pragma message CXXO_NOTICE("enabled <functional> transparent functors")
#endif

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

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup cxx14-backports
 * @{







|
>
>









|







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
 * * @c std::bit_or<void>
 * * @c std::bit_xor<void>
 *
 */


#include <cxxomfort/config.hpp>
#define CXXOMFORT_IMPLEMENTS_n3421 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_heterogeneous_operator_functors CXXOMFORT_IMPLEMENTS_n3421


#include CXXO_INCLUDE_SYS(functional)
// <functional> needs to be #included for this to make any sense
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
#pragma message CXXO_NOTICE("enabled <functional> transparent functors")
#endif

#include <type_traits> // common_type
#include "../type_traits.hpp"
#include "../impl/11-common_type.hpp"

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup cxx14-backports
 * @{

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

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 * @}
 */

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

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







|







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 * @}
 */

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

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

Added cxxomfort/cxxomfort/impl/14-iterator_access.hpp.















































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef CXXOMFORT_IMPL_14_CBEGIN_HPP
#define CXXOMFORT_IMPL_14_CBEGIN_HPP
/**
 * @file
 * @brief Implementation of std::cbegin , std::cend 
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp>
#include CXXO_INCLUDE_SYS(cstddef)

//#define CXXOMFORT_IMPLEMENTS_n4017 CXXO_IMPLSTATUS_EMULATION()
//#define CXXOMFORT_IMPLEMENTS_nonmember_size CXXOMFORT_IMPLEMENTS_n4017

namespace cxxomfort { namespace cxxostd { namespace iterator {

/**
 * @fn cbegin
 * @brief Returns an iterator to the beginning of a given container or sequence.
 * */

/**
 * @fn cend
 * @brief Returns an iterator to the end of a given container or sequence.
 * */

#if (CXXOMFORT_CXX_STD >= 2011)

template <typename C>
constexpr auto
cbegin (C const& c)  -> decltype(std::begin(c)) {
    return std::begin(c);
} ;

template <typename C>
constexpr auto
cend (C const& c) -> decltype(std::end(c)) {
    return std::end(c);
} ;

#else

template <typename C>
typename C::const_iterator
cbegin (C const& c) {
    return std::begin(c);
} 

template <typename C>
typename C::const_iterator
cend (C const& c) {
    return std::end(c);
} 

#endif

//! @ref cxx14-backports
template <typename C>
typename C::reverse_iterator inline
rbegin (C & c) {
    static_assert(sizeof(typename C::reverse_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.rbegin();
}

//! @ref cxx14-backports
template <typename C>
typename C::reverse_iterator inline
rend (C & c) {
    static_assert(sizeof(typename C::reverse_iterator), "");
    static_assert(sizeof(typename C::value_type), "");
    return c.rend();
}


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

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





}}}

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

    #if (CXXOMFORT_CXX_STD < 2014)
    namespace std {
        using ::cxxomfort::cxxostd::iterator::cbegin;
        using ::cxxomfort::cxxostd::iterator::cend;
        using ::cxxomfort::cxxostd::iterator::rbegin;
        using ::cxxomfort::cxxostd::iterator::rend;
    }
    #endif

#endif // no std using

#endif

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

2
3
4
5
6
7
8



9
10
11
12
13
14
15
#define CXXOMFORT_IMPL_MAKE_UNIQUE_HPP
/**
 * @file
 */
#include "../base.hpp"
#include "../impl/unique_ptr.hpp"




// this is included after unique_ptr

// Add make_unique
// equivalent to return std::unique_ptr<T>(new T(std::forward<Args>(args)...));

namespace std {








>
>
>







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#define CXXOMFORT_IMPL_MAKE_UNIQUE_HPP
/**
 * @file
 */
#include "../base.hpp"
#include "../impl/unique_ptr.hpp"

#define CXXOMFORT_IMPLEMENTS_n3588 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_make_unique CXXOMFORT_IMPLEMENTS_n3588

// this is included after unique_ptr

// Add make_unique
// equivalent to return std::unique_ptr<T>(new T(std::forward<Args>(args)...));

namespace std {

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

15
16
17
18
19
20
21


22
23
24
25
26
27
28
 * * std::get <T> (std::tuple<...>)
 * 
 */

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



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

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 1)







>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 * * std::get <T> (std::tuple<...>)
 * 
 */

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


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

#if (defined(CXXOMFORT_NOTICES))
    #if (CXXOMFORT_NOTICES > 1)

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

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * @file
 * @brief Implementation of std::bool_constant 
 */
#include <cxxomfort/base.hpp>
#include <cxxomfort/type_traits.hpp>
#include <type_traits>
#include <tuple>

#define CXXOMFORT_IMPLEMENTS_n4334 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_bool_constant CXXOMFORT_IMPLEMENTS_n4334

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







<







3
4
5
6
7
8
9

10
11
12
13
14
15
16
/**
 * @file
 * @brief Implementation of std::bool_constant 
 */
#include <cxxomfort/base.hpp>
#include <cxxomfort/type_traits.hpp>
#include <type_traits>


#define CXXOMFORT_IMPLEMENTS_n4334 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_bool_constant CXXOMFORT_IMPLEMENTS_n4334

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

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

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

50
51
52
53
54
55
56
57
..
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
 * byte byte(char) <-- explicit
 * 
 */


#if (CXXOMFORT_CXX_STD < 2017)
    #define CXXOMFORT_USING_stdbyte
#else 
    #define CXXOMFORT_IMPLEMENTS_byte 0
    #define CXXOMFORT_IMPLEMENTS_p0298r3 0
#endif

// -----
// implementation
//

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

    #if (CXXOMFORT_CXX_STD >= 2011)

        #define CXXOMFORT_IMPLEMENTS_p0298r3 CXXO_IMPLSTATUS_BACKPORT()
        #define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3

        
enum class byte : unsigned char {};

template <typename Int, typename = typename std::enable_if< std::is_integral<Int>::value>::type >
constexpr static inline byte to_byte (Int i) noexcept {
................................................................................

template <typename Int, typename = typename std::enable_if< std::is_integral<Int>::value>::type >
constexpr inline Int to_integer (byte b) noexcept { 
    return static_cast<Int>(b);
}
        
    #else

        #define CXXOMFORT_IMPLEMENTS_p0298r3 CXXO_IMPLSTATUS_EMULATION()
        #define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3
        // these three go here to ensure that we call namespace std outside
        }}
        #include "../library/typesafe_enum.hpp"
        namespace cxxomfort { namespace cxxostd {

namespace detail { // detail
................................................................................
: public detail::byteimpl  {
    private:
    typedef detail::byteimpl underlying_t;
    public:

    CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(byte);

    byte (byte const& b) : detail::byteimpl((detail::byteimpl const&)b) {}

    using detail::byteimpl::underlying;
    //using detail::byteimpl::CXXO_EXPLICIT_OPERATOR(unsigned char);


    //using detail::byteimpl::equals;








|












>
|







 







>
|







 







|







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
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
 * byte byte(char) <-- explicit
 * 
 */


#if (CXXOMFORT_CXX_STD < 2017)
    #define CXXOMFORT_USING_stdbyte
#else     
    #define CXXOMFORT_IMPLEMENTS_byte 0
    #define CXXOMFORT_IMPLEMENTS_p0298r3 0
#endif

// -----
// implementation
//

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

    #if (CXXOMFORT_CXX_STD >= 2011)
        #define CXXOMFORT_IMPLEMENTS_p0298r2 CXXO_IMPLSTATUS_BACKPORT()
        #define CXXOMFORT_IMPLEMENTS_p0298r3 CXXOMFORT_IMPLEMENTS_p0298r2
        #define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3

        
enum class byte : unsigned char {};

template <typename Int, typename = typename std::enable_if< std::is_integral<Int>::value>::type >
constexpr static inline byte to_byte (Int i) noexcept {
................................................................................

template <typename Int, typename = typename std::enable_if< std::is_integral<Int>::value>::type >
constexpr inline Int to_integer (byte b) noexcept { 
    return static_cast<Int>(b);
}
        
    #else
        #define CXXOMFORT_IMPLEMENTS_p0298r2 CXXO_IMPLSTATUS_EMULATION()
        #define CXXOMFORT_IMPLEMENTS_p0298r3 CXXOMFORT_IMPLEMENTS_p0298r2
        #define CXXOMFORT_IMPLEMENTS_byte CXXOMFORT_IMPLEMENTS_p0298r3
        // these three go here to ensure that we call namespace std outside
        }}
        #include "../library/typesafe_enum.hpp"
        namespace cxxomfort { namespace cxxostd {

namespace detail { // detail
................................................................................
: public detail::byteimpl  {
    private:
    typedef detail::byteimpl underlying_t;
    public:

    CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(byte);

    CXXO_CONSTEXPR byte (byte const& b) CXXO_NOEXCEPTNOTHROW : detail::byteimpl((detail::byteimpl const&)b) {}

    using detail::byteimpl::underlying;
    //using detail::byteimpl::CXXO_EXPLICIT_OPERATOR(unsigned char);


    //using detail::byteimpl::equals;

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

2
3
4
5
6
7
8

9
10
11
12
13
14
15
16
#define CXXOMFORT_IMPL_17_DESTROY_AT_HPP
/**
 * @file
 * @brief Implementation of std::destroy_at and allies
 * 
 */


#define CXXOMFORT_IMPLEMENTS_p0040r2 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_destroy_at CXXOMFORT_IMPLEMENTS_p0040r2

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

namespace cxxomfort {
namespace cxxostd {







>
|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#define CXXOMFORT_IMPL_17_DESTROY_AT_HPP
/**
 * @file
 * @brief Implementation of std::destroy_at and allies
 * 
 */

#define CXXOMFORT_IMPLEMENTS_p0040r1 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_p0040r2 CXXOMFORT_IMPLEMENTS_p0040r1
#define CXXOMFORT_IMPLEMENTS_destroy_at CXXOMFORT_IMPLEMENTS_p0040r2

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

namespace cxxomfort {
namespace cxxostd {

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

4
5
6
7
8
9
10



11
12
13
14
15
16
17
 * @file
 * @brief Implementation of std::size , std::data , std::empty 
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp>
#include CXXO_INCLUDE_SYS(cstddef)




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







>
>
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 * @file
 * @brief Implementation of std::size , std::data , std::empty 
 */
#include <cxxomfort/config.hpp>
#include <cxxomfort/base/iterator.hpp>
#include CXXO_INCLUDE_SYS(cstddef)

#define CXXOMFORT_IMPLEMENTS_n4017 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_nonmember_size CXXOMFORT_IMPLEMENTS_n4017

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

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

11
12
13
14
15
16
17



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




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

#include <cxxomfort/base.hpp>







>
>
>







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

#define CXXOMFORT_IMPLEMENTS_n3829 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_tuple_apply CXXOMFORT_IMPLEMENTS_n3829

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

#include <cxxomfort/base.hpp>

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

1
2
3




4
5
6
7
8
9
10
#ifndef CXXOMFORT_IMPL_CHARACTER_HPP
#define CXXOMFORT_IMPL_CHARACTER_HPP





namespace cxxomfort{ namespace library{ namespace type_traits {

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



>
>
>
>







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

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

namespace cxxomfort{ namespace library{ namespace type_traits {

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

Added cxxomfort/cxxomfort/impl/n3334-array_ref.hpp.















































































































































































































































































































































































































































































































































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

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

#define CXXOMFORT_IMPLEMENTS_n3334 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_array_ref CXXOMFORT_IMPLEMENTS_n3334

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


namespace cxxomfort {
namespace impl {
namespace array_ref {

namespace ct = cxxomfort::traits;

/**
 * @brief An object representing a reference or @e slice of a 
 * contiguous area of memory of type @e T .
 * @anchor libarrayref
 * @tparam T Type of the kind of value contained in the view.
 * @ingroup cxxo-sup 
 * 
 * A @c array_ref is a non-owning view of a sequence of 
 * *contiguous* elements via a simple {pointer+length} package. 
 * In many ways it could be considered an analogue to 
 * <code>std::array</code> except it doesn't actually hold the data 
 * (hence the name, @c array_ref ).
 * 
 * It provides some of the same operatios available for readable
 * sequences, in particular begin() and end(). Because it points to 
 * an area of memory directly, iterators are raw pointer types.
 * 
 * This implementation is intended to be used for sequences of 
 * const elements (ie.: template argument is <code>T const</code>).
 * 
 * The utility function make_array_ref() helps create 
 * array_refs from contexts where they can be needed.
 * 
 * See also: <code>std::vector</code>, @c seq_ .
 * 
 * @c array_ref is based in the original publication "n3334" by 
 * Jeffrey Yasskin; @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html 
 * 
 */
template <typename T>
class array_ref {
    public:
    //! type of the data contained in the view.
    typedef T       value_type;
    typedef typename ct::compose<T,::std::add_pointer>::type   pointer;
    typedef typename ct::compose<T,::std::add_const, ::std::add_pointer>::type const_pointer;
    typedef typename ct::compose<T,std::add_reference>::type   reference;
    typedef typename ct::compose<T,std::add_const,std::add_reference>::type const_reference;
    typedef ptrdiff_t    difference_type;
    typedef size_t       size_type;
    typedef pointer           iterator;
    typedef const_pointer const_iterator;
    typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
    
    public:
    
    CXXO_CONSTEXPR array_ref () CXXO_NOEXCEPTNOTHROW 
    #if (CXXOMFORT_CXX_STD<2011)
    : ptr_(nullptr), len_(0) {}
    #else
    = default;
    #endif
    
    CXXO_CONSTEXPR array_ref (array_ref const& p) CXXO_NOEXCEPTNOTHROW 
    #if (CXXOMFORT_CXX_STD<2011)
    : ptr_(p.ptr_), len_(p.len_) {}
    #else
    = default;
    #endif
    
    ///! Initializes this to refer to a buffer of memory pointed by @a p and of size @a l .
    CXXO_CONSTEXPR array_ref (pointer p, size_t l) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(l) {}
    
    CXXO_CONSTEXPR array_ref (std::nullptr_t, T const* p, T const* q) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(static_cast<size_t>(q-p)) {}
    ///! Initialize this to refer to a C-style array.
    template <size_t N>
    explicit array_ref (T(&arr)[N]) CXXO_NOEXCEPTNOTHROW : ptr_(arr), len_(N) {}
    
    

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

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


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

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

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

    const_iterator  front () const { return ptr_[0]; }
    const_iterator  back () const { return ptr_[len_-1]; }
    
    array_ref       slice (size_t skip) const {
        return (skip > len_) ? array_ref() : array_ref(ptr_+skip, len_-skip);
    }
    array_ref       slice (size_t skip, size_t n) const {
        return slice(skip);
    }
    
    private:
    void check_range (size_t i) const {
        if (i>=len_) throw std::out_of_range("array_ref: out of range");
    }
    void check_range (size_t i, std::error_code& ec) const {
        if (i>=len_) ec= std::make_error_code(EDOM, std::generic_category());
    }
    
    pointer const   ptr_;
    size_t const    len_;

}; // array_ref

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

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

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

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


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

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



template <typename Ty>
array_ref<Ty> arrayref (Ty* p, size_t l) {
    return array_ref<Ty>(p,l);
}

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

template <typename Ty>
array_ref<Ty const> carrayref (Ty* p, size_t l) {
    return array_ref<Ty const>(p,l);
}

template <typename Ty, size_t N>
array_ref<Ty const> carrayref (Ty(&p)[N]) {
    return array_ref<Ty const>(p,N);
}

template <typename Ty>
array_ref<Ty const> carrayref (array_ref<Ty> const& a) {
    return array_ref<Ty const>(a.data(), a.size());
}


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

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

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


/*
 * @page cxxo:array_ref "Array view for sequences, from n3334"
 * @ingroup cxxo:library
 * 
 * Interfaces defined:
 * 
 * * @c array_ref .
 * * @c make_array_ref , @c make_array_cref . 
 * * @c is_array_ref .
 * 
 * 
**/

#endif

Added cxxomfort/cxxomfort/impl/n3668-exchange.hpp.



























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef CXXOMFORT_IMPL_n3668_HPP
#define CXXOMFORT_IMPL_n3668_HPP

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

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

#define CXXOMFORT_IMPLEMENTS_n3668 CXXO_IMPLSTATUS_BACKPORT()
#define CXXOMFORT_IMPLEMENTS_exchange CXXOMFORT_IMPLEMENTS_n3668


#if (CXXOMFORT_CXX_STD < 2014)

namespace cxxomfort {
namespace cxxostd {

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

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

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

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

#endif


#endif

Deleted cxxomfort/cxxomfort/impl/n3668_exchange.hpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef CXXOMFORT_IMPL_n3668_HPP
#define CXXOMFORT_IMPL_n3668_HPP

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

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


#if (CXXOMFORT_CXX_STD < 2014)
#define CXXOMFORT_IMPLEMENTS_n3668 1

namespace cxxomfort {
namespace cxxostd {

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

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

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

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

#endif


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






















































































































Changes to cxxomfort/cxxomfort/impl/relationals.hpp.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#define CXXO_GENERATE_RELATIONALS(T) \
inline bool operator!= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
inline bool operator>  (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
inline bool operator<= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
inline bool operator>= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \

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


#endif







|

|

|

|




9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#define CXXO_GENERATE_RELATIONALS(T) \
inline bool operator!= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl==vr); } \
inline bool operator>  (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return vr<vl; } \
inline bool operator<= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl>vr); } \
inline bool operator>= (T const& vl, T const& vr) CXXO_NOEXCEPTNOTHROW { return !(vl<vr); } \

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


#endif

Changes to cxxomfort/cxxomfort/impl/typesafe_enum-core.hpp.

55
56
57
58
59
60
61

62
63
64

65
66
67
68
69
70
    }

    
    private:
    struct disallowed_enum_conversion {};
};


#define TARGS def,inner
CXXO_GENERATE_RELATIONALS_T(typesafe_enum_simple,typename def, typename inner);
#undef TARGS



}
}

#endif







>

|

>






55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    }

    
    private:
    struct disallowed_enum_conversion {};
};

#define TPARAMS typename def, typename inner
#define TARGS def,inner
CXXO_GENERATE_RELATIONALS_T(typesafe_enum_simple);
#undef TARGS
#undef TPARAMS


}
}

#endif

Added cxxomfort/cxxomfort/impl/typesafe_enum-wikibooks.hpp.

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

20
21
22
23
24
25
26




27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
...
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
...
362
363
364
365
366
367
368

369
370
371
372
373
374
375

376
377
378
379
380
381
382
...
420
421
422
423
424
425
426
427



428
429
430
431
432
433
434
...
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573



















574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
 *
 * * @c unique_ptr<> (also for namespace std)
 * * swap (for unique_ptr)
 * * hash<> specialization (for unique_ptr)
 * * make_unique (from "N3656 make_unique")
 * 
 */





#include "../config.hpp"

#if ((CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_unique_ptr==0))
    #define CXXOMFORT_USING_unique_ptr
#endif

#if (defined (CXXOMFORT_USING_unique_ptr))
#include "../base.hpp" // nullptr, static_assert, move, forward
#include "../util/meta.hpp"
#include "../util/type_traits.hpp"
#include CXXO_INCLUDE_SYS(cstddef) // this brings eg.: shared_ptr
#include CXXO_INCLUDE_SYS(memory) // this brings eg.: shared_ptr
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled unique_ptr emulation")
#endif

/*
 * Dependencies from type_traits:
 * is_reference
................................................................................
    typedef typename add_reference<const T2>::type T2_const_reference;

    unique_ptr_storage(const unique_ptr_storage&);
    unique_ptr_storage& operator=(const unique_ptr_storage&);
public:
    operator rv<unique_ptr_storage>() {return rv<unique_ptr_storage>(*this);}

    unique_ptr_storage() : t1_(), t2_() {}

    explicit unique_ptr_storage(T1 t1)
        : t1_(move(t1)), t2_() {}

    unique_ptr_storage(T1 t1, T2 t2)
        : t1_(move(t1)), t2_(forward<T2>(t2)) {}

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

}  // detail_unique_ptr

template <class T>
struct default_delete {

    default_delete() {}
    virtual ~default_delete () {};

    template <class U>
    default_delete ( const default_delete<U>&
    , typename std::enable_if<detail_unique_ptr::is_convertible<U*, T*>::value, void>::type* = 0 )  {
    }

    void operator() (T* ptr) const     {
        static_assert (sizeof(T) > 0, "T must be a complete type");
        delete ptr;
    }
};

template <class T>
struct default_delete<T[]> {
    void operator() (T* ptr) const {
        static_assert (sizeof(T) > 0, "T must be a complete type");
        delete [] ptr;
    }

private:

    template <class U> void operator()(U*) const;
................................................................................
    unique_ptr& operator=( CXXO_RV_REF(unique_ptr) r) {
        reset(r.release());
        ptr_.second() = std::move(r.get_deleter());
        return *this;
    }

    //! Default constructor.

    unique_ptr() : ptr_(nullptr) {
        static_assert (!cxxomfort::traits::is_reference<deleter_type>::value, "Trying to use the deleter of a reference type.");
        static_assert (!cxxomfort::traits::is_pointer<deleter_type>::value, "Trying to use the deleter of a pointer type.");
    }

    //! Creates a @c unique_ptr wrapping the allocated pointer @a p .
    explicit unique_ptr(pointer p) : ptr_(p) {

        static_assert (!cxxomfort::traits::is_reference<deleter_type>::value, "Trying to use the deleter of a reference type.");
        static_assert (!cxxomfort::traits::is_pointer<deleter_type>::value, "Trying to use the deleter of a pointer type.");
    }

    //! Creates a @c unique_ptr given a pointer and a deleter, which is stored unreferenced.
    unique_ptr(pointer p, typename std::conditional<cxxomfort::traits::is_reference<D>::value
        , volatile typename cxxomfort::traits::remove_reference<D>::type&, D
................................................................................
    pointer operator->() const {return get();}
    //! Provides access to member.
    pointer get() const {return ptr_.first();}
    //! Provides access to deleter.
    deleter_reference       get_deleter()       {return ptr_.second();}
    deleter_const_reference get_deleter() const {return ptr_.second();}
    // (safe-bool conversion)
    operator int nat::*() const {return get() ? &nat::for_bool_ : 0;}




    //! Resets / reassigns the @c unique_ptr to another allocated pointer.
    void reset (pointer p = pointer()) {
        pointer t = get();
        if (t != pointer())
            get_deleter()(t);
        ptr_.first() = p;
................................................................................

template<class T, class D>
inline void swap (unique_ptr<T, D>& x, unique_ptr<T, D>& y) {
    x.swap(y);
}

template<class T1, class D1, class T2, class D2>
inline bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y) {
    return x.get() == y.get();
}

template<class T1, class D1, class T2, class D2>
inline bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y) {
    return !(x == y);
}

template<class T1, class D1, class T2, class D2>
inline bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y) {
    return x.get() < y.get();
}

template<class T1, class D1, class T2, class D2>
inline bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y) {
    return !(y < x);
}

template<class T1, class D1, class T2, class D2>
inline bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y) {
    return y < x;
}

template<class T1, class D1, class T2, class D2>
inline bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y) {
    return !(x < y);
}




















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

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


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

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

#endif  // guard







>
>
>
>











|
|







 







|







 







|







|







|







 







>
|





|
>







 







|
>
>
>







 







|




|




|




|




|




|


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








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





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
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
...
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
...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
...
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609






















610
611
612
613
614
 *
 * * @c unique_ptr<> (also for namespace std)
 * * swap (for unique_ptr)
 * * hash<> specialization (for unique_ptr)
 * * make_unique (from "N3656 make_unique")
 * 
 */

//
// FIXME TODO: fix interface to match https://github.com/SRombauts/unique_ptr/blob/master/unique_ptr.hpp
//

#include "../config.hpp"

#if ((CXXOMFORT_CXX_STD < 2011) && (CXXO_COMPILER_SUPPORT_unique_ptr==0))
    #define CXXOMFORT_USING_unique_ptr
#endif

#if (defined (CXXOMFORT_USING_unique_ptr))
#include "../base.hpp" // nullptr, static_assert, move, forward
#include "../util/meta.hpp"
#include "../util/type_traits.hpp"
#include CXXO_INCLUDE_SYS(cstddef) 
#include CXXO_INCLUDE_SYS(memory) 
#if defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1)
    #pragma message CXXO_NOTICE("enabled unique_ptr emulation")
#endif

/*
 * Dependencies from type_traits:
 * is_reference
................................................................................
    typedef typename add_reference<const T2>::type T2_const_reference;

    unique_ptr_storage(const unique_ptr_storage&);
    unique_ptr_storage& operator=(const unique_ptr_storage&);
public:
    operator rv<unique_ptr_storage>() {return rv<unique_ptr_storage>(*this);}

    CXXO_CONSTEXPR unique_ptr_storage() : t1_(), t2_() CXXO_NOEXCEPT {}

    explicit unique_ptr_storage(T1 t1)
        : t1_(move(t1)), t2_() {}

    unique_ptr_storage(T1 t1, T2 t2)
        : t1_(move(t1)), t2_(forward<T2>(t2)) {}

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

}  // detail_unique_ptr

template <class T>
struct default_delete {

    CXXO_CONSTEXPR default_delete() CXXO_NOEXCEPTNOTHROW {}
    virtual ~default_delete () {};

    template <class U>
    default_delete ( const default_delete<U>&
    , typename std::enable_if<detail_unique_ptr::is_convertible<U*, T*>::value, void>::type* = 0 )  {
    }

    void operator() (T* ptr) const  CXXO_NOEXCEPTNOTHROW   {
        static_assert (sizeof(T) > 0, "T must be a complete type");
        delete ptr;
    }
};

template <class T>
struct default_delete<T[]> {
    void operator() (T* ptr) const CXXO_NOEXCEPTNOTHROW {
        static_assert (sizeof(T) > 0, "T must be a complete type");
        delete [] ptr;
    }

private:

    template <class U> void operator()(U*) const;
................................................................................
    unique_ptr& operator=( CXXO_RV_REF(unique_ptr) r) {
        reset(r.release());
        ptr_.second() = std::move(r.get_deleter());
        return *this;
    }

    //! Default constructor.
    CXXO_CONSTEXPR unique_ptr() CXXO_NOEXCEPTNOTHROW 
    : ptr_(nullptr) {
        static_assert (!cxxomfort::traits::is_reference<deleter_type>::value, "Trying to use the deleter of a reference type.");
        static_assert (!cxxomfort::traits::is_pointer<deleter_type>::value, "Trying to use the deleter of a pointer type.");
    }

    //! Creates a @c unique_ptr wrapping the allocated pointer @a p .
    explicit unique_ptr(pointer p) 
    : ptr_(p) {
        static_assert (!cxxomfort::traits::is_reference<deleter_type>::value, "Trying to use the deleter of a reference type.");
        static_assert (!cxxomfort::traits::is_pointer<deleter_type>::value, "Trying to use the deleter of a pointer type.");
    }

    //! Creates a @c unique_ptr given a pointer and a deleter, which is stored unreferenced.
    unique_ptr(pointer p, typename std::conditional<cxxomfort::traits::is_reference<D>::value
        , volatile typename cxxomfort::traits::remove_reference<D>::type&, D
................................................................................
    pointer operator->() const {return get();}
    //! Provides access to member.
    pointer get() const {return ptr_.first();}
    //! Provides access to deleter.
    deleter_reference       get_deleter()       {return ptr_.second();}
    deleter_const_reference get_deleter() const {return ptr_.second();}
    // (safe-bool conversion)
    //operator int nat::*() const {return get() ? &nat::for_bool_ : 0;}
    CXXO_EXPLICIT_OPERATOR(bool) () const CXXO_NOEXCEPTNOTHROW {
        return this->get() ? true : false;
    }

    //! Resets / reassigns the @c unique_ptr to another allocated pointer.
    void reset (pointer p = pointer()) {
        pointer t = get();
        if (t != pointer())
            get_deleter()(t);
        ptr_.first() = p;
................................................................................

template<class T, class D>
inline void swap (unique_ptr<T, D>& x, unique_ptr<T, D>& y) {
    x.swap(y);
}

template<class T1, class D1, class T2, class D2>
inline bool operator==(unique_ptr<T1, D1> const& x, const unique_ptr<T2, D2>& y) {
    return x.get() == y.get();
}

template<class T1, class D1, class T2, class D2>
inline bool operator!=(unique_ptr<T1, D1> const& x, const unique_ptr<T2, D2>& y) {
    return !(x == y);
}

template<class T1, class D1, class T2, class D2>
inline bool operator<(unique_ptr<T1, D1> const& x, const unique_ptr<T2, D2>& y) {
    return x.get() < y.get();
}

template<class T1, class D1, class T2, class D2>
inline bool operator<=(unique_ptr<T1, D1> const& x, const unique_ptr<T2, D2>& y) {
    return !(y < x);
}

template<class T1, class D1, class T2, class D2>
inline bool operator>(unique_ptr<T1, D1> const& x, const unique_ptr<T2, D2>& y) {
    return y < x;
}

template<class T1, class D1, class T2, class D2>
inline bool operator>=(unique_ptr<T1, D1> const& x, const unique_ptr<T2, D2>& y) {
    return !(x < y);
}

// comparison with nullptr
template <typename T, typename D>
inline bool operator== (unique_ptr<T,D> const& up, std::nullptr_t) {
    return up.get()==nullptr;
}
template <typename T, typename D>
inline bool operator== (std::nullptr_t, unique_ptr<T,D> const& up) {
    return up.get()==nullptr;
}
template <typename T, typename D>
inline bool operator!= (unique_ptr<T,D> const& up, std::nullptr_t) {
    return !(up==nullptr);
}
template <typename T, typename D>
inline bool operator!= (std::nullptr_t, unique_ptr<T,D> const& up) {
    return !(up==nullptr);
}


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

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























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

#endif  // guard

Changes to cxxomfort/cxxomfort/iterator.hpp.

21
22
23
24
25
26
27

28
29
30
31
#include "base.hpp"
#include CXXO_INCLUDE_SYS(iterator)
#include "base/iterator.hpp"

// make_reverse_iterator
//#include 
// globals size, data, empty from C++17

#include "impl/17-iterator_access.hpp"


#endif







>
|



21
22
23
24
25
26
27
28
29
30
31
32
#include "base.hpp"
#include CXXO_INCLUDE_SYS(iterator)
#include "base/iterator.hpp"

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


#endif

Changes to cxxomfort/cxxomfort/library/array_ref.hpp.

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

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

#define CXXOMFORT_IMPLEMENTS_n3334 CXXO_IMPLSTATUS_LIBRARY()
#define CXXOMFORT_IMPLEMENTS_array_ref CXXOMFORT_IMPLEMENTS_n3334

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


namespace cxxomfort {
namespace library {
namespace array_ref {

namespace ct = cxxomfort::traits;

/**
 * @brief An object representing a reference or @e slice of a 
 * contiguous area of memory of type @e T .
 * @anchor libarrayref
 * @tparam T Type of the kind of value contained in the view.
 * @ingroup cxxo-sup 
 * 
 * A @c array_ref is a non-owning view of a sequence of 
 * *contiguous* elements via a simple {pointer+length} package. 
 * In many ways it could be considered an analogue to 
 * <code>std::array</code> except it doesn't actually hold the data 
 * (hence the name, @c array_ref ).
 * 
 * It provides some of the same operatios available for readable
 * sequences, in particular begin() and end(). Because it points to 
 * an area of memory directly, iterators are raw pointer types.
 * 
 * This implementation is intended to be used for sequences of 
 * const elements (ie.: template argument is <code>T const</code>).
 * 
 * The utility function make_array_ref() helps create 
 * array_refs from contexts where they can be needed.
 * 
 * See also: <code>std::vector</code>, @c seq_ .
 * 
 * @c array_ref is based in the original publication "n3334" by 
 * Jeffrey Yasskin; @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html 
 * 
 */
template <typename T>
class array_ref {
    public:
    //! type of the data contained in the view.
    typedef T       value_type;
    typedef typename ct::compose<T,::std::add_pointer>::type   pointer;
    typedef typename ct::compose<T,::std::add_const, ::std::add_pointer>::type const_pointer;
    typedef typename ct::compose<T,std::add_reference>::type   reference;
    typedef typename ct::compose<T,std::add_const,std::add_reference>::type const_reference;
    typedef ptrdiff_t    difference_type;
    typedef size_t       size_type;
    typedef pointer           iterator;
    typedef const_pointer const_iterator;
    typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
    
    public:
    
    CXXO_CONSTEXPR array_ref () CXXO_NOEXCEPTNOTHROW 
    #if (CXXOMFORT_CXX_STD<2011)
    : ptr_(nullptr), len_(0) {}
    #else
    = default;
    #endif
    
    CXXO_CONSTEXPR array_ref (array_ref const& p) CXXO_NOEXCEPTNOTHROW 
    #if (CXXOMFORT_CXX_STD<2011)
    : ptr_(p.ptr_), len_(p.len_) {}
    #else
    = default;
    #endif
    
    ///! Initializes this to refer to a buffer of memory pointed by @a p and of size @a l .
    CXXO_CONSTEXPR array_ref (T const* p, size_t l) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(l) {}
    
    CXXO_CONSTEXPR array_ref (std::nullptr_t, T const* p, T const* q) CXXO_NOEXCEPTNOTHROW 
    : ptr_(p), len_(static_cast<size_t>(q-p)) {}
    ///! Initialize this to refer to a C-style array.
    template <size_t N>
    explicit array_ref (T(&arr)[N]) CXXO_NOEXCEPTNOTHROW : ptr_(arr), len_(N) {}
    
    

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

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

/*    
    // view ref from vector; should be a std::array conversion operator but can't in C++03, C++11
    template <typename Alloc>
    array_ref (std::vector<T,Alloc> const& vec) 
    : ptr_(std::addressof(vec[0])), len_(vec.size()) {}
    
    // view ref from valarray; should be a std::array conversion operator but can't in C++03, C++11
    array_ref (std::valarray<T> const& va) 
    : ptr_(std::addressof(va[0])), len_(va.size()) {}

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

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

*/

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

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

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

    const_iterator  front () const { return ptr_[0]; }
    const_iterator  back () const { return ptr_[len_-1]; }
    
    array_ref       slice (size_t skip) const {
        return (skip > len_) ? array_ref() : array_ref(ptr_+skip, len_-skip);
    }
    array_ref       slice (size_t skip, size_t n) const {
        return slice(skip);
    }
    
    private:
    void check_range (size_t i) const {
        if (i>=len_) throw std::out_of_range("array_ref: out of range");
    }
    void check_range (size_t i, std::error_code& ec) const {
        if (i>=len_) ec= std::make_error_code(EDOM, std::generic_category());
    }
    
    pointer const   ptr_;
    size_t const    len_;

}; // array_ref

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

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

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

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


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

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



template <typename Ty>
array_ref<Ty> arrayref (Ty* p, size_t l) {
    return array_ref<Ty>(p,l);
}

template <typename Ty>
array_ref<Ty const> carrayref (Ty* p, size_t l) {
    return array_ref<Ty const>(p,l);
}

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

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

} } } // cxxomfort::library::array_ref


/*
 * @page cxxo:array_ref "Array view for sequences, from n3334"
 * @ingroup cxxo:library
 * 
 * Interfaces defined:
 * 
 * * @c array_ref .
 * * @c make_array_ref , @c make_array_cref . 
 * * @c is_array_ref .
 * 
 * 
**/

#endif
|
|
<
<
|
<
<
<
<
<
<
|
<
<

<
<

<
<
<
<
<
|
<
<

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

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

1
2


3






4


5


6





7


8







































































































































































9







10








11











12
13




14
15


































16
#ifndef CXXOMFORT_IMPL_ARRAY_REF_HPP
#define CXXOMFORT_IMPL_ARRAY_REF_HPP









#include <cxxomfort/impl/n3334-array_ref.hpp>











namespace cxxomfort { namespace library { 










































































































































































    using array_ref::array_ref;







    using array_ref::make_array_ref;








    using array_ref::arrayref;











    using array_ref::carrayref;





} }



































#endif

Changes to cxxomfort/cxxomfort/library/functional.hpp.

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

template <typename T> struct is_std_function : std::false_type {};
template <typename Sig> struct is_std_function< std::function<Sig> > : std::true_type {};


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

CXXO_CONSTEXPR14 const constant_function<bool> true_f (true);
CXXO_CONSTEXPR14 const constant_function<bool> false_f (false);



} // .functional:
}}



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








#endif







|









>




>

<
>
>
>

<
>



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

template <typename T> struct is_std_function : std::false_type {};
template <typename Sig> struct is_std_function< std::function<Sig> > : std::true_type {};


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

CXXO_CONSTEXPR14 const constant_function<bool> true_f (true);
CXXO_CONSTEXPR14 const constant_function<bool> false_f (false);



} // .functional:
}}

#include "../impl/functionmeta.hpp"


namespace cxxomfort { namespace library { namespace functional {
    using ::cxxomfort::impl::functiontype;
} } }


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


#endif

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

5
6
7
8
9
10
11

12
13
14
15
16
17
18
...
181
182
183
184
185
186
187















188
189
190
191
192
193
194
...
198
199
200
201
202
203
204











205
206
207
208
209
210
211
...
214
215
216
217
218
219
220












221
222
223
224
225
226
227
...
244
245
246
247
248
249
250

251
















































252

253
254
255
256
257
258
259
260
261
 *
 * This file provides supplementary features to the ones
 * present in <code><string></code> that are
 * specific to cxxomfort.
 *
 * * @c chr() , @c utf8chr()  - Conversion from integer/codepoint to character.
 * * @c codepoint() - Conversion from character to integer/codepoint.

 * * @c join() - Joins elements into a string.
 * * @c split_to() , @c split_to_n() - Split elements from a string.
 * * @c explode() - Splits elements from a string into a std::vector.
 * * @c l_trim() , @c r_trim() , @c trim()  - Removes elements from a string's ends.
 * * @c string_replace - Replace substrings in a string.
 * * @c string_pad - Pad a string to length.
 * * @c to_string() - Variadic for of to_string.
................................................................................
template <typename String, typename Separator>
std::vector<String> explode (Separator const& sep, String const& s) {
    using namespace std;
    std::vector<String> V;
    split_to (sep, s, back_inserter(V));
    return V;
}
















/**
 * @brief Trims a string removing a selected character class from the left.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 *
 */
................................................................................
    // we find L = first position in s where p(L) is false
    // we use string's erase function (or just a copy constructor)
    typename String::iterator L = find_if_not(begin(s), end(s), p);
    if (L == end(s)) return;
    s= String(L, end(s));
}













/**
 * @brief Trims a string removing a selected character class from the right.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 *
 */
................................................................................
    using namespace std;
    // we find L = last position in s where p(L) is true
    // we use string's erase function (or just a copy constructor)
    typename String::reverse_iterator L = find_if_not(s.rbegin(), s.rend(), p);
    if (L == s.rend()) return;
    s= String(s.rend().base(), L.base());
}













/** Trims a string removing characters from the left and right. **/
template <typename String, typename Pred>
void trim (String& s, Pred p) {
    l_trim(s,p);
    r_trim(s,p);
}
................................................................................
        s.insert (pos, to);
    }
    return s;

} // string_replace




















































} // string

/**
 * @}
 */

}} // cxxomfort::library



#endif







>







 







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







 







>
>
>
>
>
>
>
>
>
>
>







 







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







 







>

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

>









5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
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
...
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
...
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
...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
 *
 * This file provides supplementary features to the ones
 * present in <code><string></code> that are
 * specific to cxxomfort.
 *
 * * @c chr() , @c utf8chr()  - Conversion from integer/codepoint to character.
 * * @c codepoint() - Conversion from character to integer/codepoint.
 * * @c string_cast() - convert between string representations; overload point.
 * * @c join() - Joins elements into a string.
 * * @c split_to() , @c split_to_n() - Split elements from a string.
 * * @c explode() - Splits elements from a string into a std::vector.
 * * @c l_trim() , @c r_trim() , @c trim()  - Removes elements from a string's ends.
 * * @c string_replace - Replace substrings in a string.
 * * @c string_pad - Pad a string to length.
 * * @c to_string() - Variadic for of to_string.
................................................................................
template <typename String, typename Separator>
std::vector<String> explode (Separator const& sep, String const& s) {
    using namespace std;
    std::vector<String> V;
    split_to (sep, s, back_inserter(V));
    return V;
}

// left$, as in BASIC

template <typename String>
String left$ (String c, size_t n) {
    if (c.size() <= n) return c;
    return String(&c[0], &c[n]);
}

template <typename String>
String right$ (String c, size_t n) {
    if (c.size() <= n) return c;
    return String(c.end()-n, c.end());
}


/**
 * @brief Trims a string removing a selected character class from the left.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 *
 */
................................................................................
    // we find L = first position in s where p(L) is false
    // we use string's erase function (or just a copy constructor)
    typename String::iterator L = find_if_not(begin(s), end(s), p);
    if (L == end(s)) return;
    s= String(L, end(s));
}

template <typename String>
void l_trim (String& s, char c) {
    using namespace std;
    // we find L = first position in s where p(L) is false
    // we use string's erase function (or just a copy constructor)
    function<bool(char)> p = bind(
        equal_to<char>()
        , c, placeholders::_1
    );
    l_trim(s,p);
}

/**
 * @brief Trims a string removing a selected character class from the right.
 * @param s The string object to be modified.
 * @param p Predicate for selecting the character class.
 *
 */
................................................................................
    using namespace std;
    // we find L = last position in s where p(L) is true
    // we use string's erase function (or just a copy constructor)
    typename String::reverse_iterator L = find_if_not(s.rbegin(), s.rend(), p);
    if (L == s.rend()) return;
    s= String(s.rend().base(), L.base());
}

template <typename String>
void r_trim (String& s, char c) {
    using namespace std;
    // we find L = first position in s where p(L) is false
    // we use string's erase function (or just a copy constructor)
    function<bool(char)> p = bind(
        equal_to<char>()
        , c, placeholders::_1
    );
    r_trim(s,p);
}

/** Trims a string removing characters from the left and right. **/
template <typename String, typename Pred>
void trim (String& s, Pred p) {
    l_trim(s,p);
    r_trim(s,p);
}
................................................................................
        s.insert (pos, to);
    }
    return s;

} // string_replace


// "overload" here

template <typename T, typename F>
struct string_cast_impl {
    // naive conversion. This will more often than not not suffice.
    T operator() (F const& f) const {
        using namespace std;
        return T(begin(f), end(f));
    }
};

template <typename T>
struct string_cast_impl<T,T> {
    T operator() (T const& t) const CXXO_NOEXCEPTNOTHROW {
        return t;
    }
};

// customization point for string to wstring conversion
template<>
struct string_cast_impl<std::wstring,std::string> {
    std::wstring operator() (std::string const& s) const {
        std::wstring ws(s.size(), 0); // Overestimate number of code points.
        ws.resize(std::mbstowcs(&ws[0], s.c_str(), s.size())); // Shrink to fit.        
        return ws;
    }
};

template<>
struct string_cast_impl<std::string,std::wstring> {
    std::string operator() (std::wstring const& ws) const {
        std::string s(ws.size(), 0); // Overestimate number of code points.
        s.resize(wcstombs(&s[0], ws.c_str(), ws.size())); // Shrink to fit.        
        return s;
    }
};

/**
 * @brief Converts between string representations. Common / Customization Point.
 * @tparam To A string type to convert to.
 * @param str A string of a given string type.
 * @return A new string of type @a To which is the template argument to invoke with.
 */
template <typename To, typename FromString>
To string_cast (FromString const& str) {
    static string_cast_impl<To,FromString> const c;
    return c(str);
}


} // string

/**
 * @}
 */

}} // cxxomfort::library



#endif

Changes to cxxomfort/cxxomfort/library/tuple.hpp.

310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
...
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
 * if so, returns its index (0...N-1)
 * 
 * @tparam S = size of the tuple Tuple.
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_element2index_helper {
    enum { rec = (0 <= N && N < S) };
    typedef typename std::enable_if<rec, bool>::type still_has_arguments_t;
    enum { value = 
    (std::is_same<C, typename std::tuple_element<N,Tuple>::type>::value
    ? N : tuple_element2index_helper<C,N+1,S,Tuple>::value
    ) 
    };
};


template <typename C, size_t N, typename Tuple>
struct tuple_element2index_helper<C,N,N,Tuple> {
    enum { value = N+1 };
};
................................................................................
    
    static_assert ((va < 2), "Type (C in template) is repeated in tuple.");
    //static_assert ((va != 0), "Type (C in template) does not exist in tuple.");
    public:
    typedef typename std::conditional< (va>0) , bool, void>::type Sentinel_t;
    enum { 
        //! The value of this trait.
        value = detail::tuple_element2index_helper<C,0,std::tuple_size<T>::value,T>::value 
    };
};


/**
 * @brief Convert from tuple type to function signature.
 * @ingroup cxxo-sup-tuple







|
|
|
|
|
|







 







|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
...
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
 * if so, returns its index (0...N-1)
 * 
 * @tparam S = size of the tuple Tuple.
 */
template <typename C, size_t N, size_t S, typename Tuple>
struct tuple_element2index_helper {
    enum { rec = (0 <= N && N < S) };
    static const size_t X = tuple_element2index_helper<C,N+1,S,Tuple>::value ;
    typedef typename std::enable_if<rec, bool>::type still_has_arguments_t;
    static const size_t value = 
    (std::is_same<C, typename std::tuple_element<N,Tuple>::type>::value
    ? N : X
    ) ;
};


template <typename C, size_t N, typename Tuple>
struct tuple_element2index_helper<C,N,N,Tuple> {
    enum { value = N+1 };
};
................................................................................
    
    static_assert ((va < 2), "Type (C in template) is repeated in tuple.");
    //static_assert ((va != 0), "Type (C in template) does not exist in tuple.");
    public:
    typedef typename std::conditional< (va>0) , bool, void>::type Sentinel_t;
    enum { 
        //! The value of this trait.
        value = detail::tuple_element2index_helper<C,0UL,std::tuple_size<T>::value,T>::value 
    };
};


/**
 * @brief Convert from tuple type to function signature.
 * @ingroup cxxo-sup-tuple

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

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

/**
 * @brief Demangle a typename, recovering information about const / volatile too.
 * @ingroup cxxo-sup
 * @return A string containing a type name depending on the type @a T used to instantiate the function.
 */
template <typename T>
std::string type_name () {
    using namespace std;
    typedef typename remove_reference<T>::type TnR;
    std::string r( typeid_demangle(typeid(T)) );
#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
    #pragma warning (disable:4127) // conditional expression is constant
#endif
    if (is_const<TnR>::value) { r+= " const"; }







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

/**
 * @brief Demangle a typename, recovering information about const / volatile too.
 * @ingroup cxxo-sup
 * @return A string containing a type name depending on the type @a T used to instantiate the function.
 */
template <typename T>
std::string type_name () CXXO_NOEXCEPTNOTHROW {
    using namespace std;
    typedef typename remove_reference<T>::type TnR;
    std::string r( typeid_demangle(typeid(T)) );
#if (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
    #pragma warning (disable:4127) // conditional expression is constant
#endif
    if (is_const<TnR>::value) { r+= " const"; }

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

108
109
110
111
112
113
114

115
116
117
118
119
120
121

122


123
/*
 * integral_constant shortcuts
 * */
#include "../impl/ic_types.hpp"

// fixes for is_trivially_constructible<void>


#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_CXX_EMULATION == 2011)
namespace std {
    template <> struct is_trivially_copy_constructible<void> : std::false_type {};
    template <> struct is_trivially_move_constructible<void> : std::false_type {};
}

#endif




#endif







>





<

>

>
>

108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
/*
 * integral_constant shortcuts
 * */
#include "../impl/ic_types.hpp"

// fixes for is_trivially_constructible<void>

/*
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_CXX_EMULATION == 2011)
namespace std {
    template <> struct is_trivially_copy_constructible<void> : std::false_type {};
    template <> struct is_trivially_move_constructible<void> : std::false_type {};
}

#endif
*/



#endif

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

37
38
39
40
41
42
43

44




45











46
47
48
49

50
51
52
53


54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72
73
74
75
76
77
..
80
81
82
83
84
85
86

87
88
89
90
91
92

93
94
95
96
97
98
99
100
class typesafe_enum : public def /*, public detail_enum::safe_enum_tag */ {
    inner val;
    public: 
    typedef typename def::type enum_type;
    typedef inner underlying_type;
 
    public:

    CXXO_CONSTEXPR typesafe_enum () CXXO_NOEXCEPT {}




    CXXO_CONSTEXPR typesafe_enum (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 };
        static_assert (T_is_compatible_type, "typesafe_enum construction invalid - not the enum's tags or the underlying type");
    };*/

    bool equals (typesafe_enum const& x) const CXXO_NOEXCEPT { return val == x.val; }
    
    private:
    struct disallowed_enum_conversion {};
    // we disallow other constructors

    template <typename T> 
    typesafe_enum (T const&, 
     typename std::enable_if< 
        std::is_integral<T>::value , disallowed_enum_conversion 
        >::type * = 0 );
    

    public:
/*
    template <typename E>
    typesafe_enum (E e
    , typename std::enable_if<std::is_enum<E>::value && !std::is_same<E,enum_type>::value
    , disallowed_enum_conversion>::type* = nullptr) {
................................................................................
    }
*/

};

// equality
template<typename def, typename inner>

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

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

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

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







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




>
|
|

<
>
>






|




>





|







 







>
|





>
|







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
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class typesafe_enum : public def /*, public detail_enum::safe_enum_tag */ {
    inner val;
    public: 
    typedef typename def::type enum_type;
    typedef inner underlying_type;
 
    public:
#if (CXXOMFORT_CXX_STD < 2011)
    CXXO_CONSTEXPR typesafe_enum () CXXO_NOEXCEPTNOTHROW {}
#else
    constexpr typesafe_enum () noexcept = default;
#endif

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

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

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

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

    template <typename I>
    CXXO_CONSTEXPR CXXO_EXPLICIT_OPERATOR(I) () const CXXO_NOEXCEPTNOTHROW { return static_cast<I>(val); }

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

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

    public:
/*
    template <typename E>
    typesafe_enum (E e
    , typename std::enable_if<std::is_enum<E>::value && !std::is_same<E,enum_type>::value
    , disallowed_enum_conversion>::type* = nullptr) {
................................................................................
    }
*/

};

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

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

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

Added cxxomfort/cxxomfort/library/utility.hpp.

























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
#ifndef CXXOMFORT_LIBRARY_UTILITY_HPP
#define CXXOMFORT_LIBRARY_UTILITY_HPP
/**
 * @file
 * 
 * Interfaces defined in this file:
 * 
 * 
 * */
#include <cxxomfort/type_traits.hpp>
#include <cxxomfort/utility.hpp> // pair


namespace cxxomfort { namespace library { 
namespace utility {

//
// integral_of_size
//

template <size_t S> struct integral_of_size { 
    static const bool value = false; 
    typedef void type; 
};

// sizeof(char)==1 is guaranteed by the Standard

template <> struct integral_of_size<sizeof(int8_t)> { 
    static const bool value= true;
    typedef int8_t type; 
};
template <> struct integral_of_size<sizeof(int16_t)> { 
    static const bool value= true;
    typedef int16_t type; 
};
template <> struct integral_of_size<sizeof(int32_t)> { 
    static const bool value= true;
    typedef int32_t type; 
};
template <> struct integral_of_size<sizeof(int64_t)> { 
    static const bool value= true;
    typedef int64_t type; 
};

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

template <typename T>
CXXO_CONSTEXPR std::in_place_type_t<T> v_in_place_type () CXXO_NOEXCEPTNOTHROW {
    return std::in_place_type_t<T>();
}

template <size_t I>
CXXO_CONSTEXPR std::in_place_index_t<I> v_in_place_index () CXXO_NOEXCEPTNOTHROW {
    return std::in_place_index_t<I>();
}





//
// strict_type
//

template <typename T>
struct strict_type {
    explicit strict_type (T const& a) : t(a) {}
    CXXO_EXPLICIT_OPERATOR(T) () const CXXO_NOEXCEPT { return t; }
    T t;
};


//
// generic "none" type
// a "none" type not only denotes no type things, but can also be 
// converted to eg.: nullptr_t or nullopt_t in contexts that need it
//

const struct none_t {
    CXXO_CONSTEXPR operator std::nullptr_t () const CXXO_NOEXCEPTNOTHROW { return nullptr; }
} none = {};



}
}}

#endif

Changes to cxxomfort/cxxomfort/memory.hpp.

15
16
17
18
19
20
21

22
23
24
25
26
27
28
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
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
 * See also: 
 * <a href="https://en.cppreference.com/w/cpp/header/memory">\<memory\> \@cppreference</a>.
 * 
 */

#include "config.hpp"
#include "base/alignof.hpp"


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


/* alignas, aligned_storage */
................................................................................
    #pragma message CXXO_NOTICE("memtools support.")
    #endif
#endif // c++11


#if defined(CXXOMFORT_USING_MEMTOOLS)

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

// We define alignas, alignof depending on compiler specifics
#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC)
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_CLANG)
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
#else // unrecognized compiler, we can't go any further
    // take a safe bet
................................................................................


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

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



#else
#include <memory>









namespace cxxomfort {
    //using std::addressof;
    using std::uninitialized_copy_n;
    using std::aligned_storage;











}







#endif // c++03/11


#include "impl/14-make_unique.hpp"
#include "impl/17-destroy_at.hpp"


#endif // file







>







 







<
<
<







 







|

>

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

>




<
<



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
66
67
68
69
70
71
72



73
74
75
76
77
78
79
...
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
 * See also: 
 * <a href="https://en.cppreference.com/w/cpp/header/memory">\<memory\> \@cppreference</a>.
 * 
 */

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

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


/* alignas, aligned_storage */
................................................................................
    #pragma message CXXO_NOTICE("memtools support.")
    #endif
#endif // c++11


#if defined(CXXOMFORT_USING_MEMTOOLS)




// We define alignas, alignof depending on compiler specifics
#if 0
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_GCC)
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_CLANG)
#elif (CXXOMFORT_COMPILER_ID == CXXO_COMPILERID_MSC)
#else // unrecognized compiler, we can't go any further
    // take a safe bet
................................................................................


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

#include "impl/14-make_unique.hpp"

#include "impl/17-destroy_at.hpp"


// -- set up needed things in std::
#if (CXXOMFORT_CXX_STD < 2011)
    #if (!defined(CXXOMFORT_NO_TR1) && !defined(NO_TR1))
//
// specialize std::tr1::hash for unique_ptr<>
// (this is allowed)
// define either NO_TR1 or CXXOMFORT_NO_TR1 to disable 
// using this TR1 extension in C++03
//
#include <functional> // std::hash, from Tr1
namespace std { namespace tr1 {



    template <typename T, typename D>
    struct hash< unique_ptr<T,D> > 
    : private hash< typename unique_ptr<T,D>::pointer > {
        private:
        typedef hash< typename unique_ptr<T,D>::pointer > base_type;
        public:
        typedef unique_ptr<T,D> argument_type;
        typedef size_t result_type;
        size_t operator() (argument_type const& t) const {
            //return static_cast<base_type>(*this).operator()(t.get());
            return static_cast<base_type const*>(this)->operator()(t.get());
        }
    };
} /* tr1 */ }
    #endif
#endif

#else

#endif // c++03/11






#endif // file

Changes to cxxomfort/cxxomfort/string.hpp.

8
9
10
11
12
13
14


15
16
17
18
19
20

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




34





















35



 * 
 * * @c to_string() (C++11)
 * * @c strtoll() , @c strtoull() function family (C++11)
 * 
 * Future / potential interfaces:
 * 
 * * @c string user-defined literal


 *
 */



#include "base.hpp"


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

namespace cxxomfort {
namespace cxxostd {
}
}

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



























#endif










>
>






>













>
>
>
>

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

>
>
>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 * 
 * * @c to_string() (C++11)
 * * @c strtoll() , @c strtoull() function family (C++11)
 * 
 * Future / potential interfaces:
 * 
 * * @c string user-defined literal
 * 
 * @see https://en.cppreference.com/w/cpp/header/string
 *
 */



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

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

namespace cxxomfort {
namespace cxxostd {
}
}

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

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

    template<typename Char> 
    struct hash< ::std::basic_string<Char> > {
        typedef ::std::basic_string<Char> argument_type;
        typedef size_t result_type;
        result_type operator()(argument_type const& s) const CXXO_NOEXCEPTNOTHROW   {
            using namespace std;
            size_t const MS = (sizeof(size_t) - sizeof(Char) + 1) * CHAR_BIT;
            size_t r= s.length();
            size_t wi= 1;
            cout<< "[hash<basic_string> MS="<< MS<< " for string of size:"<< r<< "]"<< flush;
            for ( size_t i= 0; i < s.length(); ++i, wi<<=1 ) {
                r ^= (static_cast<size_t>(s[i]) * wi);
                if (wi<<2 > MS ) { wi= 1; }
            }
            cout<< "[hash::return "<< r<< "]"<< flush;
            return r;
        }    
    };
    
}
    #endif // gcc
#endif


#endif

Changes to cxxomfort/cxxomfort/type_traits.hpp.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
165
166
167
168
169
170
171




172




173
174
175
176
177
178
179
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
...
421
422
423
424
425
426
427
428

429






430
431
432
433
434
435
436
...
444
445
446
447
448
449
450

451
452
453
454
455
456
457
458
459
460
461
462


463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
 * * #bool_constant  (C++17)
 * 
 */

#include "config.hpp"
#include "base.hpp"

#ifdef CXXOFLAG_CXXHEADERS
    #include_next <type_traits>
#else

#if (CXXOMFORT_CXX_STD>=2011)
    #include CXXO_INCLUDE_SYS(type_traits)
#else
    // we need to find a <type_traits> header. In GCC,
    // we depend on a wrapper like tr1_fwd set up to enable us
    // to directly include the header
    #if (defined(__GNUC__))
        #include_next <type_traits>
    #else
        #include CXXO_INCLUDE_SYS(type_traits)
    #endif
#endif
#endif

#include "impl/11-conditional.hpp"
#include "util/type_traits.hpp"
#include "util/meta.hpp" // enable_if etc

#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
#pragma message CXXO_NOTICE("enabled <type_traits> support.")
................................................................................
}
#endif
#undef CXXO_MIRROR_LVALUE_REFERENCE


#include "impl/11-decay.hpp"
#include "impl/11-underlying_type.hpp"
#include "util/traits_ct.hpp"


/*
 * Triviality / Throwness traits
 * (is_trivially_..., is_nothrow_...)
 *
 */
................................................................................
#include "impl/20-endian.hpp"


//
// is_trivially_... missing in GCC 4.7 despite announcing C++11 mode
//

#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_COMPILER_VERSION==407 && CXXOMFORT_CXX_EMULATION==2011)
namespace std {
    template <typename T> struct is_trivially_default_constructible
    : integral_constant<bool, __has_trivial_constructor(T)> {};

    template <typename T> struct is_trivially_copy_constructible
    : integral_constant<bool, __has_trivial_copy(T)> {};

................................................................................
    : integral_constant<bool, __has_trivial_assign(T)> {};

    template <typename T> struct is_trivially_destructible
    : integral_constant<bool, __has_trivial_destructor(T)> {};

}
#endif











#if 0 // -- is_constructible
//
// "variadic" is_constructible, is_assignable implementation
//

................................................................................
#endif // -- is_constructible


/*
 * is_null_pointer (was added in C++14)
 */
#if ( (CXXOMFORT_CXX_STD < 2014) )
    #define CXXO_enable_is_null_pointer
#endif
#if (defined(CXXO_enable_is_null_pointer) && CXXOMFORT_CXX_STD == 2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    #undef CXXO_enable_is_null_pointer
#endif
#if (defined(CXXO_enable_is_null_pointer) && CXXOMFORT_CXX_EMULATION == 2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    #undef CXXO_enable_is_null_pointer
#endif

#if (defined(CXXO_enable_is_null_pointer))
namespace std {
    using ::cxxomfort::traits::is_null_pointer;
}
#endif


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

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_CXX_EMULATION==2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && CXXOMFORT_COMPILER_VERSION >= 1600)
    #else
        #define CXXO_enable_move_constructible
    #endif
#else
    // Even in C++11, *_move_constructible is missing in some compilers
    #if (CXXOMFORT_CXX_STD==2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG && CXXOMFORT_COMPILER_VERSION<=304) \
    || (CXXOMFORT_CXX_EMULATION==2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC && CXXOMFORT_COMPILER_VERSION<=408)
        #define CXXO_enable_move_constructible
    #endif
#endif

#if defined(CXXO_enable_move_constructible)
namespace std {
    template <typename T>
    struct is_trivially_move_constructible
    : std::is_scalar<T> {};

}
#endif

#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011) \
|| CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, <= 1610)
namespace std {
    template <typename T>
    struct is_nothrow_move_constructible
    : std::is_scalar<T> {};

}
#endif

// is_destructible
#if (CXXOMFORT_CXX_STD >= 2011) \
|| CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1700)
#else
namespace std {

................................................................................
    : integral_constant<bool, is_pod<T>::value || is_class<T>::value && !is_void<T>::value > {
    };

}
#endif

// is_standard_layout
#if (CXXOMFORT_CXX_STD < 2011) \

&& !(CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1600))






namespace std {

    template <typename T>
    struct is_standard_layout
    : integral_constant<bool,
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
        #if (CXXOMFORT_COMPILER_VERSION>=1600)
................................................................................
        is_scalar<T>::value
    #endif

    > {
    };

}

#endif

// is_final

#if (CXXOMFORT_CXX_STD < 2014)
namespace std {
    template <typename T>
    struct is_final
    : integral_constant<bool,
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
        false
    #elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)


        __is_final(T)
    #else
        false
    #endif

    > {
    };
} // namespace
#endif

/*
 * is_move_constructible
 */
#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011) \
|| CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,<=1600)

namespace std {
    template <typename T>
    struct is_move_constructible
    : std::integral_constant<bool,
        is_scalar<T>::value && !(is_same<T,void>::value)
    > {};

}
#endif

#endif // #include guard







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







 







|







 







|







 







>
>
>
>
|
>
>
>
>







 







|

|
|

|
|


|






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







 







|
>
|
>
>
>
>
>
>







 







>









|

|
>
>








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



18
19
20
21
22
23
24







25
26
27

28





29
30
31
32
33
34
35
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371



































372
373
374
375
376
377
378
...
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
...
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
















441
442
443
 * * #bool_constant  (C++17)
 * 
 */

#include "config.hpp"
#include "base.hpp"








// we need to find a <type_traits> header. In GCC,
// we depend on a wrapper like tr1_fwd set up to enable us
// to directly include the header

#include <type_traits>






#include "impl/11-conditional.hpp"
#include "util/type_traits.hpp"
#include "util/meta.hpp" // enable_if etc

#if (defined(CXXOMFORT_NOTICES) && (CXXOMFORT_NOTICES > 1))
#pragma message CXXO_NOTICE("enabled <type_traits> support.")
................................................................................
}
#endif
#undef CXXO_MIRROR_LVALUE_REFERENCE


#include "impl/11-decay.hpp"
#include "impl/11-underlying_type.hpp"
#include "impl/11-common_type.hpp"


/*
 * Triviality / Throwness traits
 * (is_trivially_..., is_nothrow_...)
 *
 */
................................................................................
#include "impl/20-endian.hpp"


//
// is_trivially_... missing in GCC 4.7 despite announcing C++11 mode
//

#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC , < 407) && CXXOMFORT_CXX_EMULATION==2011)
namespace std {
    template <typename T> struct is_trivially_default_constructible
    : integral_constant<bool, __has_trivial_constructor(T)> {};

    template <typename T> struct is_trivially_copy_constructible
    : integral_constant<bool, __has_trivial_copy(T)> {};

................................................................................
    : integral_constant<bool, __has_trivial_assign(T)> {};

    template <typename T> struct is_trivially_destructible
    : integral_constant<bool, __has_trivial_destructor(T)> {};

}
#endif
#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC , == 407) && CXXOMFORT_CXX_EMULATION==2011)
namespace std {
    template <typename T> struct is_trivially_destructible
    : integral_constant<bool, __has_trivial_destructor(T)> {};
}
#endif    

// is_...._move_constructible - for C++03
#include "impl/11-move_traits.hpp"


#if 0 // -- is_constructible
//
// "variadic" is_constructible, is_assignable implementation
//

................................................................................
#endif // -- is_constructible


/*
 * is_null_pointer (was added in C++14)
 */
#if ( (CXXOMFORT_CXX_STD < 2014) )
    #define CXXO_needs_is_null_pointer
#endif
#if (defined(CXXO_needs_is_null_pointer) && CXXOMFORT_CXX_STD == 2011 && CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_CLANG)
    #undef CXXO_needs_is_null_pointer
#endif
#if (defined(CXXO_needs_is_null_pointer) && CXXOMFORT_CXX_EMULATION == 2011 && CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, >=500 ))
    #undef CXXO_needs_is_null_pointer
#endif

#if (defined(CXXO_needs_is_null_pointer))
namespace std {
    using ::cxxomfort::traits::is_null_pointer;
}
#endif






































// is_destructible
#if (CXXOMFORT_CXX_STD >= 2011) \
|| CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,>=1700)
#else
namespace std {

................................................................................
    : integral_constant<bool, is_pod<T>::value || is_class<T>::value && !is_void<T>::value > {
    };

}
#endif

// is_standard_layout
#if (CXXOMFORT_CXX_STD < 2011) 
    #if \
    (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC,<1600)) || \
    (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC,>0) && 0==CXXOMFORT_CXX_EMULATION)
        #define CXXO_needs_standard_layout
    #endif
#endif

#ifdef CXXO_needs_standard_layout
namespace std {

    template <typename T>
    struct is_standard_layout
    : integral_constant<bool,
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC)
        #if (CXXOMFORT_COMPILER_VERSION>=1600)
................................................................................
        is_scalar<T>::value
    #endif

    > {
    };

}
    #undef CXXO_needs_standard_layout
#endif

// is_final

#if (CXXOMFORT_CXX_STD < 2014)
namespace std {
    template <typename T>
    struct is_final
    : integral_constant<bool,
    #if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, > 0))
        false
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, >= 600))
        __is_final(T)
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_CLANG, >= 300))
        __is_final(T)
    #else
        false
    #endif

    > {
    };
} // namespace
















#endif

#endif // #include guard

Added cxxomfort/cxxomfort/typeindex.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
#ifndef CXXOMFORT_TYPE_INDEX_HPP
#define CXXOMFORT_TYPE_INDEX_HPP
/**
 * @file
 * @brief Implementations and backports tied to Standard Header <code><typeindex></code>.
 * 
 * Interfaces defined in this file:
 * 
 * * @c std::type_index (C++11)
 * * @c std::hash<std::type_index> (C++11)
 *
 * @see https://en.cppreference.com/w/cpp/header/typeindex
 * 
 */

#include "config.hpp"
#include "base.hpp"   // move, forward

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

#if (CXXOMFORT_CXX_STD >= 2011)
    #include <typeindex>
#else
namespace std {
    using ::cxxomfort::cxxostd::type_index;
}
#endif

#include <functional> // hash

#if (CXXOMFORT_CXX_STD < 2011)
namespace std {
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    namespace tr1 {
    #endif
    
    template<>
    struct hash< type_index > {
        typedef type_index argument_type;
        typedef size_t result_type;
        result_type operator()(argument_type const& s) const CXXO_NOEXCEPTNOTHROW   {
            //cout<< "[hash<type_index> for "<< s.name()<< "]"<< flush;
            return s.hash_code();
        }    
    };
    
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
    } // tr1
    #endif

}
#endif

#endif

Changes to cxxomfort/cxxomfort/util/memtraits.hpp.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
131
132
133
134
135
136
137


138
139
140
141
142
143
144
...
152
153
154
155
156
157
158


159
160
161
162
163
164
165
166
167

168
169
170
171
172
173



174
175





176






177












178
179
180
181
182









183
184
185
186
187
188
189
190
191


192
193


194
195
196
197
198
199
200
201
202
203
204

205
206
207
208
209
 * interfaces in C++03 as a way to provide uniform access to 
 * allocator functionality when using this library to implement 
 * eg.: container functionality.
 * 
 */

#include "../config.hpp"

#include <cstddef>
#include <memory>
#include <utility> // forward, move in c++11
#include "../base/move.hpp"

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup StandardFeatures
 * @brief API to refer to properties of pointer types
................................................................................
    typedef typename Alloc::value_type      value_type;
    //typedef typename Alloc::pointer         pointer;
    typedef typename detail::has_pointer_types<Alloc>::pointer pointer;
// pointer 	Alloc::pointer if present, otherwise value_type*
    typedef typename detail::has_pointer_types<Alloc>::const_pointer const_pointer;
    //typedef typename Alloc::const_pointer   const_pointer;
//const_pointer 	Alloc::const_pointer if present, otherwise std::pointer_traits<pointer>::rebind<const value_type>


    
    //typedef typename Alloc::void_pointer  void_pointer;
    typedef typename pointer_traits<pointer>::template rebind<void>::other void_pointer;
    //typedef typename detail::has_voidpointer_types<Alloc>::void_pointer void_pointer;
//void_pointer 	Alloc::void_pointer if present, otherwise std::pointer_traits<pointer>::rebind<void>
    typedef typename pointer_traits<pointer>::template rebind<void const>::other const_void_pointer;
    //typedef typename Alloc::const_void_pointer   const_void_pointer;
................................................................................
//propagate_on_container_copy_assignment 	Alloc::propagate_on_container_copy_assignment if present, otherwise std::false_type
//propagate_on_container_move_assignment 	Alloc::propagate_on_container_move_assignment if present, otherwise std::false_type
//propagate_on_container_swap 	Alloc::propagate_on_container_swap if present, otherwise 

    template <typename T>
    struct rebind_alloc { typedef typename Alloc::template rebind<T>::other type;  };
    


    static pointer allocate (Alloc &a, size_type n) { return a.allocate(n); }
    static pointer allocate (Alloc &a, size_type n, const void* hint) { return a.allocate(n,hint); }
    static void    deallocate (Alloc &a, pointer p, size_type n) { a.deallocate(p,n); }
    template <typename T>
    static void construct (Alloc &a, T* p) { 
        //a.construct(p); 
        (void)a;
        ::new (static_cast<void*>(p)) T;
        }

    template <typename T>
    static void construct (Alloc &a, T* p, CXXO_RV_REF(T) m) { 
        //a.construct(p,std::forward<T>(m)); 
        (void)a;
        ::new (static_cast<void*>(p)) T (std::move(m));
    }



    template <typename T, typename Arg1>
    static void construct (Alloc& a, T* p, Arg1 x1) { a.construct(p,x1); }





    template <typename T, typename Arg1, typename Arg2>






    static void construct (Alloc& a, T* p, Arg1 x1, Arg2 x2) { a.construct(p,x1,x2); }












    template <typename T>
    static void destroy (Alloc &a, T* p) { a.destroy(p); }
    static size_t max_size (Alloc const& a)  { return a.max_size(); }

};










}
}

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_CXX_EMULATION < 2011)
        #define CXXO_USE_memtraits 1
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, <= 1600) )
        #define CXXO_USE_memtraits 1


    #endif
#endif


#ifdef CXXO_USE_memtraits
    
namespace std {
    using ::cxxomfort::cxxostd::pointer_traits;
    using ::cxxomfort::cxxostd::allocator_traits;
/**
 * @class std::pointer_traits
 * @ingroup StandardFeatures
 * @brief Backport of C++11's pointer_traits API (using @c cxxomfort::pointer_traits ).
 */
}

#endif


#endif








|



|







 







>
>







 







>
>









>






>
>
>

|
>
>
>
>
>

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





>
>
>
>
>
>
>
>
>






|

|
>
>


>
>
|










>





7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
 * interfaces in C++03 as a way to provide uniform access to 
 * allocator functionality when using this library to implement 
 * eg.: container functionality.
 * 
 */

#include "../config.hpp"
#include "../base.hpp"
#include <cstddef>
#include <memory>
#include <utility> // forward, move in c++11
#include "../impl/11-addressof.hpp"

namespace cxxomfort {
namespace cxxostd {

/**
 * @ingroup StandardFeatures
 * @brief API to refer to properties of pointer types
................................................................................
    typedef typename Alloc::value_type      value_type;
    //typedef typename Alloc::pointer         pointer;
    typedef typename detail::has_pointer_types<Alloc>::pointer pointer;
// pointer 	Alloc::pointer if present, otherwise value_type*
    typedef typename detail::has_pointer_types<Alloc>::const_pointer const_pointer;
    //typedef typename Alloc::const_pointer   const_pointer;
//const_pointer 	Alloc::const_pointer if present, otherwise std::pointer_traits<pointer>::rebind<const value_type>
    typedef value_type& reference;
    typedef value_type const& const_reference;
    
    //typedef typename Alloc::void_pointer  void_pointer;
    typedef typename pointer_traits<pointer>::template rebind<void>::other void_pointer;
    //typedef typename detail::has_voidpointer_types<Alloc>::void_pointer void_pointer;
//void_pointer 	Alloc::void_pointer if present, otherwise std::pointer_traits<pointer>::rebind<void>
    typedef typename pointer_traits<pointer>::template rebind<void const>::other const_void_pointer;
    //typedef typename Alloc::const_void_pointer   const_void_pointer;
................................................................................
//propagate_on_container_copy_assignment 	Alloc::propagate_on_container_copy_assignment if present, otherwise std::false_type
//propagate_on_container_move_assignment 	Alloc::propagate_on_container_move_assignment if present, otherwise std::false_type
//propagate_on_container_swap 	Alloc::propagate_on_container_swap if present, otherwise 

    template <typename T>
    struct rebind_alloc { typedef typename Alloc::template rebind<T>::other type;  };
    
    pointer address (reference x ) const { return std::addressof(x); }
    const_pointer address (const_reference x) const { return std::addressof(x); }
    static pointer allocate (Alloc &a, size_type n) { return a.allocate(n); }
    static pointer allocate (Alloc &a, size_type n, const void* hint) { return a.allocate(n,hint); }
    static void    deallocate (Alloc &a, pointer p, size_type n) { a.deallocate(p,n); }
    template <typename T>
    static void construct (Alloc &a, T* p) { 
        //a.construct(p); 
        (void)a;
        ::new (static_cast<void*>(p)) T;
        }
/*
    template <typename T>
    static void construct (Alloc &a, T* p, CXXO_RV_REF(T) m) { 
        //a.construct(p,std::forward<T>(m)); 
        (void)a;
        ::new (static_cast<void*>(p)) T (std::move(m));
    }
*/
	// c++03 allocators don't have a concept of "emplace", 
	// so at most we can construct object by copy here
    template <typename T, typename Arg1>
    static void construct (Alloc& a, T* p, CXXO_FWD_REF(Arg1) x1) { 
        //a.construct(p,x1); 
        (void)a;
        ::new((void *)p) T( std::forward<Arg1>(x1) );
        //a.construct(p, std::forward<T> ( T(x1) ));
    }
    template <typename T, typename Arg1, typename Arg2>
    static void construct (Alloc& a, T* p, CXXO_FWD_REF(Arg1) x1, CXXO_FWD_REF(Arg2) x2) { 
        using std::forward;
        /*a.construct*/
        ::new((void *)p) T(p,forward<Arg1>(x1), forward<Arg2>(x2) ); 
    }
    template <typename T, typename Arg1, typename Arg2, typename Arg3>
    static void construct (Alloc& a, T* p, Arg1 x1, Arg2 x2, Arg3 x3) { 
        a.construct(p,x1,x2,x3); 
    }
    template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
    static void construct (Alloc& a, T* p, Arg1 x1, Arg2 x2, Arg3 x3, Arg4 x4) { 
        a.construct(p,x1,x2,x3,x4); 
    }
    template <typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
    static void construct (Alloc& a, T* p, Arg1 x1, Arg2 x2, Arg3 x3, Arg4 x4, Arg5 x5) { 
        a.construct(p,x1,x2,x3,x4,x5); 
    }


    template <typename T>
    static void destroy (Alloc &a, T* p) { a.destroy(p); }
    static size_t max_size (Alloc const& a)  { return a.max_size(); }

};

// specialization of std::allocator_traits < std::allocator< T > > 
// that adds emplace construction

//template <typename T>
//struct allocator_traits <std::allocator<T> >{
//
//};


}
}

#if (CXXOMFORT_CXX_STD < 2011)
    #if (CXXOMFORT_CXX_EMULATION < 2011)
        #define CXXO_needs_memtraits 1
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, <= 1600) )
        #define CXXO_needs_memtraits 1
    #elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, <= 408) )
        #define CXXO_needs_memtraits 1
    #endif
#endif


#ifdef CXXO_needs_memtraits
    
namespace std {
    using ::cxxomfort::cxxostd::pointer_traits;
    using ::cxxomfort::cxxostd::allocator_traits;
/**
 * @class std::pointer_traits
 * @ingroup StandardFeatures
 * @brief Backport of C++11's pointer_traits API (using @c cxxomfort::pointer_traits ).
 */
}
    #undef CXXO_needs_memtraits
#endif


#endif

Deleted cxxomfort/cxxomfort/util/traits_ct.hpp.

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

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

#include "../util/type_traits.hpp"
#include <type_traits>
#include <ciso646>

#if (CXXOMFORT_CXX_STD >= 2011)
    // only do something if the specific compiler lacks std::common_type
#else // c++03
    #define CXXO_IMPLEMENT_COMMON_TYPE 1

    
    #if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && (CXXOMFORT_COMPILER_VERSION>=1600 && CXXOMFORT_COMPILER_VERSION<=1800) )
        // MSVC 2010 already implements common_type, albeit broken; nothing we can do
        #undef CXXO_IMPLEMENT_COMMON_TYPE
    #elif (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC)
        // GCC ships common_type in "emulation" mode from 4.4 onwards
        #if (CXXOMFORT_COMPILER_VERSION >= 404 && CXXOMFORT_CXX_EMULATION==2011)
            #undef CXXO_IMPLEMENT_COMMON_TYPE
        #endif
    #else
        // unrecognized compiler
    
    #endif

#endif // CXXOMFORT_CXX_STD


#if defined(CXXO_IMPLEMENT_COMMON_TYPE) // _IMPLEMENT_
/*
 * Unlike other utilities, common_type has to be implemented in namespace std 
 * because clients have to be able to specialize.
 * 
 * The only way around it would be to either hack MSVC 2010's <utility> 
 * or replacing the header whole via a cstd/cxx11/utility transparent header.
 * 
 * A cxxomfort::common_type_2 could be offered as an alternative.
 * 
 */
namespace std {

#if (0 && CXXO_COMPILER_SUPPORT_variadic==1) // VARIADIC

#else

template <
 typename T1, typename T2=void, typename T3=void, typename T4=void, typename T5=void
 , typename T6=void, typename T7=void, typename T8=void, typename T9=void, typename TA=void>
struct common_type
 : public common_type <T1, typename common_type<T2,T3,T4,T5,T6,T7,T8,T9,TA>::type >
 {};

// one arg - not exactly identity
template <typename T>
struct common_type<T> { typedef typename std::decay<T>::type type; };

//
// two args - here is where the real work is done
// if we have __typeof__, we can use that
// if not but we have is_convertible, we can try to use that
// if we don't even have that, we can use a promotion chain
//


// two args - unequal case
#if (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_GCC || CXXO_COMPILER_SUPPORT_typeof==1)

template <typename T1, typename T2> struct common_type<T1,T2> {
	private:
	template <typename Q> static typename std::add_lvalue_reference<Q>::type dv ();
	public:
	typedef  typename common_type< __typeof__ (true ? dv<T1>() : dv<T2>() ) >::type type;
};
    

#else
// (decltype/__typeof__ not available)
// (we can try and solve some cases via eg.: is_convertible)

template <typename T1, typename T2> struct common_type <T1,T2> {
	private:
	struct common_type_cant_resolve; 
	template <typename Q> static typename std::add_lvalue_reference<Q>::type dv ();
	enum { 
		samey = is_same<T1,T2>::value, 
		convertible_12 = std::tr1::is_convertible<T1,T2>::value ,
		convertible_21 = std::tr1::is_convertible<T2,T1>::value
	};
	static_assert (convertible_12 or convertible_21, "cxxomfort: common_type<...> instantiation can not resolve");
	typedef std::conditional< 
		convertible_12, 
		T2, 
		typename std::enable_if<convertible_21, T1>::type
		> convto_t;
	
	public:
	typedef typename std::decay<typename convto_t::type>::type type;
	
};

// we specialize promotion pairs 
// that define common_type<T1,T2> -> type = T2
#define DEF_COMFORT_COMMONTYPE_PROMOTE(T1,T2) \
template <> struct common_type<T1,T2>: common_type<T2> {}; \
template <> struct common_type<T2,T1>: common_type<T2> {} 

    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,int) ;
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,long) ;
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,long long) ;
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(bool,unsigned long long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(signed char,short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(signed char,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(signed char,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned char,unsigned short);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned char,unsigned int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned char,unsigned long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(short,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(short,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(short,long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,unsigned int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,unsigned long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,unsigned long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned short,long long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(int,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(int,long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,unsigned long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,unsigned long long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,int);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,long);
    DEF_COMFORT_COMMONTYPE_PROMOTE(unsigned int,long long);

    DEF_COMFORT_COMMONTYPE_PROMOTE(float,double);
    DEF_COMFORT_COMMONTYPE_PROMOTE(float,long double);
    DEF_COMFORT_COMMONTYPE_PROMOTE(double,long double);

    //DEF_COMFORT_COMMONTYPE_PROMOTE(char const*, std::string);
    //DEF_COMFORT_COMMONTYPE_PROMOTE(wchar const*, std::wstring);

#undef DEF_COMFORT_COMMONTYPE_PROMOTE
// end compiler w/o typeof
    
#endif // common_case<T1,T2> resolver


// three args

template <typename T1, typename T2, typename T3>
struct common_type<T1,T2,T3>
 : public common_type< typename common_type<T1,T2>::type, T3 >
 {};


// four args

template <typename T1, typename T2, typename T3, typename T4>
struct common_type<T1,T2,T3,T4>
 : public common_type< typename common_type<T1,T2,T3>::type, T4 >
 {};


// five args

template <typename T1, typename T2, typename T3, typename T4, typename T5>
struct common_type<T1,T2,T3,T4,T5>
 : public common_type< typename common_type<T1,T2,T3,T4>::type, T5 >
 {};

// six args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
struct common_type<T1,T2,T3,T4,T5,T6>
 : public common_type< typename common_type<T1,T2,T3,T4,T5>::type, T6 >
 {};

// seven args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
struct common_type<T1,T2,T3,T4,T5,T6,T7>
 : public common_type< typename common_type<T1,T2,T3,T4,T5,T6>::type, T7 >
 {};

// eight args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
struct common_type<T1,T2,T3,T4,T5,T6,T7,T8>
 : public common_type< typename common_type<T1,T2,T3,T4,T5,T6,T7>::type, T8 >
 {};

// nine args

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
struct common_type<T1,T2,T3,T4,T5,T6,T7,T8,T9>
 : public common_type< typename common_type<T1,T2,T3,T4,T5,T6,T7,T8>::type, T9 >
 {};

#endif // VARIADIC

// two args - equal case
template <typename T>
struct common_type<T,T>
 : common_type<T> 
 {};


}    // namespace std
#endif // _IMPLEMENT_

#if defined(DOXYGEN_DOC)

/**
 * @struct common_type
 * @brief Calculates the common type between two types.
 * @ingroup cxx11-backports
 * @xrefitem std:type_traits "<type_traits>" ""
 * 
**/
template <typename... Types>
struct common_type {
    typedef _implementation_defined_ type;
};

#endif

#endif


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






































































































































































































































































































































































































































































































Changes to cxxomfort/cxxomfort/util/traits_tn.hpp.

184
185
186
187
188
189
190








191
192
193
194
195
196

197
198


199
200
201
202
203
204
205
...
217
218
219
220
221
222
223
224




225
226




227
228
229
230
231
232
233
...
235
236
237
238
239
240
241
242
243

244
    struct is_nothrow_destructible
    : cxxomfort::traits::integral_constant<bool, __has_trivial_destructor(T)> {};

}
#undef CXXO_enable_is_nothrow
#endif // cxx11










//
// is_default_constructible (for c++03)
// we approximate it by using the trivially and nothrow traits
//


#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011) \
&& (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, <= 407))


namespace std {
    template <typename T>
    struct is_default_constructible
    : std::integral_constant<bool, is_trivially_default_constructible<T>::value || is_nothrow_default_constructible<T>::value>
    {};

} // std::
................................................................................
#endif


//
// is_copy_constructible (for c++03)
// is_copy_assignable (for c++03)
//
#if (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011)




#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, > 0)) \
 || (CXXOMFORT_COMPILER_ID==CXXO_COMPILERID_MSC && CXXOMFORT_COMPILER_VERSION < 1700)




namespace std {
    // pending: use is_convertible as an assist
    template <typename T>
    struct is_copy_constructible
    : std::integral_constant<bool, is_trivially_copy_constructible<T>::value || is_nothrow_copy_constructible<T>::value > 
    {};

................................................................................
    template <typename T>
    struct is_copy_assignable
    : cxxomfort::traits::integral_constant<bool, is_trivially_copy_assignable<T>::value || is_nothrow_copy_assignable<T>::value > 
    {};

} // std::
#endif
#endif


#endif // HEADER GUARD







>
>
>
>
>
>
>
>






>
|
<
>
>







 







|
>
>
>
>
|
<
>
>
>
>







 







<

>

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
...
227
228
229
230
231
232
233
234
235
236
237
238
239

240
241
242
243
244
245
246
247
248
249
250
...
252
253
254
255
256
257
258

259
260
261
    struct is_nothrow_destructible
    : cxxomfort::traits::integral_constant<bool, __has_trivial_destructor(T)> {};

}
#undef CXXO_enable_is_nothrow
#endif // cxx11

// GCC 4.7 misses some nothrow traits despite announcing C++11 mode
#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC , == 407) && CXXOMFORT_CXX_EMULATION==2011)
namespace std {
    template <typename T>
    struct is_nothrow_destructible
    : cxxomfort::traits::integral_constant<bool, __has_trivial_destructor(T)> {};
}
#endif

//
// is_default_constructible (for c++03)
// we approximate it by using the trivially and nothrow traits
//

#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, > 0)) && ( \
 (CXXOMFORT_CXX_STD < 2011 && CXXOMFORT_CXX_EMULATION < 2011) \

 || (CXXOMFORT_CXX_EMULATION==2011 && CXXOMFORT_COMPILER_VERSION < 407) \
 )
namespace std {
    template <typename T>
    struct is_default_constructible
    : std::integral_constant<bool, is_trivially_default_constructible<T>::value || is_nothrow_default_constructible<T>::value>
    {};

} // std::
................................................................................
#endif


//
// is_copy_constructible (for c++03)
// is_copy_assignable (for c++03)
//
#if (CXXOMFORT_CXX_STD < 2011)
    #define CXXO_needs_copy_constructible
#endif
#if (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_GCC, >= 500) && 2011==CXXOMFORT_CXX_EMULATION)
    #undef CXXO_needs_copy_constructible
#elif (CXXO_COMPILERVERSION_COMPARE(CXXO_COMPILERID_MSC, >= 1700))

    #undef CXXO_needs_copy_constructible
#endif

#ifdef CXXO_needs_copy_constructible
namespace std {
    // pending: use is_convertible as an assist
    template <typename T>
    struct is_copy_constructible
    : std::integral_constant<bool, is_trivially_copy_constructible<T>::value || is_nothrow_copy_constructible<T>::value > 
    {};

................................................................................
    template <typename T>
    struct is_copy_assignable
    : cxxomfort::traits::integral_constant<bool, is_trivially_copy_assignable<T>::value || is_nothrow_copy_assignable<T>::value > 
    {};

} // std::
#endif



#endif // HEADER GUARD

Changes to cxxomfort/cxxomfort/utility.hpp.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
72
73
74
75
76
77
78
79
80
81
82
83













84



























































 * Interfaces defined in this file:
 * 
 * * @c move() (C++11)
 * * @c declval() (C++11)
 * * @c exchange() (C++14)
 * * @c integer_sequence , @c index_sequence (C++14) (down to C++11 only)
 * * @c as_const() (C++17)

 *
 * See also @ref type_traits.hpp , @ref tuple.hpp , 
 * <a href="https://en.cppreference.com/w/cpp/header/utility">\<utility\> \@cppreference</a>.
 */



#include "config.hpp"
#include "base.hpp"   // move, forward

#ifdef CXXOFLAG_CXXHEADERS
    #include_next <type_traits>
#else
    #include CXXO_INCLUDE_SYS(utility)
#endif

#include "util/meta.hpp"
#include "util/type_traits.hpp"

//#include "type_traits.hpp"
#include "using.hpp"

................................................................................
#endif

#define CXXOMFORT_IMPLEMENTS_n1978 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_decltype CXXOMFORT_IMPLEMENTS_n1978
#define CXXOMFORT_IMPLEMENTS_n2343 CXXO_IMPLSTATUS_BACKPORT()


#include "impl/n3668_exchange.hpp"
#include "impl/14-integer_sequence.hpp"
#include "impl/17-as_const.hpp"















#endif


































































>









<
<
<
<
|
<







 







|




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

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




24

25
26
27
28
29
30
31
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
 * Interfaces defined in this file:
 * 
 * * @c move() (C++11)
 * * @c declval() (C++11)
 * * @c exchange() (C++14)
 * * @c integer_sequence , @c index_sequence (C++14) (down to C++11 only)
 * * @c as_const() (C++17)
 * * @c in_place_t , @c in_place_type_t (C++17)
 *
 * See also @ref type_traits.hpp , @ref tuple.hpp , 
 * <a href="https://en.cppreference.com/w/cpp/header/utility">\<utility\> \@cppreference</a>.
 */



#include "config.hpp"
#include "base.hpp"   // move, forward




#include CXXO_INCLUDE_SYS(utility)


#include "util/meta.hpp"
#include "util/type_traits.hpp"

//#include "type_traits.hpp"
#include "using.hpp"

................................................................................
#endif

#define CXXOMFORT_IMPLEMENTS_n1978 CXXO_IMPLSTATUS_EMULATION()
#define CXXOMFORT_IMPLEMENTS_decltype CXXOMFORT_IMPLEMENTS_n1978
#define CXXOMFORT_IMPLEMENTS_n2343 CXXO_IMPLSTATUS_BACKPORT()


#include "impl/n3668-exchange.hpp"
#include "impl/14-integer_sequence.hpp"
#include "impl/17-as_const.hpp"


//
// in_place_t, etc
//

#if (CXXOMFORT_CXX_STD < 2017)

namespace std {

    struct in_place_t { };
#if (CXXOMFORT_CXX_STD >= 2017)
    inline constexpr in_place_t in_place{};
#else
    CXXO_CONSTEXPR const in_place_t in_place = {};
#endif

    namespace detail {

        template< typename T >
        struct in_place_type_tag {
        };

        template< size_t N>
        struct in_place_index_tag {};

    } // detail

    //! Tag template definition for in-place construction of a type
    template <typename T>     struct in_place_type_t { 
        // an assist against C++'s "most vexing parse"
        CXXO_CONSTEXPR in_place_type_t (...) CXXO_NOEXCEPTNOTHROW {}
    };

    //! Tag template definition for in-place construction of a type in a slot
    template <size_t I>       struct in_place_index_t { 
    };

#if (CXXOMFORT_CXX_STD == 2014)
    // here we have template variables

    template <class T>
    CXXOMFORT_CXX17_CODE(inline, ) constexpr in_place_type_t<T> in_place_type = {};

    template <size_t I>
    CXXOMFORT_CXX17_CODE(inline, ) constexpr in_place_index_t<I> in_place_index{};

    #define CXXO_in_place_type_t(T) ::std::in_place_type_t<T>
    
#else

// c++<14 does not have inline variables so we use the 
// overloaded function name reference from 
// https://vector-of-bool.github.io/2016/10/30/standard-in-place.html


struct in_place_tag { };

template <typename T>
void in_place_type (detail::in_place_type_tag<T> = detail::in_place_type_tag<T>() ) CXXO_NOEXCEPTNOTHROW {
}

template <size_t I>
void in_place_index (detail::in_place_index_tag<I> = detail::in_place_index_tag<I>() ) CXXO_NOEXCEPTNOTHROW {
}

    #define CXXO_in_place_type_t(T) void(&)( ::std::detail::in_place_type_tag<T> )

#endif


} // std
#endif // c++17 for in_place_...

#endif

Changes to cxxomfort/cxxomfort/various.hpp.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

/*
 * integral_of_size
 * 
 * @brief Query if an integral with the given size exists
 * 
 */

namespace cxxomfort {

template <unsigned S> struct integral_of_size { 
    static const bool value = false; 
    typedef void type; 
};

template <> struct integral_of_size<sizeof(char)> { 
    static const bool value= true;
    typedef int8_t type; 
};
template <> struct integral_of_size<sizeof(int16_t)> { 
    static const bool value= true;
    typedef int8_t type; 
};
template <> struct integral_of_size<sizeof(int32_t)> { 
    static const bool value= true;
    typedef int32_t type; 
};
template <> struct integral_of_size<sizeof(int64_t)> { 
    static const bool value= true;
    typedef int32_t type; 
};

} //cxxomfort::


#include "util/type_traits.hpp"
#include "util/meta.hpp"      // enable_if, etc...
#include "utility.hpp"
#include "using.hpp"









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







42
43
44
45
46
47
48



























49
50
51
52
53
54
55

/*
 * integral_of_size
 * 
 * @brief Query if an integral with the given size exists
 * 
 */




























#include "util/type_traits.hpp"
#include "util/meta.hpp"      // enable_if, etc...
#include "utility.hpp"
#include "using.hpp"


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

59
60
61
62
63
64
65


66
67
68
69
70
71
72
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


#code generation
CXXO_AUTO|type?|(name , expression)|
CXXOMFORT_CXX11_CODE|code...|(cxx11onward_code,cxx03upto_code)|
CXXOMFORT_CXX14_CODE|code...|(cxx14onward_code,cxx11upto_code)|
CXXO_DEFAULT_DEFAULT_CONSTRUCTOR|default_ctor_expression|(T)|
CXXO_GENERATE_RELATIONALS|code...||
CXXO_COMPILERVERSION_COMPARE|BOOL|(compilerid_, > == < version_)|







>
>







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
CXXO_in_place_type(T)|std::in_place_type_t<T>|(type T)|
CXXO_in_place_index(I)|std::in_place_index_t<I>|(size_t I)|
#code generation
CXXO_AUTO|type?|(name , expression)|
CXXOMFORT_CXX11_CODE|code...|(cxx11onward_code,cxx03upto_code)|
CXXOMFORT_CXX14_CODE|code...|(cxx14onward_code,cxx11upto_code)|
CXXO_DEFAULT_DEFAULT_CONSTRUCTOR|default_ctor_expression|(T)|
CXXO_GENERATE_RELATIONALS|code...||
CXXO_COMPILERVERSION_COMPARE|BOOL|(compilerid_, > == < version_)|