More windows port work by Ruben Van Boxem

llvm-svn: 142732
This commit is contained in:
Howard Hinnant 2011-10-22 20:59:45 +00:00
parent a6674c7fc9
commit e4383379ae
16 changed files with 233 additions and 121 deletions

View File

@ -218,9 +218,9 @@ __find_bool_false(__bit_iterator<_C, false> __first, typename _C::size_type __n)
template <class _C, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__bit_iterator<_C, false>
find(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value)
find(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value_)
{
if (static_cast<bool>(__value))
if (static_cast<bool>(__value_))
return __find_bool_true(__first, static_cast<typename _C::size_type>(__last - __first));
return __find_bool_false(__first, static_cast<typename _C::size_type>(__last - __first));
}
@ -292,9 +292,9 @@ __count_bool_false(__bit_iterator<_C, false> __first, typename _C::size_type __n
template <class _C, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename __bit_iterator<_C, false>::difference_type
count(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value)
count(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value_)
{
if (static_cast<bool>(__value))
if (static_cast<bool>(__value_))
return __count_bool_true(__first, static_cast<typename _C::size_type>(__last - __first));
return __count_bool_false(__first, static_cast<typename _C::size_type>(__last - __first));
}
@ -364,11 +364,11 @@ __fill_n_true(__bit_iterator<_C, false> __first, typename _C::size_type __n)
template <class _C>
_LIBCPP_INLINE_VISIBILITY inline
void
fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __value)
fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __value_)
{
if (__n > 0)
{
if (__value)
if (__value_)
__fill_n_true(__first, __n);
else
__fill_n_false(__first, __n);
@ -380,9 +380,9 @@ fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __val
template <class _C>
inline _LIBCPP_INLINE_VISIBILITY
void
fill(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, bool __value)
fill(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, bool __value_)
{
_VSTD::fill_n(__first, static_cast<typename _C::size_type>(__last - __first), __value);
_VSTD::fill_n(__first, static_cast<typename _C::size_type>(__last - __first), __value_);
}
// copy

View File

@ -321,6 +321,8 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
#elif defined(_MSC_VER)
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_UNICODE_CHARS

View File

@ -764,10 +764,10 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
template <class _InputIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_InputIterator
find(_InputIterator __first, _InputIterator __last, const _Tp& __value)
find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
{
for (; __first != __last; ++__first)
if (*__first == __value)
if (*__first == __value_)
break;
return __first;
}
@ -1004,11 +1004,11 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
template <class _InputIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename iterator_traits<_InputIterator>::difference_type
count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
{
typename iterator_traits<_InputIterator>::difference_type __r(0);
for (; __first != __last; ++__first)
if (*__first == __value)
if (*__first == __value_)
++__r;
return __r;
}
@ -1312,22 +1312,22 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
_ForwardIterator
__search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count, const _Tp& __value, _BinaryPredicate __pred, forward_iterator_tag)
_Size __count, const _Tp& __value_, _BinaryPredicate __pred, forward_iterator_tag)
{
if (__count <= 0)
return __first;
while (true)
{
// Find first element in sequence that matchs __value, with a mininum of loop checks
// Find first element in sequence that matchs __value_, with a mininum of loop checks
while (true)
{
if (__first == __last) // return __last if no element matches __value
if (__first == __last) // return __last if no element matches __value_
return __last;
if (__pred(*__first, __value))
if (__pred(*__first, __value_))
break;
++__first;
}
// *__first matches __value, now match elements after here
// *__first matches __value_, now match elements after here
_ForwardIterator __m = __first;
_Size __c(0);
while (true)
@ -1336,7 +1336,7 @@ __search_n(_ForwardIterator __first, _ForwardIterator __last,
return __first;
if (++__m == __last) // Otherwise if source exhaused, pattern not found
return __last;
if (!__pred(*__m, __value)) // if there is a mismatch, restart with a new __first
if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
{
__first = __m;
++__first;
@ -1349,7 +1349,7 @@ __search_n(_ForwardIterator __first, _ForwardIterator __last,
template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
_RandomAccessIterator
__search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Size __count, const _Tp& __value, _BinaryPredicate __pred, random_access_iterator_tag)
_Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag)
{
if (__count <= 0)
return __first;
@ -1359,16 +1359,16 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here
while (true)
{
// Find first element in sequence that matchs __value, with a mininum of loop checks
// Find first element in sequence that matchs __value_, with a mininum of loop checks
while (true)
{
if (__first == __s) // return __last if no element matches __value
if (__first == __s) // return __last if no element matches __value_
return __last;
if (__pred(*__first, __value))
if (__pred(*__first, __value_))
break;
++__first;
}
// *__first matches __value, now match elements after here
// *__first matches __value_, now match elements after here
_RandomAccessIterator __m = __first;
_Size __c(0);
while (true)
@ -1376,7 +1376,7 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
return __first;
++__m; // no need to check range on __m because __s guarantees we have enough source
if (!__pred(*__m, __value)) // if there is a mismatch, restart with a new __first
if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
{
__first = __m;
++__first;
@ -1390,19 +1390,19 @@ template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count, const _Tp& __value, _BinaryPredicate __pred)
_Size __count, const _Tp& __value_, _BinaryPredicate __pred)
{
return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
(__first, __last, __count, __value, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
(__first, __last, __count, __value_, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
}
template <class _ForwardIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value)
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
{
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
return _VSTD::search_n(__first, __last, __count, __value, __equal_to<__v, _Tp>());
return _VSTD::search_n(__first, __last, __count, __value_, __equal_to<__v, _Tp>());
}
// copy
@ -1744,29 +1744,29 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value, false_type)
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, false_type)
{
for (; __n > 0; ++__first, --__n)
*__first = __value;
*__first = __value_;
return __first;
}
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value, true_type)
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, true_type)
{
if (__n > 0)
_VSTD::memset(__first, (unsigned char)__value, (size_t)(__n));
_VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n));
return __first + __n;
}
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
return _VSTD::__fill_n(__first, __n, __value, integral_constant<bool,
return _VSTD::__fill_n(__first, __n, __value_, integral_constant<bool,
is_pointer<_OutputIterator>::value &&
is_trivially_copy_assignable<_Tp>::value &&
sizeof(_Tp) == 1>());
@ -1777,26 +1777,26 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
{
for (; __first != __last; ++__first)
*__first = __value;
*__first = __value_;
}
template <class _RandomAccessIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
{
_VSTD::fill_n(__first, __last - __first, __value);
_VSTD::fill_n(__first, __last - __first, __value_);
}
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
_VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
_VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
}
// generate
@ -1826,15 +1826,15 @@ generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
template <class _ForwardIterator, class _Tp>
_ForwardIterator
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
__first = _VSTD::find(__first, __last, __value);
__first = _VSTD::find(__first, __last, __value_);
if (__first != __last)
{
_ForwardIterator __i = __first;
while (++__i != __last)
{
if (!(*__i == __value))
if (!(*__i == __value_))
{
*__first = _VSTD::move(*__i);
++__first;
@ -1872,11 +1872,11 @@ remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
template <class _InputIterator, class _OutputIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
{
for (; __first != __last; ++__first)
{
if (!(*__first == __value))
if (!(*__first == __value_))
{
*__result = *__first;
++__result;
@ -3683,6 +3683,10 @@ sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp)
_VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
}
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable: 4231)
#endif // _MSC_VER
extern template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
extern template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
extern template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
@ -3716,12 +3720,15 @@ extern template bool __insertion_sort_incomplete<__less<double>&, double*>(doubl
extern template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
extern template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
#ifdef _MSC_VER
#pragma warning( pop )
#endif _MSC_VER
// lower_bound
template <class _Compare, class _ForwardIterator, class _Tp>
_ForwardIterator
__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
difference_type __len = _VSTD::distance(__first, __last);
@ -3730,7 +3737,7 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
difference_type __l2 = __len / 2;
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__comp(*__m, __value))
if (__comp(*__m, __value_))
{
__first = ++__m;
__len -= __l2 + 1;
@ -3744,24 +3751,24 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
template <class _ForwardIterator, class _Tp, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
#ifdef _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
__debug_less<_Compare> __c(__comp);
return __lower_bound<_Comp_ref>(__first, __last, __value, __c);
return __lower_bound<_Comp_ref>(__first, __last, __value_, __c);
#else // _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
return __lower_bound<_Comp_ref>(__first, __last, __value, __comp);
return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
#endif // _LIBCPP_DEBUG2
}
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
return _VSTD::lower_bound(__first, __last, __value,
return _VSTD::lower_bound(__first, __last, __value_,
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
}
@ -3769,7 +3776,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
template <class _Compare, class _ForwardIterator, class _Tp>
_ForwardIterator
__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
difference_type __len = _VSTD::distance(__first, __last);
@ -3778,7 +3785,7 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
difference_type __l2 = __len / 2;
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__comp(__value, *__m))
if (__comp(__value_, *__m))
__len = __l2;
else
{
@ -3792,24 +3799,24 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
template <class _ForwardIterator, class _Tp, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
#ifdef _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
__debug_less<_Compare> __c(__comp);
return __upper_bound<_Comp_ref>(__first, __last, __value, __c);
return __upper_bound<_Comp_ref>(__first, __last, __value_, __c);
#else // _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
return __upper_bound<_Comp_ref>(__first, __last, __value, __comp);
return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
#endif // _LIBCPP_DEBUG2
}
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
return _VSTD::upper_bound(__first, __last, __value,
return _VSTD::upper_bound(__first, __last, __value_,
__less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
}
@ -3817,7 +3824,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
template <class _Compare, class _ForwardIterator, class _Tp>
pair<_ForwardIterator, _ForwardIterator>
__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
difference_type __len = _VSTD::distance(__first, __last);
@ -3826,12 +3833,12 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
difference_type __l2 = __len / 2;
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__comp(*__m, __value))
if (__comp(*__m, __value_))
{
__first = ++__m;
__len -= __l2 + 1;
}
else if (__comp(__value, *__m))
else if (__comp(__value_, *__m))
{
__last = __m;
__len = __l2;
@ -3841,8 +3848,8 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
_ForwardIterator __mp1 = __m;
return pair<_ForwardIterator, _ForwardIterator>
(
__lower_bound<_Compare>(__first, __m, __value, __comp),
__upper_bound<_Compare>(++__mp1, __last, __value, __comp)
__lower_bound<_Compare>(__first, __m, __value_, __comp),
__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
);
}
}
@ -3852,24 +3859,24 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
template <class _ForwardIterator, class _Tp, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
#ifdef _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
__debug_less<_Compare> __c(__comp);
return __equal_range<_Comp_ref>(__first, __last, __value, __c);
return __equal_range<_Comp_ref>(__first, __last, __value_, __c);
#else // _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
return __equal_range<_Comp_ref>(__first, __last, __value, __comp);
return __equal_range<_Comp_ref>(__first, __last, __value_, __comp);
#endif // _LIBCPP_DEBUG2
}
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
return _VSTD::equal_range(__first, __last, __value,
return _VSTD::equal_range(__first, __last, __value_,
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
}
@ -3878,33 +3885,33 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
template <class _Compare, class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
__first = __lower_bound<_Compare>(__first, __last, __value, __comp);
return __first != __last && !__comp(__value, *__first);
__first = __lower_bound<_Compare>(__first, __last, __value_, __comp);
return __first != __last && !__comp(__value_, *__first);
}
template <class _ForwardIterator, class _Tp, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
#ifdef _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
__debug_less<_Compare> __c(__comp);
return __binary_search<_Comp_ref>(__first, __last, __value, __c);
return __binary_search<_Comp_ref>(__first, __last, __value_, __c);
#else // _LIBCPP_DEBUG2
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
return __binary_search<_Comp_ref>(__first, __last, __value, __comp);
return __binary_search<_Comp_ref>(__first, __last, __value_, __comp);
#endif // _LIBCPP_DEBUG2
}
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
return _VSTD::binary_search(__first, __last, __value,
return _VSTD::binary_search(__first, __last, __value_,
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
}

View File

@ -37,6 +37,9 @@ int toupper(int c);
#include <__config>
#include <ctype.h>
#if defined(_MSC_VER)
#include "support/win32/support.h"
#endif // _MSC_VER
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View File

@ -126,13 +126,15 @@ using ::scanf;
using ::snprintf;
using ::sprintf;
using ::sscanf;
#ifndef _MSC_VER
using ::vfprintf;
using ::vfscanf;
using ::vprintf;
using ::vscanf;
using ::vsscanf;
#endif // _MSC_VER
using ::vprintf;
using ::vsnprintf;
using ::vsprintf;
using ::vsscanf;
using ::fgetc;
using ::fgets;
using ::fputc;

View File

@ -81,6 +81,9 @@ size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
#include <__config>
#include <stdlib.h>
#ifdef _MSC_VER
#include "support/win32/support.h"
#endif // _MSC_VER
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@ -129,11 +132,13 @@ using ::wctomb;
using ::mbstowcs;
using ::wcstombs;
#ifndef _MSC_VER // MSVC already has the correct prototype in <stdlib.h.h> #ifdef __cplusplus
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) {return labs(__x);}
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) {return llabs(__x);}
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) {return ldiv(__x, __y);}
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) {return lldiv(__x, __y);}
#endif // _MSC_VER
_LIBCPP_END_NAMESPACE_STD

View File

@ -93,7 +93,8 @@ using ::strspn;
using ::strstr;
#ifndef __GLIBC__ // GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus
// MSVC, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus
#if !defined(__GLIBC__) && !defined(_MSC_VER)
inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);}

View File

@ -124,13 +124,15 @@ using ::FILE;
using ::fwprintf;
using ::fwscanf;
using ::swprintf;
using ::swscanf;
using ::vfwprintf;
using ::vfwscanf;
using ::vswprintf;
using ::vswscanf;
using ::vwprintf;
#ifndef _MSC_VER
using ::swscanf;
using ::vfwscanf;
using ::vswscanf;
using ::vwscanf;
#endif // _MSC_VER
using ::wprintf;
using ::wscanf;
using ::fgetwc;
@ -144,8 +146,10 @@ using ::putwc;
using ::putwchar;
using ::ungetwc;
using ::wcstod;
#ifndef _MSC_VER
using ::wcstof;
using ::wcstold;
#endif // _MSC_VER
using ::wcstol;
using ::wcstoll;
using ::wcstoul;

View File

@ -626,11 +626,11 @@ public:
typedef _Container container_type;
_LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(&__x) {}
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value)
{container->push_back(__value); return *this;}
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
{container->push_back(__value_); return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value)
{container->push_back(_VSTD::move(__value)); return *this;}
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_)
{container->push_back(_VSTD::move(__value_)); return *this;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;}
@ -659,11 +659,11 @@ public:
typedef _Container container_type;
_LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(&__x) {}
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value)
{container->push_front(__value); return *this;}
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
{container->push_front(__value_); return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value)
{container->push_front(_VSTD::move(__value)); return *this;}
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_)
{container->push_front(_VSTD::move(__value_)); return *this;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;}
@ -694,11 +694,11 @@ public:
_LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
: container(&__x), iter(__i) {}
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value)
{iter = container->insert(iter, __value); ++iter; return *this;}
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
{iter = container->insert(iter, __value_); ++iter; return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value)
{iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;}
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_)
{iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;}
@ -769,9 +769,9 @@ public:
: __out_stream_(&__s), __delim_(0) {}
_LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter)
: __out_stream_(&__s), __delim_(__delimiter) {}
_LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value)
_LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
{
*__out_stream_ << __value;
*__out_stream_ << __value_;
if (__delim_)
*__out_stream_ << __delim_;
return *this;

View File

@ -109,6 +109,10 @@ template<> class numeric_limits<cv long double>;
#include <__config>
#include <type_traits>
#if defined(_MSC_VER)
#include "support/win32/limits_win32.h"
#endif // _MSC_VER
_LIBCPP_BEGIN_NAMESPACE_STD
enum float_round_style

View File

@ -186,10 +186,10 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
{
for (; __first != __last; ++__first, ++__value)
*__first = __value;
for (; __first != __last; ++__first, ++__value_)
*__first = __value_;
}
_LIBCPP_END_NAMESPACE_STD

View File

@ -1023,7 +1023,14 @@ __basic_string_common<__b>::__throw_out_of_range() const
#endif
}
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable: 4231 )
#endif // _MSC_VER
extern template class __basic_string_common<true>;
#ifdef _MSC_VER
#pragma warning( pop )
#endif // _MSC_VER
template<class _CharT, class _Traits, class _Allocator>
class _LIBCPP_VISIBLE basic_string

View File

@ -15,6 +15,11 @@
#error "This header is MSVC specific, Clang and GCC should not include it"
#else
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h> // ymath.h works correctly
#include <float.h> // limit constants
#define __FLT_MANT_DIG__ FLT_MANT_DIG
@ -57,16 +62,17 @@
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
// __builtin replacements/workarounds
#include <math.h> // HUGE_VAL
#include <ymath.h> // internal MSVC header providing the needed functionality
#define __builtin_huge_val() HUGE_VAL
#define __builtin_huge_valf() _FInf
#define __builtin_huge_vall() _LInf
#define __builtin_nan() _Nan
#define __builtin_nanf() _FNan
#define __builtin_nanl() _LNan
#define __builtin_nans() _Snan
#define __builtin_nansf() _FSnan
#define __builtin_nansl() _LSnan
#define __builtin_huge_val() HUGE_VAL
#define __builtin_huge_valf() _FInf._Float
#define __builtin_huge_vall() _LInf._Long_double
#define __builtin_nan(__dummy) _Nan._Double
#define __builtin_nanf(__dummy) _FNan._Float
#define __builtin_nanl(__dummmy) _LNan._Long_double
#define __builtin_nans(__dummy) _Snan._Double
#define __builtin_nansf(__dummy) _FSnan._Float
#define __builtin_nansl(__dummy) _LSnan._Long_double
#endif // _MSC_VER

View File

@ -15,17 +15,81 @@
Functions and constants used in libc++ that are missing from the Windows C library.
*/
#include <__config>
#include <wchar.h> // mbstate_t
#include <stdio.h> // _snwprintf
#define swprintf _snwprintf
#define vswprintf _vsnwprintf
#define vfscnaf fscanf
int vasprintf( char **sptr, const char *__restrict__ fmt , va_list ap );
int asprintf(char **sptr, const char *__restrict__ fmt, ...);
int vasprintf( char **sptr, const char *__restrict fmt , va_list ap );
int asprintf( char **sptr, const char *__restrict fmt, ...);
//int vfscanf( FILE *__restrict stream, const char *__restrict format,
// va_list arg);
size_t mbsnrtowcs( wchar_t *__restrict__ dst, const char **__restrict__ src,
size_t nmc, size_t len, mbstate_t *__restrict__ ps );
size_t wcsnrtombs( char *__restrict__ dst, const wchar_t **__restrict__ src,
size_t nwc, size_t len, mbstate_t *__restrict__ ps );
size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
size_t nmc, size_t len, mbstate_t *__restrict ps );
size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
size_t nwc, size_t len, mbstate_t *__restrict ps );
#if defined(_MSC_VER)
#define snprintf _snprintf
inline int isblank( int c, locale_t /*loc*/ )
{ return ( c == ' ' || c == '\t' ); }
inline int iswblank( wint_t c, locale_t /*loc*/ )
{ return ( c == L' ' || c == L'\t' ); }
#include <xlocinfo.h>
#define atoll _atoi64
#define strtoll _strtoi64
#define strtoull _strtoui64
#define wcstoll _wcstoi64
#define wcstoull _wcstoui64
_LIBCPP_ALWAYS_INLINE float strtof( const char *nptr, char **endptr )
{ return _Stof(nptr, endptr, 0); }
_LIBCPP_ALWAYS_INLINE double strtod( const char *nptr, char **endptr )
{ return _Stod(nptr, endptr, 0); }
_LIBCPP_ALWAYS_INLINE long double strtold( const char *nptr, char **endptr )
{ return _Stold(nptr, endptr, 0); }
_LIBCPP_ALWAYS_INLINE float wcstof( const wchar_t *nptr, char** endptr )
#define _Exit _exit
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountl __popcnt
#define __builtin_popcountll(__i) static_cast<int>(__popcnt64(__i))
_LIBCPP_ALWAYS_INLINE int __builtin_ctz( unsigned int x )
{
DWORD r = 0;
_BitScanReverse(&r, x);
return static_cast<int>(r);
}
// sizeof(long) == sizeof(int) on Windows
_LIBCPP_ALWAYS_INLINE int __builtin_ctzl( unsigned long x )
{ return __builtin_ctz( static_cast<int>(x) ); }
_LIBCPP_ALWAYS_INLINE int __builtin_ctzll( unsigned long long x )
{
DWORD r = 0;
_BitScanReverse64(&r, x);
return static_cast<int>(r);
}
_LIBCPP_ALWAYS_INLINE int __builtin_clz( unsigned int x )
{
DWORD r = 0;
_BitScanForward(&r, x);
return static_cast<int>(r);
}
// sizeof(long) == sizeof(int) on Windows
_LIBCPP_ALWAYS_INLINE int __builtin_clzl( unsigned long x )
{ return __builtin_clz( static_cast<int>(x) ); }
_LIBCPP_ALWAYS_INLINE int __builtin_clzll( unsigned long long x )
{
DWORD r = 0;
_BitScanForward64(&r, x);
return static_cast<int>(r);
}
#endif
#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H

View File

@ -307,7 +307,14 @@ __vector_base_common<__b>::__throw_out_of_range() const
#endif
}
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable: 4231 )
#endif // _MSC_VER
extern template class __vector_base_common<true>;
#ifdef _MSC_VER
#pragma warning( pop )
#endif // _MSC_VER
template <class _Tp, class _Allocator>
class __vector_base

View File

@ -15,7 +15,7 @@
#include <stdio.h> // vsprintf, vsnprintf
#include <string.h> // strcpy, wcsncpy
int asprintf(char **sptr, const char *__restrict__ fmt, ...)
int asprintf(char **sptr, const char *__restrict fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -23,7 +23,7 @@ int asprintf(char **sptr, const char *__restrict__ fmt, ...)
va_end(ap);
return result;
}
int vasprintf( char **sptr, const char *__restrict__ fmt, va_list ap )
int vasprintf( char **sptr, const char *__restrict fmt, va_list ap )
{
*sptr = NULL;
int count = vsnprintf( *sptr, 0, fmt, ap );
@ -38,8 +38,8 @@ int vasprintf( char **sptr, const char *__restrict__ fmt, va_list ap )
// FIXME: use wcrtomb and avoid copy
// use mbsrtowcs which is available, first copy first nwc elements of src
size_t mbsnrtowcs( wchar_t *__restrict__ dst, const char **__restrict__ src,
size_t nmc, size_t len, mbstate_t *__restrict__ ps )
size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
size_t nmc, size_t len, mbstate_t *__restrict ps )
{
char* local_src = new char[nmc+1];
char* nmcsrc = local_src;
@ -54,8 +54,8 @@ size_t mbsnrtowcs( wchar_t *__restrict__ dst, const char **__restrict__ src,
}
// FIXME: use wcrtomb and avoid copy
// use wcsrtombs which is available, first copy first nwc elements of src
size_t wcsnrtombs( char *__restrict__ dst, const wchar_t **__restrict__ src,
size_t nwc, size_t len, mbstate_t *__restrict__ ps )
size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
size_t nwc, size_t len, mbstate_t *__restrict ps )
{
wchar_t* local_src = new wchar_t[nwc];
wchar_t* nwcsrc = local_src;