Skip to content

Commit

Permalink
Fix compilation issues with MSVC
Browse files Browse the repository at this point in the history
`_D1` and `_D2` are macros defined in MSVC xmath.hpp

#fixes Missing symbols in MSVC C++ compilation, many headers fail to compile #354
  • Loading branch information
miscco committed Feb 23, 2023
1 parent 91e3674 commit 708cf6f
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
{
typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _Diff1;
typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _Diff2;
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
const _D2 __len2 = __last2 - __first2;
const __Diff2 __len2 = __last2 - __first2;
if (__len2 == 0)
return _CUDA_VSTD::make_pair(__first1, __first1);
const _D1 __len1 = __last1 - __first1;
const __Diff1 __len1 = __last1 - __first1;
if (__len1 < __len2)
return _CUDA_VSTD::make_pair(__last1, __last1);
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
Expand Down
22 changes: 11 additions & 11 deletions include/cuda/std/detail/libcxx/include/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,9 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
return true;

// __first1 != __last1 && *__first1 != *__first2
typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
_D1 __l1 = _CUDA_VSTD::distance(__first1, __last1);
if (__l1 == _D1(1))
typedef typename iterator_traits<_ForwardIterator1>::difference_type _Diff1;
_Diff1 __l1 = _CUDA_VSTD::distance(__first1, __last1);
if (__l1 == _Diff1(1))
return false;
_ForwardIterator2 __last2 = _CUDA_VSTD::next(__first2, __l1);
// For each element in [f1, l1) see if there are the same number of
Expand All @@ -1374,14 +1374,14 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
break;
if (__match == __i) {
// Count number of *__i in [f2, l2)
_D1 __c2 = 0;
_Diff1 __c2 = 0;
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
if (__pred(*__i, *__j))
++__c2;
if (__c2 == 0)
return false;
// Count number of *__i in [__i, l1) (we can start with 1)
_D1 __c1 = 1;
_Diff1 __c1 = 1;
for (_ForwardIterator1 __j = _CUDA_VSTD::next(__i); __j != __last1; ++__j)
if (__pred(*__i, *__j))
++__c1;
Expand Down Expand Up @@ -1422,11 +1422,11 @@ __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
else if (__first2 == __last2)
return false;

typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
_D1 __l1 = _CUDA_VSTD::distance(__first1, __last1);
typedef typename iterator_traits<_ForwardIterator1>::difference_type _Diff1;
_Diff1 __l1 = _CUDA_VSTD::distance(__first1, __last1);

typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
_D2 __l2 = _CUDA_VSTD::distance(__first2, __last2);
typedef typename iterator_traits<_ForwardIterator2>::difference_type _Diff2;
__Diff2 __l2 = _CUDA_VSTD::distance(__first2, __last2);
if (__l1 != __l2)
return false;

Expand All @@ -1441,14 +1441,14 @@ __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
break;
if (__match == __i) {
// Count number of *__i in [f2, l2)
_D1 __c2 = 0;
_Diff1 __c2 = 0;
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
if (__pred(*__i, *__j))
++__c2;
if (__c2 == 0)
return false;
// Count number of *__i in [__i, l1) (we can start with 1)
_D1 __c1 = 1;
_Diff1 __c1 = 1;
for (_ForwardIterator1 __j = _CUDA_VSTD::next(__i); __j != __last1; ++__j)
if (__pred(*__i, *__j))
++__c1;
Expand Down
Loading

0 comments on commit 708cf6f

Please sign in to comment.