Revert "Merge to upstream r304942."
This reverts commit83b1388ecd, reversing changes made tof20819f925. Test: treehugger Bug: None
This commit is contained in:
@@ -35,9 +35,6 @@ template <class InputIterator, class Function>
|
||||
Function
|
||||
for_each(InputIterator first, InputIterator last, Function f);
|
||||
|
||||
template<class InputIterator, class Size, class Function>
|
||||
InputIterator for_each_n(InputIterator first, Size n, Function f); // C++17
|
||||
|
||||
template <class InputIterator, class T>
|
||||
InputIterator
|
||||
find(InputIterator first, InputIterator last, const T& value);
|
||||
@@ -284,12 +281,12 @@ template <class ForwardIterator, class OutputIterator>
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14
|
||||
|
||||
template <class RandomAccessIterator, class RandomNumberGenerator>
|
||||
void
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
|
||||
RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
|
||||
RandomNumberGenerator& rand); // deprecated in C++14
|
||||
|
||||
template<class PopulationIterator, class SampleIterator,
|
||||
class Distance, class UniformRandomBitGenerator>
|
||||
@@ -647,20 +644,18 @@ template <class BidirectionalIterator, class Compare>
|
||||
#if defined(__IBMCPP__)
|
||||
#include "support/ibm/support.h"
|
||||
#endif
|
||||
#if defined(_LIBCPP_COMPILER_MSVC)
|
||||
#include <intrin.h>
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
#include "support/win32/support.h"
|
||||
#endif
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
|
||||
@@ -788,132 +783,51 @@ struct __debug_less
|
||||
|
||||
// Precondition: __x != 0
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned __ctz(unsigned __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
unsigned
|
||||
__ctz(unsigned __x)
|
||||
{
|
||||
return static_cast<unsigned>(__builtin_ctz(__x));
|
||||
#else
|
||||
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
|
||||
static_assert(sizeof(unsigned long) == 4, "");
|
||||
unsigned long where;
|
||||
// Search from LSB to MSB for first set bit.
|
||||
// Returns zero if no set bit is found.
|
||||
if (_BitScanForward(&where, mask))
|
||||
return where;
|
||||
return 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned long __ctz(unsigned long __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
unsigned long
|
||||
__ctz(unsigned long __x)
|
||||
{
|
||||
return static_cast<unsigned long>(__builtin_ctzl(__x));
|
||||
#else
|
||||
static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
|
||||
return __ctz(static_cast<unsigned>(__x));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned long long __ctz(unsigned long long __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
unsigned long long
|
||||
__ctz(unsigned long long __x)
|
||||
{
|
||||
return static_cast<unsigned long long>(__builtin_ctzll(__x));
|
||||
#else
|
||||
unsigned long where;
|
||||
// Search from LSB to MSB for first set bit.
|
||||
// Returns zero if no set bit is found.
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
(defined(_M_AMD64) || defined(__x86_64__))
|
||||
if (_BitScanForward64(&where, mask))
|
||||
return static_cast<int>(where);
|
||||
#else
|
||||
// Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
|
||||
// Scan the Low Word.
|
||||
if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
|
||||
return where;
|
||||
// Scan the High Word.
|
||||
if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
|
||||
return where + 32; // Create a bit offset from the LSB.
|
||||
#endif
|
||||
return 64;
|
||||
#endif // _LIBCPP_COMPILER_MSVC
|
||||
}
|
||||
|
||||
// Precondition: __x != 0
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned __clz(unsigned __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
unsigned
|
||||
__clz(unsigned __x)
|
||||
{
|
||||
return static_cast<unsigned>(__builtin_clz(__x));
|
||||
#else
|
||||
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
|
||||
static_assert(sizeof(unsigned long) == 4, "");
|
||||
unsigned long where;
|
||||
// Search from LSB to MSB for first set bit.
|
||||
// Returns zero if no set bit is found.
|
||||
if (_BitScanReverse(&where, mask))
|
||||
return 31 - where;
|
||||
return 32; // Undefined Behavior.
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned long __clz(unsigned long __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
unsigned long
|
||||
__clz(unsigned long __x)
|
||||
{
|
||||
return static_cast<unsigned long>(__builtin_clzl (__x));
|
||||
#else
|
||||
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
|
||||
return __clz(static_cast<unsigned>(__x));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned long long __clz(unsigned long long __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
unsigned long long
|
||||
__clz(unsigned long long __x)
|
||||
{
|
||||
return static_cast<unsigned long long>(__builtin_clzll(__x));
|
||||
#else
|
||||
unsigned long where;
|
||||
// BitScanReverse scans from MSB to LSB for first set bit.
|
||||
// Returns 0 if no set bit is found.
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
if (_BitScanReverse64(&where, mask))
|
||||
return static_cast<int>(63 - where);
|
||||
#else
|
||||
// Scan the high 32 bits.
|
||||
if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
|
||||
return 63 - (where + 32); // Create a bit offset from the MSB.
|
||||
// Scan the low 32 bits.
|
||||
if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
|
||||
return 63 - where;
|
||||
#endif
|
||||
return 64; // Undefined Behavior.
|
||||
#endif // _LIBCPP_COMPILER_MSVC
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
return __builtin_popcount (__x);
|
||||
#else
|
||||
static_assert(sizeof(unsigned) == 4, "");
|
||||
return __popcnt(__x);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
return __builtin_popcountl (__x);
|
||||
#else
|
||||
static_assert(sizeof(unsigned long) == 4, "");
|
||||
return __popcnt(__x);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
return __builtin_popcountll(__x);
|
||||
#else
|
||||
static_assert(sizeof(unsigned long long) == 8, "");
|
||||
return __popcnt64(__x);
|
||||
#endif
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {return __builtin_popcount (__x);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long __x) {return __builtin_popcountl (__x);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {return __builtin_popcountll(__x);}
|
||||
|
||||
// all_of
|
||||
|
||||
@@ -966,26 +880,6 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
|
||||
return __f;
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
// for_each_n
|
||||
|
||||
template <class _InputIterator, class _Size, class _Function>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_InputIterator
|
||||
for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
|
||||
{
|
||||
typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
|
||||
_IntegralSize __n = __orig_n;
|
||||
while (__n > 0)
|
||||
{
|
||||
__f(*__first);
|
||||
++__first;
|
||||
--__n;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
#endif
|
||||
|
||||
// find
|
||||
|
||||
template <class _InputIterator, class _Tp>
|
||||
@@ -2654,7 +2548,7 @@ min(const _Tp& __a, const _Tp& __b)
|
||||
return _VSTD::min(__a, __b, __less<_Tp>());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
@@ -2672,7 +2566,7 @@ min(initializer_list<_Tp> __t)
|
||||
return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
// max_element
|
||||
|
||||
@@ -2719,7 +2613,7 @@ max(const _Tp& __a, const _Tp& __b)
|
||||
return _VSTD::max(__a, __b, __less<_Tp>());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
@@ -2737,7 +2631,7 @@ max(initializer_list<_Tp> __t)
|
||||
return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
// clamp
|
||||
@@ -2838,7 +2732,7 @@ minmax(const _Tp& __a, const _Tp& __b)
|
||||
return _VSTD::minmax(__a, __b, __less<_Tp>());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
@@ -2885,7 +2779,7 @@ minmax(initializer_list<_Tp> __t)
|
||||
return _VSTD::minmax(__t, __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
// random_shuffle
|
||||
|
||||
@@ -2910,11 +2804,11 @@ struct __log2_imp<0, _Rp>
|
||||
static const size_t value = _Rp + 1;
|
||||
};
|
||||
|
||||
template <class _UIntType, _UIntType _Xp>
|
||||
template <class _UI, _UI _Xp>
|
||||
struct __log2
|
||||
{
|
||||
static const size_t value = __log2_imp<_Xp,
|
||||
sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
|
||||
sizeof(_UI) * __CHAR_BIT__ - 1>::value;
|
||||
};
|
||||
|
||||
template<class _Engine, class _UIntType>
|
||||
@@ -2943,7 +2837,7 @@ private:
|
||||
_Engine_result_type __mask0_;
|
||||
_Engine_result_type __mask1_;
|
||||
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
#ifdef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
|
||||
+ _Working_result_type(1);
|
||||
#else
|
||||
@@ -3132,8 +3026,6 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
|
||||
return static_cast<result_type>(__u + __p.a());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
|
||||
|| defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
class _LIBCPP_TYPE_VIS __rs_default;
|
||||
|
||||
_LIBCPP_FUNC_VIS __rs_default __rs_get();
|
||||
@@ -3186,7 +3078,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
template <class _RandomAccessIterator, class _RandomNumberGenerator>
|
||||
void
|
||||
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_RandomNumberGenerator&& __rand)
|
||||
#else
|
||||
_RandomNumberGenerator& __rand)
|
||||
@@ -3203,7 +3095,6 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
@@ -3279,7 +3170,7 @@ _SampleIterator sample(_PopulationIterator __first,
|
||||
|
||||
template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
|
||||
void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_UniformRandomNumberGenerator&& __g)
|
||||
#else
|
||||
_UniformRandomNumberGenerator& __g)
|
||||
@@ -5906,6 +5797,4 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_ALGORITHM
|
||||
|
||||
Reference in New Issue
Block a user