Skip to content

Commit 7d6e34a

Browse files
Remove non-Standard TR1 (#5763)
1 parent 57c30ca commit 7d6e34a

File tree

24 files changed

+109
-2029
lines changed

24 files changed

+109
-2029
lines changed

benchmarks/src/random_integer_generation.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ BENCHMARK(BM_discard<std::mt19937>)->Range(0, 1 << 18);
4646
BENCHMARK(BM_discard<std::mt19937_64>)->Range(0, 1 << 18);
4747
BENCHMARK(BM_discard<std::minstd_rand>)->Range(0, 1 << 18);
4848

49-
/// Support machinery for testing _Rng_from_urng and _Rng_from_urng_v2
49+
/// Support machinery for testing _Rng_from_urng_v2
5050

5151
std::uint32_t GetMax() {
5252
std::mt19937 gen;
@@ -58,15 +58,6 @@ const std::uint32_t maximum = GetMax(); // random divisor to prevent strength re
5858

5959
/// Test mt19937
6060

61-
void BM_raw_mt19937_old(benchmark::State& state) {
62-
std::mt19937 gen;
63-
std::_Rng_from_urng<std::uint32_t, decltype(gen)> rng(gen);
64-
for (auto _ : state) {
65-
benchmark::DoNotOptimize(rng(maximum));
66-
}
67-
}
68-
BENCHMARK(BM_raw_mt19937_old);
69-
7061
void BM_raw_mt19937_new(benchmark::State& state) {
7162
std::mt19937 gen;
7263
std::_Rng_from_urng_v2<std::uint32_t, decltype(gen)> rng(gen);
@@ -78,15 +69,6 @@ BENCHMARK(BM_raw_mt19937_new);
7869

7970
/// Test mt19937_64
8071

81-
void BM_raw_mt19937_64_old(benchmark::State& state) {
82-
std::mt19937_64 gen;
83-
std::_Rng_from_urng<std::uint64_t, decltype(gen)> rng(gen);
84-
for (auto _ : state) {
85-
benchmark::DoNotOptimize(rng(maximum));
86-
}
87-
}
88-
BENCHMARK(BM_raw_mt19937_64_old);
89-
9072
void BM_raw_mt19937_64_new(benchmark::State& state) {
9173
std::mt19937_64 gen;
9274
std::_Rng_from_urng_v2<std::uint64_t, decltype(gen)> rng(gen);
@@ -98,15 +80,6 @@ BENCHMARK(BM_raw_mt19937_64_new);
9880

9981
/// Test minstd_rand
10082

101-
void BM_raw_lcg_old(benchmark::State& state) {
102-
std::minstd_rand gen;
103-
std::_Rng_from_urng<std::uint32_t, decltype(gen)> rng(gen);
104-
for (auto _ : state) {
105-
benchmark::DoNotOptimize(rng(maximum));
106-
}
107-
}
108-
BENCHMARK(BM_raw_lcg_old);
109-
11083
void BM_raw_lcg_new(benchmark::State& state) {
11184
std::minstd_rand gen;
11285
std::_Rng_from_urng_v2<std::uint32_t, decltype(gen)> rng(gen);

stl/inc/algorithm

Lines changed: 6 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -5953,73 +5953,6 @@ namespace ranges {
59535953
#endif // _HAS_CXX20
59545954
#endif // _HAS_CXX17
59555955

5956-
template <class _Diff, class _Urng>
5957-
class _Rng_from_urng { // wrap a URNG as an RNG
5958-
public:
5959-
using _Ty0 = make_unsigned_t<_Diff>;
5960-
using _Ty1 = _Invoke_result_t<_Urng&>;
5961-
5962-
using _Udiff = conditional_t<sizeof(_Ty1) < sizeof(_Ty0), _Ty0, _Ty1>;
5963-
5964-
explicit _Rng_from_urng(_Urng& _Func)
5965-
: _Ref(_Func), _Bits(CHAR_BIT * sizeof(_Udiff)), _Bmask(static_cast<_Udiff>(-1)) {
5966-
for (; static_cast<_Udiff>((_Urng::max) () - (_Urng::min) ()) < _Bmask; _Bmask >>= 1) {
5967-
--_Bits;
5968-
}
5969-
}
5970-
5971-
_Diff operator()(_Diff _Index) { // adapt _Urng closed range to [0, _Index)
5972-
for (;;) { // try a sample random value
5973-
_Udiff _Ret = 0; // random bits
5974-
_Udiff _Mask = 0; // 2^N - 1, _Ret is within [0, _Mask]
5975-
5976-
while (_Mask < static_cast<_Udiff>(_Index - 1)) { // need more random bits
5977-
_Ret <<= _Bits - 1; // avoid full shift
5978-
_Ret <<= 1;
5979-
_Ret |= _Get_bits();
5980-
_Mask <<= _Bits - 1; // avoid full shift
5981-
_Mask <<= 1;
5982-
_Mask |= _Bmask;
5983-
}
5984-
5985-
// _Ret is [0, _Mask], _Index - 1 <= _Mask, return if unbiased
5986-
if (_Ret / _Index < _Mask / _Index || _Mask % _Index == static_cast<_Udiff>(_Index - 1)) {
5987-
return static_cast<_Diff>(_Ret % _Index);
5988-
}
5989-
}
5990-
}
5991-
5992-
_Udiff _Get_all_bits() {
5993-
_Udiff _Ret = 0;
5994-
5995-
for (size_t _Num = 0; _Num < CHAR_BIT * sizeof(_Udiff); _Num += _Bits) { // don't mask away any bits
5996-
_Ret <<= _Bits - 1; // avoid full shift
5997-
_Ret <<= 1;
5998-
_Ret |= _Get_bits();
5999-
}
6000-
6001-
return _Ret;
6002-
}
6003-
6004-
_Rng_from_urng(const _Rng_from_urng&) = delete;
6005-
_Rng_from_urng& operator=(const _Rng_from_urng&) = delete;
6006-
6007-
private:
6008-
_Udiff _Get_bits() { // return a random value within [0, _Bmask]
6009-
for (;;) { // repeat until random value is in range
6010-
const _Udiff _Val = static_cast<_Udiff>(_Ref() - (_Urng::min) ());
6011-
6012-
if (_Val <= _Bmask) {
6013-
return _Val;
6014-
}
6015-
}
6016-
}
6017-
6018-
_Urng& _Ref; // reference to URNG
6019-
size_t _Bits; // number of random bits generated by _Get_bits()
6020-
_Udiff _Bmask; // 2^_Bits - 1
6021-
};
6022-
60235956
template <class _Diff, class _Urng>
60245957
class _Rng_from_urng_v2 { // wrap a URNG as an RNG
60255958
public:
@@ -6142,19 +6075,6 @@ private:
61426075
static constexpr _Udiff _Bmask = static_cast<_Udiff>(-1) >> (_Udiff_bits - _Bits); // 2^_Bits - 1
61436076
};
61446077

6145-
template <class _Gen, class = void>
6146-
constexpr bool _Has_static_min_max = false;
6147-
6148-
// This checks a requirement of N4981 [rand.req.urng] `concept uniform_random_bit_generator` but doesn't attempt
6149-
// to implement the whole concept - we just need to distinguish Standard machinery from tr1 machinery.
6150-
template <class _Gen>
6151-
constexpr bool _Has_static_min_max<_Gen, void_t<decltype(bool_constant<(_Gen::min) () < (_Gen::max) ()>::value)>> =
6152-
true;
6153-
6154-
template <class _Diff, class _Urng>
6155-
using _Rng_from_urng_v1_or_v2 =
6156-
conditional_t<_Has_static_min_max<_Urng>, _Rng_from_urng_v2<_Diff, _Urng>, _Rng_from_urng<_Diff, _Urng>>;
6157-
61586078
#if _HAS_CXX17
61596079
template <class _PopIt, class _SampleIt, class _Diff, class _RngFn>
61606080
_SampleIt _Sample_reservoir_unchecked(
@@ -6212,7 +6132,7 @@ _SampleIt sample(_PopIt _First, _PopIt _Last, _SampleIt _Dest, _Diff _Count, _Ur
62126132
auto _UFirst = _STD _Get_unwrapped(_First);
62136133
auto _ULast = _STD _Get_unwrapped(_Last);
62146134
using _PopDiff = _Iter_diff_t<_PopIt>;
6215-
_Rng_from_urng_v1_or_v2<_PopDiff, remove_reference_t<_Urng>> _RngFunc(_Func);
6135+
_Rng_from_urng_v2<_PopDiff, remove_reference_t<_Urng>> _RngFunc(_Func);
62166136
if constexpr (_Is_ranges_fwd_iter_v<_PopIt>) {
62176137
// source is forward: use selection sampling (stable)
62186138
using _CT = common_type_t<_Diff, _PopDiff>;
@@ -6255,7 +6175,7 @@ namespace ranges {
62556175
return _Output;
62566176
}
62576177

6258-
_Rng_from_urng_v1_or_v2<iter_difference_t<_It>, remove_reference_t<_Urng>> _RngFunc(_Func);
6178+
_Rng_from_urng_v2<iter_difference_t<_It>, remove_reference_t<_Urng>> _RngFunc(_Func);
62596179
if constexpr (forward_iterator<_It>) {
62606180
auto _UFirst = _RANGES _Unwrap_iter<_Se>(_STD move(_First));
62616181
auto _Pop_size = _RANGES distance(_UFirst, _RANGES _Unwrap_sent<_It>(_STD move(_Last)));
@@ -6276,7 +6196,7 @@ namespace ranges {
62766196
return _Output;
62776197
}
62786198

6279-
_Rng_from_urng_v1_or_v2<range_difference_t<_Rng>, remove_reference_t<_Urng>> _RngFunc(_Func);
6199+
_Rng_from_urng_v2<range_difference_t<_Rng>, remove_reference_t<_Urng>> _RngFunc(_Func);
62806200
if constexpr (forward_range<_Rng>) {
62816201
auto _UFirst = _Ubegin(_Range);
62826202
auto _Pop_size = _RANGES distance(_UFirst, _Uend(_Range));
@@ -6379,7 +6299,7 @@ void _Random_shuffle1(_RanIt _First, _RanIt _Last, _RngFn& _RngFunc) {
63796299
_EXPORT_STD template <class _RanIt, class _Urng>
63806300
void shuffle(_RanIt _First, _RanIt _Last, _Urng&& _Func) { // shuffle [_First, _Last) using URNG _Func
63816301
using _Urng0 = remove_reference_t<_Urng>;
6382-
_Rng_from_urng_v1_or_v2<_Iter_diff_t<_RanIt>, _Urng0> _RngFunc(_Func);
6302+
_Rng_from_urng_v2<_Iter_diff_t<_RanIt>, _Urng0> _RngFunc(_Func);
63836303
_STD _Random_shuffle1(_First, _Last, _RngFunc);
63846304
}
63856305

@@ -6392,7 +6312,7 @@ namespace ranges {
63926312
_STATIC_CALL_OPERATOR _It operator()(_It _First, _Se _Last, _Urng&& _Func) _CONST_CALL_OPERATOR {
63936313
_STD _Adl_verify_range(_First, _Last);
63946314

6395-
_Rng_from_urng_v1_or_v2<iter_difference_t<_It>, remove_reference_t<_Urng>> _RngFunc(_Func);
6315+
_Rng_from_urng_v2<iter_difference_t<_It>, remove_reference_t<_Urng>> _RngFunc(_Func);
63966316
auto _UResult = _Shuffle_unchecked(
63976317
_RANGES _Unwrap_iter<_Se>(_STD move(_First)), _RANGES _Unwrap_sent<_It>(_STD move(_Last)), _RngFunc);
63986318

@@ -6403,7 +6323,7 @@ namespace ranges {
64036323
template <random_access_range _Rng, class _Urng>
64046324
requires permutable<iterator_t<_Rng>> && uniform_random_bit_generator<remove_reference_t<_Urng>>
64056325
_STATIC_CALL_OPERATOR borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Urng&& _Func) _CONST_CALL_OPERATOR {
6406-
_Rng_from_urng_v1_or_v2<range_difference_t<_Rng>, remove_reference_t<_Urng>> _RngFunc(_Func);
6326+
_Rng_from_urng_v2<range_difference_t<_Rng>, remove_reference_t<_Urng>> _RngFunc(_Func);
64076327

64086328
return _RANGES _Rewrap_iterator(_Range, _Shuffle_unchecked(_Ubegin(_Range), _Uend(_Range), _RngFunc));
64096329
}

stl/inc/array

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,6 @@ public:
420420

421421
using _Library_defined = array;
422422

423-
#if _HAS_TR1_NAMESPACE
424-
_DEPRECATE_TR1_NAMESPACE void assign(const _Ty& _Value) {
425-
_STD fill_n(_Elems, _Size, _Value);
426-
}
427-
#endif // _HAS_TR1_NAMESPACE
428-
429423
_CONSTEXPR20 void fill(const _Ty& _Value) {
430424
_STD fill_n(_Elems, _Size, _Value);
431425
}
@@ -610,10 +604,6 @@ public:
610604

611605
using _Library_defined = array;
612606

613-
#if _HAS_TR1_NAMESPACE
614-
_DEPRECATE_TR1_NAMESPACE void assign(const _Ty&) {}
615-
#endif // _HAS_TR1_NAMESPACE
616-
617607
_CONSTEXPR20 void fill(const _Ty&) {}
618608

619609
_CONSTEXPR20 void swap(array&) noexcept {}
@@ -896,13 +886,6 @@ _NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept {
896886
return _STD move(_Arr[_Idx]);
897887
}
898888
}
899-
900-
#if _HAS_TR1_NAMESPACE
901-
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
902-
using _STD array;
903-
using _STD get;
904-
} // namespace _DEPRECATE_TR1_NAMESPACE tr1
905-
#endif // _HAS_TR1_NAMESPACE
906889
_STD_END
907890

908891
#pragma pop_macro("new")

stl/inc/cstdint

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,6 @@ _EXPORT_STD using _CSTD intmax_t;
4949
_EXPORT_STD using _CSTD intptr_t;
5050
_EXPORT_STD using _CSTD uintmax_t;
5151
_EXPORT_STD using _CSTD uintptr_t;
52-
53-
#if _HAS_TR1_NAMESPACE
54-
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
55-
using _CSTD int8_t;
56-
using _CSTD int16_t;
57-
using _CSTD int32_t;
58-
using _CSTD int64_t;
59-
using _CSTD uint8_t;
60-
using _CSTD uint16_t;
61-
using _CSTD uint32_t;
62-
using _CSTD uint64_t;
63-
64-
using _CSTD int_least8_t;
65-
using _CSTD int_least16_t;
66-
using _CSTD int_least32_t;
67-
using _CSTD int_least64_t;
68-
using _CSTD uint_least8_t;
69-
using _CSTD uint_least16_t;
70-
using _CSTD uint_least32_t;
71-
using _CSTD uint_least64_t;
72-
73-
using _CSTD int_fast8_t;
74-
using _CSTD int_fast16_t;
75-
using _CSTD int_fast32_t;
76-
using _CSTD int_fast64_t;
77-
using _CSTD uint_fast8_t;
78-
using _CSTD uint_fast16_t;
79-
using _CSTD uint_fast32_t;
80-
using _CSTD uint_fast64_t;
81-
82-
using _CSTD intmax_t;
83-
using _CSTD intptr_t;
84-
using _CSTD uintmax_t;
85-
using _CSTD uintptr_t;
86-
} // namespace _DEPRECATE_TR1_NAMESPACE tr1
87-
#endif // _HAS_TR1_NAMESPACE
8852
_STD_END
8953

9054
#pragma pop_macro("new")

stl/inc/functional

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,22 +3148,6 @@ namespace ranges {
31483148
};
31493149
} // namespace ranges
31503150
#endif // _HAS_CXX20
3151-
3152-
#if _HAS_TR1_NAMESPACE
3153-
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
3154-
using _STD bad_function_call;
3155-
using _STD bind;
3156-
using _STD function;
3157-
using _STD is_bind_expression;
3158-
using _STD is_placeholder;
3159-
using _STD mem_fn;
3160-
using _STD swap;
3161-
namespace placeholders {
3162-
using namespace _STD placeholders;
3163-
}
3164-
} // namespace _DEPRECATE_TR1_NAMESPACE tr1
3165-
#endif // _HAS_TR1_NAMESPACE
3166-
31673151
_STD_END
31683152

31693153
// TRANSITION, non-_Ugly attribute tokens

stl/inc/ios

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,6 @@ _EXPORT_STD inline ios_base& __CLRCALL_OR_CDECL uppercase(ios_base& _Iosbase) {
300300
_Iosbase.setf(ios_base::uppercase);
301301
return _Iosbase;
302302
}
303-
304-
#if _HAS_TR1_NAMESPACE
305-
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
306-
using _STD hexfloat;
307-
}
308-
#endif // _HAS_TR1_NAMESPACE
309-
310303
_STD_END
311304

312305
#pragma pop_macro("new")

stl/inc/memory

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,23 +4528,6 @@ _NODISCARD auto inout_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) {
45284528
}
45294529
}
45304530
#endif // _HAS_CXX23
4531-
4532-
#if _HAS_TR1_NAMESPACE
4533-
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
4534-
using _STD allocate_shared;
4535-
using _STD bad_weak_ptr;
4536-
using _STD const_pointer_cast;
4537-
using _STD dynamic_pointer_cast;
4538-
using _STD enable_shared_from_this;
4539-
using _STD get_deleter;
4540-
using _STD make_shared;
4541-
using _STD shared_ptr;
4542-
using _STD static_pointer_cast;
4543-
using _STD swap;
4544-
using _STD weak_ptr;
4545-
} // namespace _DEPRECATE_TR1_NAMESPACE tr1
4546-
#endif // _HAS_TR1_NAMESPACE
4547-
45484531
_STD_END
45494532

45504533
// TRANSITION, non-_Ugly attribute tokens

0 commit comments

Comments
 (0)