Skip to content

Commit 7289c6a

Browse files
committed
Merge branch 'work' into tests
2 parents 6c55811 + 222d083 commit 7289c6a

File tree

4 files changed

+78
-44
lines changed

4 files changed

+78
-44
lines changed

stdex/include/cstdint.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,13 @@ namespace stdex
156156
{ };
157157

158158
template<class _Tp>
159-
struct _is_integral_constant:
160-
_is_integral_constant_impl<_Tp,
161-
_is_integral_constant_std_impl<unsigned short>::value == bool(true)
162-
&& _is_integral_constant_std_impl<long>::value == bool(true)
163-
&& _is_integral_constant_std_impl<signed char>::value == bool(true)
164-
>
159+
struct _is_integral_constant
165160
{
166-
161+
static const bool flag =
162+
(_is_integral_constant_std_impl<unsigned short>::value == bool(true)
163+
&& _is_integral_constant_std_impl<long>::value == bool(true)
164+
&& _is_integral_constant_std_impl<signed char>::value == bool(true));
165+
static const bool value = _is_integral_constant_impl<_Tp, flag>::value;
167166
};
168167

169168
template<class _Tp>

stdex/include/nullptr.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,10 @@ namespace stdex
402402
static const bool _equal_void_ptr = _is_equal_size_to_void_ptr<_nullptr_t_as_integral>::value;
403403
static const bool _can_be_compared_to_ptr = _nullptr_t_can_be_compared_to_ptr<_nullptr_t_as_integral>::value;
404404
};
405-
406-
typedef _nullptr_choose_as_int<
405+
static const bool _nullptr_choose_as_int_flag =
407406
(nullptr_detail::_NULL_is_convertable_to_int::value == bool(true)) &&
408-
(_as_int::_is_convertable_to_ptr == bool(true) && _as_int::_equal_void_ptr == bool(true) && _as_int::_can_be_compared_to_ptr == bool(true))
409-
>::type type;
407+
(_as_int::_is_convertable_to_ptr == bool(true) && _as_int::_equal_void_ptr == bool(true) && _as_int::_can_be_compared_to_ptr == bool(true));
408+
typedef _nullptr_choose_as_int< _nullptr_choose_as_int_flag >::type type;
410409
};
411410

412411
template<>
@@ -420,10 +419,10 @@ namespace stdex
420419
static const bool _equal_void_ptr = _is_equal_size_to_void_ptr<_nullptr_t_as_enum>::value;
421420
static const bool _can_be_ct_constant = true;//_nullptr_can_be_ct_constant_impl<_nullptr_t_as_enum>::value;
422421
};
422+
static const bool _nullptr_choose_as_enum_flag =
423+
(_as_enum::_is_convertable_to_ptr == bool(true) && _as_enum::_equal_void_ptr == bool(true) && _as_enum::_can_be_ct_constant == bool(true));
423424

424-
typedef _nullptr_choose_as_enum<
425-
(_as_enum::_is_convertable_to_ptr == bool(true) && _as_enum::_equal_void_ptr == bool(true) && _as_enum::_can_be_ct_constant == bool(true))
426-
>::type type;
425+
typedef _nullptr_choose_as_enum< _nullptr_choose_as_enum_flag >::type type;
427426
};
428427

429428
struct _nullptr_chooser
@@ -437,10 +436,10 @@ namespace stdex
437436
static const bool _equal_void_ptr = _is_equal_size_to_void_ptr<_nullptr_t_as_class>::value;
438437
static const bool _can_be_ct_constant = _nullptr_can_be_ct_constant_impl<_nullptr_t_as_class>::value;
439438
};
439+
static const bool _nullptr_choose_as_class_flag =
440+
(_as_class::_equal_void_ptr == bool(true) && _as_class::_can_be_ct_constant == bool(true));
440441

441-
typedef _nullptr_choose_as_class<
442-
(_as_class::_equal_void_ptr == bool(true) && _as_class::_can_be_ct_constant == bool(true))
443-
>::type type;
442+
typedef _nullptr_choose_as_class< _nullptr_choose_as_class_flag >::type type;
444443
};
445444
} // namespace detail
446445

stdex/include/string.hpp

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
#include <cstddef> // std::size_t
3434
#include <iomanip> // std::setbase
3535

36+
#ifdef max
37+
#define _STDEX_NUMERIC_LIMITS_MAX(T) (std::numeric_limits<T>::max)()
38+
#else
39+
#define _STDEX_NUMERIC_LIMITS_MAX(T) std::numeric_limits<T>::max()
40+
#endif
41+
#ifdef min
42+
#define _STDEX_NUMERIC_LIMITS_MIN(T) (std::numeric_limits<T>::min)()
43+
#else
44+
#define _STDEX_NUMERIC_LIMITS_MIN(T) std::numeric_limits<T>::min()
45+
#endif
46+
3647
namespace stdex
3748
{
3849
namespace cstddef
@@ -209,7 +220,7 @@ namespace stdex
209220
unsigned long int uvalue = strtoul(positive_str.c_str(), NULL, base);
210221
unsigned long int _zero = 0;
211222

212-
if(errno == 0 && uvalue > static_cast<unsigned long int>(is_negative ? _zero - (numeric_limits<long int>::min)() : (numeric_limits<long int>::max)() ))
223+
if(errno == 0 && uvalue > static_cast<unsigned long int>(is_negative ? _zero - _STDEX_NUMERIC_LIMITS_MIN(long int) : _STDEX_NUMERIC_LIMITS_MAX(long int) ))
213224
errno = ERANGE;// using errno is bad - m'kay?
214225
}
215226

@@ -255,7 +266,7 @@ namespace stdex
255266
unsigned long int uvalue = wcstoul(positive_str.c_str(), NULL, base);
256267
unsigned long int _zero = 0;
257268

258-
if(errno == 0 && uvalue > static_cast<unsigned long int>(is_negative ? _zero - (numeric_limits<long int>::min)() : (numeric_limits<long int>::max)() ))
269+
if(errno == 0 && uvalue > static_cast<unsigned long int>(is_negative ? _zero - _STDEX_NUMERIC_LIMITS_MIN(long int) : _STDEX_NUMERIC_LIMITS_MAX(long int) ))
259270
errno = ERANGE;// using errno is bad - m'kay?
260271
}
261272

@@ -285,7 +296,7 @@ namespace stdex
285296
#ifdef LONG_MIN
286297
return ((_value == -LONG_MIN || _value == LONG_MIN));
287298
#else
288-
return ((_value == (std::numeric_limits<long int>::min)() || _value == (std::numeric_limits<long int>::max)()));
299+
return ((_value == _STDEX_NUMERIC_LIMITS_MIN(long int) || _value == _STDEX_NUMERIC_LIMITS_MAX(long int)));
289300
#endif
290301
#endif
291302
}
@@ -467,7 +478,7 @@ namespace stdex
467478
#ifdef ULONG_MAX
468479
return ((_value == ULONG_MAX));
469480
#else
470-
return ((_value == (std::numeric_limits<unsigned long int>::max)()));
481+
return ((_value == _STDEX_NUMERIC_LIMITS_MAX(unsigned long int)));
471482
#endif
472483
}
473484
};
@@ -529,7 +540,7 @@ namespace stdex
529540
template<class _Tp>
530541
struct _infinity_impl<_Tp, false>
531542
{
532-
static _Tp inf() { return (std::numeric_limits<_Tp>::max)(); }
543+
static _Tp inf() { return _STDEX_NUMERIC_LIMITS_MAX(_Tp); }
533544
};
534545

535546
template<class _Tp>
@@ -950,7 +961,7 @@ namespace stdex
950961
#ifdef LLONG_MIN
951962
return ((_value == -LLONG_MIN || _value == LLONG_MIN));
952963
#else
953-
return ((_value == (std::numeric_limits<string_detail::_long_long_type>::min)() || _value == (std::numeric_limits<string_detail::_long_long_type>::max)()));
964+
return ((_value == _STDEX_NUMERIC_LIMITS_MIN(string_detail::_long_long_type) || _value == _STDEX_NUMERIC_LIMITS_MAX(string_detail::_long_long_type)));
954965
#endif
955966
#endif
956967
}
@@ -979,7 +990,7 @@ namespace stdex
979990
#ifdef ULLONG_MAX
980991
return ((_value == ULLONG_MAX));
981992
#else
982-
return ((_value == (std::numeric_limits<string_detail::_unsigned_long_long_type>::max)()));
993+
return ((_value == _STDEX_NUMERIC_LIMITS_MAX(string_detail::_unsigned_long_long_type)));
983994
#endif
984995
}
985996
};
@@ -1023,9 +1034,9 @@ namespace stdex
10231034

10241035
if (_str_to_integral::check(_value) && errno == ERANGE)
10251036
num_s_end = 0;
1026-
else if (_value > static_cast<large_value_type>((std::numeric_limits<_Tp>::max)()) || _value < static_cast<large_value_type>((std::numeric_limits<_Tp>::min)()))
1037+
else if (_value > static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MAX(_Tp)) || _value < static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MIN(_Tp)))
10271038
{
1028-
_value = (std::numeric_limits<_Tp>::max)();
1039+
_value = _STDEX_NUMERIC_LIMITS_MAX(_Tp);
10291040
num_s_end = 0;
10301041
}
10311042
else
@@ -1050,9 +1061,9 @@ namespace stdex
10501061

10511062
if (_str_to_integral::check(_value) && errno == ERANGE)
10521063
num_s_end = 0;
1053-
else if (_value > static_cast<large_value_type>((std::numeric_limits<_Tp>::max)()) || _value < static_cast<large_value_type>((std::numeric_limits<_Tp>::min)()))
1064+
else if (_value > static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MAX(_Tp)) || _value < static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MIN(_Tp)))
10541065
{
1055-
_value = (std::numeric_limits<_Tp>::max)();
1066+
_value = _STDEX_NUMERIC_LIMITS_MAX(_Tp);
10561067
num_s_end = 0;
10571068
}
10581069
else
@@ -1078,9 +1089,9 @@ namespace stdex
10781089

10791090
if (_str_to_integral::check(_value) && errno == ERANGE)
10801091
num_s_end = 0;
1081-
else if (_value > static_cast<large_value_type>((std::numeric_limits<_Tp>::max)()) || _value < static_cast<large_value_type>((std::numeric_limits<_Tp>::min)()))
1092+
else if (_value > static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MAX(_Tp)) || _value < static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MIN(_Tp)))
10821093
{
1083-
_value = (std::numeric_limits<_Tp>::max)();
1094+
_value = _STDEX_NUMERIC_LIMITS_MAX(_Tp);
10841095
num_s_end = 0;
10851096
}
10861097
else
@@ -1105,9 +1116,9 @@ namespace stdex
11051116

11061117
if (_str_to_integral::check(_value) && errno == ERANGE)
11071118
num_s_end = 0;
1108-
else if (_value > static_cast<large_value_type>((std::numeric_limits<_Tp>::max)()) || _value < static_cast<large_value_type>((std::numeric_limits<_Tp>::min)()))
1119+
else if (_value > static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MAX(_Tp)) || _value < static_cast<large_value_type>(_STDEX_NUMERIC_LIMITS_MIN(_Tp)))
11091120
{
1110-
_value = (std::numeric_limits<_Tp>::max)();
1121+
_value = _STDEX_NUMERIC_LIMITS_MAX(_Tp);
11111122
num_s_end = 0;
11121123
}
11131124
else
@@ -1136,9 +1147,9 @@ namespace stdex
11361147
if (errno == ERANGE)
11371148
#endif
11381149
num_s_end = 0;
1139-
else if (_value > static_cast<double>((std::numeric_limits<_Tp>::max)()) || _value < static_cast<double>(-(std::numeric_limits<_Tp>::max)()))
1150+
else if (_value > static_cast<double>(_STDEX_NUMERIC_LIMITS_MAX(_Tp)) || _value < static_cast<double>(-_STDEX_NUMERIC_LIMITS_MAX(_Tp)))
11401151
{
1141-
_value = (std::numeric_limits<_Tp>::max)();
1152+
_value = _STDEX_NUMERIC_LIMITS_MAX(_Tp);
11421153
num_s_end = 0;
11431154
}
11441155
else
@@ -1166,9 +1177,9 @@ namespace stdex
11661177
if (errno == ERANGE)
11671178
#endif
11681179
num_s_end = 0;
1169-
else if (_value > static_cast<double>((std::numeric_limits<_Tp>::max)()) || _value < static_cast<double>(-(std::numeric_limits<_Tp>::max)()))
1180+
else if (_value > static_cast<double>(_STDEX_NUMERIC_LIMITS_MAX(_Tp)) || _value < static_cast<double>(-_STDEX_NUMERIC_LIMITS_MAX(_Tp)))
11701181
{
1171-
_value = (std::numeric_limits<_Tp>::max)();
1182+
_value = _STDEX_NUMERIC_LIMITS_MAX(_Tp);
11721183
num_s_end = 0;
11731184
}
11741185
else
@@ -1274,7 +1285,7 @@ namespace stdex
12741285
value = fp_integer_part + fp_fractional_part;
12751286
}
12761287

1277-
if(value > (numeric_limits<long double>::max)() || value < (numeric_limits<long double>::min)())
1288+
if(value > _STDEX_NUMERIC_LIMITS_MAX(long double) || value < _STDEX_NUMERIC_LIMITS_MIN(long double))
12781289
{
12791290
errno = ERANGE;
12801291
value = 0.0;
@@ -1316,7 +1327,7 @@ namespace stdex
13161327
value = fp_integer_part + fp_fractional_part;
13171328
}
13181329

1319-
if (value > (numeric_limits<long double>::max)() || value < (numeric_limits<long double>::min)())
1330+
if (value > _STDEX_NUMERIC_LIMITS_MAX(long double) || value < _STDEX_NUMERIC_LIMITS_MIN(long double))
13201331
{
13211332
errno = ERANGE;
13221333
value = 0.0;
@@ -1411,7 +1422,7 @@ namespace stdex
14111422
if (std::numeric_limits<long double>::max_exponent10 < _i)
14121423
{
14131424
errno = ERANGE;
1414-
return (std::numeric_limits<long double>::max)();
1425+
return _STDEX_NUMERIC_LIMITS_MAX(long double);
14151426
}
14161427
return _a_to_floating_point(_str);
14171428
}
@@ -1510,7 +1521,7 @@ namespace stdex
15101521
if (std::numeric_limits<long double>::max_exponent10 < _i)
15111522
{
15121523
errno = ERANGE;
1513-
return (std::numeric_limits<long double>::max)();
1524+
return _STDEX_NUMERIC_LIMITS_MAX(long double);
15141525
}
15151526
return _a_to_floating_point(_str);
15161527
}
@@ -2414,4 +2425,8 @@ namespace stdex
24142425

24152426
}
24162427

2428+
2429+
#undef _STDEX_NUMERIC_LIMITS_MAX
2430+
#undef _STDEX_NUMERIC_LIMITS_MIN
2431+
24172432
#endif // _STDEX_STRING_H

stdex/include/type_traits.hpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,13 +949,34 @@ _STDEX_MSVC_SUPPRESS_WARNING_POP // warning C4180
949949
{ };
950950

951951
template<class _Tp>
952-
struct _arr_is_incomplete_type:
953-
_is_incomplete_type<_Tp[]>
954-
{ };
952+
_Tp* _arr_is_incomplete_type_tester_helper(_Tp(*)[]);
953+
954+
template<class _Tp>
955+
void* _arr_is_incomplete_type_tester_helper(...);
956+
957+
template<class _Tp>
958+
_no_type _arr_is_incomplete_type_tester(_Tp*);
959+
960+
_yes_type _arr_is_incomplete_type_tester(...);
961+
962+
template<class _Tp>
963+
struct _arr_is_incomplete_type
964+
//_is_incomplete_type<_Tp[]>
965+
{
966+
967+
static const bool value =
968+
sizeof( _arr_is_incomplete_type_tester(_arr_is_incomplete_type_tester_helper<_Tp>(0)) )
969+
== sizeof(_yes_type);
970+
};
955971

956972
template<class _Tp>
957973
struct _arr_is_incomplete_type<_Tp&>:
958-
_is_incomplete_type<_Tp[]>
974+
_arr_is_incomplete_type<_Tp>
975+
{ };
976+
977+
template<>
978+
struct _arr_is_incomplete_type<void>:
979+
_is_incomplete_type<void>
959980
{ };
960981

961982
template<>

0 commit comments

Comments
 (0)