| 1 |
// { dg-do compile } |
| 2 |
// { dg-additional-options "-g" } |
| 3 |
|
| 4 |
namespace std { |
| 5 |
typedef __SIZE_TYPE__ size_t; |
| 6 |
typedef __PTRDIFF_TYPE__ ptrdiff_t; |
| 7 |
void __throw_length_error(const char *) __attribute__((__noreturn__, __cold__)); |
| 8 |
} |
| 9 |
extern "C++" { |
| 10 |
namespace std __attribute__((__visibility__("default"))) { |
| 11 |
template <typename _Tp> struct __is_integer { |
| 12 |
enum { __value = 1 }; |
| 13 |
}; |
| 14 |
template <typename _Tp> struct __is_nonvolatile_trivially_copyable { |
| 15 |
enum { __value = __is_trivially_copyable(_Tp) }; |
| 16 |
}; |
| 17 |
template <typename _OutputIter, typename _InputIter> struct __memcpyable {}; |
| 18 |
template <typename _Tp> |
| 19 |
struct __memcpyable<_Tp *, _Tp *> : __is_nonvolatile_trivially_copyable<_Tp> { |
| 20 |
}; |
| 21 |
template <typename _Tp> |
| 22 |
struct __memcpyable<_Tp *, const _Tp *> |
| 23 |
: __is_nonvolatile_trivially_copyable<_Tp> {}; |
| 24 |
template <typename _Tp> struct __is_move_iterator { |
| 25 |
enum { __value = 0 }; |
| 26 |
}; |
| 27 |
template <typename _Iterator> inline _Iterator __miter_base(_Iterator __it) { |
| 28 |
return __it; |
| 29 |
} |
| 30 |
} // namespace ) |
| 31 |
} |
| 32 |
namespace __gnu_cxx __attribute__((__visibility__("default"))) { |
| 33 |
template <typename _Tp> |
| 34 |
struct __is_integer_nonstrict : public std::__is_integer<_Tp> { |
| 35 |
using std::__is_integer<_Tp>::__value; |
| 36 |
enum { __width = __value ? sizeof(_Tp) * 8 : 0 }; |
| 37 |
}; |
| 38 |
template <typename _Value> struct __numeric_traits_integer { |
| 39 |
static const bool __is_signed = (_Value)(-1) < 0; |
| 40 |
static const int __digits = |
| 41 |
__is_integer_nonstrict<_Value>::__width - __is_signed; |
| 42 |
static const _Value __max = |
| 43 |
__is_signed ? (((((_Value)1 << (__digits - 1)) - 1) << 1) + 1) |
| 44 |
: ~(_Value)0; |
| 45 |
}; |
| 46 |
template <typename _Value> |
| 47 |
struct __numeric_traits : public __numeric_traits_integer<_Value> {}; |
| 48 |
} // namespace ) |
| 49 |
namespace std __attribute__((__visibility__("default"))) { |
| 50 |
template <typename _Tp, _Tp __v> struct integral_constant { |
| 51 |
static constexpr _Tp value = __v; |
| 52 |
using type = integral_constant<_Tp, __v>; |
| 53 |
}; |
| 54 |
template <bool __v> using __bool_constant = integral_constant<bool, __v>; |
| 55 |
using true_type = __bool_constant<true>; |
| 56 |
using false_type = __bool_constant<false>; |
| 57 |
template <bool, typename _Tp = void> struct enable_if {}; |
| 58 |
template <typename _Tp> struct enable_if<true, _Tp> { using type = _Tp; }; |
| 59 |
template <bool _Cond, typename _Tp = void> |
| 60 |
using __enable_if_t = typename enable_if<_Cond, _Tp>::type; |
| 61 |
template <bool> struct __conditional { |
| 62 |
template <typename _Tp, typename> using type = _Tp; |
| 63 |
}; |
| 64 |
template <bool _Cond, typename _If, typename _Else> |
| 65 |
using __conditional_t = |
| 66 |
typename __conditional<_Cond>::template type<_If, _Else>; |
| 67 |
namespace __detail { |
| 68 |
template <typename... _Bn> auto __and_fn(...) -> false_type; |
| 69 |
} |
| 70 |
template <typename... _Bn> |
| 71 |
struct __and_ : decltype(__detail::__and_fn<_Bn...>(0)) {}; |
| 72 |
template <typename _Pp> struct __not_ : __bool_constant<!bool(_Pp::value)> {}; |
| 73 |
template <typename...> using __void_t = void; |
| 74 |
template <typename _Tp> |
| 75 |
struct is_trivial : public __bool_constant<__is_trivial(_Tp)> {}; |
| 76 |
template <typename _Tp, typename _Up = _Tp &&> _Up __declval(int); |
| 77 |
template <typename _Tp> auto declval() noexcept->decltype(__declval<_Tp>(0)); |
| 78 |
template <typename _Tp, typename... _Args> |
| 79 |
using __is_constructible_impl = |
| 80 |
__bool_constant<__is_constructible(_Tp, _Args...)>; |
| 81 |
template <typename _Tp, typename = void> |
| 82 |
struct __add_lvalue_reference_helper { |
| 83 |
using type = _Tp &; |
| 84 |
}; |
| 85 |
template <typename _Tp> |
| 86 |
using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type; |
| 87 |
template <typename _Tp> |
| 88 |
struct is_copy_constructible |
| 89 |
: public __is_constructible_impl<_Tp, __add_lval_ref_t<const _Tp>> {}; |
| 90 |
template <typename _Tp, typename = void> |
| 91 |
struct __add_rvalue_reference_helper { |
| 92 |
using type = _Tp; |
| 93 |
}; |
| 94 |
template <typename _Tp> |
| 95 |
using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type; |
| 96 |
template <typename _Tp> |
| 97 |
struct is_move_constructible |
| 98 |
: public __is_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> {}; |
| 99 |
template <typename _Tp, typename... _Args> |
| 100 |
using __is_nothrow_constructible_impl = |
| 101 |
__bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; |
| 102 |
template <typename _Tp> |
| 103 |
struct is_nothrow_default_constructible |
| 104 |
: public __is_nothrow_constructible_impl<_Tp> {}; |
| 105 |
template <typename _Tp> |
| 106 |
struct is_nothrow_copy_constructible |
| 107 |
: public __is_nothrow_constructible_impl<_Tp, |
| 108 |
__add_lval_ref_t<const _Tp>> {}; |
| 109 |
template <typename _Tp> |
| 110 |
struct is_nothrow_move_constructible |
| 111 |
: public __is_nothrow_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> {}; |
| 112 |
template <typename _Tp> struct remove_reference { |
| 113 |
using type = __remove_reference(_Tp); |
| 114 |
}; |
| 115 |
template <typename _Tp> |
| 116 |
[[__nodiscard__]] constexpr _Tp &&forward( |
| 117 |
typename std::remove_reference<_Tp>::type & __t) noexcept { |
| 118 |
return static_cast<_Tp &&>(__t); |
| 119 |
} |
| 120 |
template <typename _Tp> |
| 121 |
[[__nodiscard__]] constexpr typename std::remove_reference<_Tp>::type &&move( |
| 122 |
_Tp && __t) noexcept { |
| 123 |
return static_cast<typename std::remove_reference<_Tp>::type &&>(__t); |
| 124 |
} |
| 125 |
template <typename _Tp> |
| 126 |
struct __move_if_noexcept_cond |
| 127 |
: public __and_<__not_<is_nothrow_move_constructible<_Tp>>, |
| 128 |
is_copy_constructible<_Tp>>::type {}; |
| 129 |
struct input_iterator_tag {}; |
| 130 |
struct forward_iterator_tag : public input_iterator_tag {}; |
| 131 |
struct bidirectional_iterator_tag : public forward_iterator_tag {}; |
| 132 |
struct random_access_iterator_tag : public bidirectional_iterator_tag {}; |
| 133 |
template <typename _Iterator, typename = __void_t<>> |
| 134 |
struct __iterator_traits { |
| 135 |
typedef typename _Iterator::value_type value_type; |
| 136 |
}; |
| 137 |
template <typename _Iterator> |
| 138 |
struct iterator_traits : public __iterator_traits<_Iterator> {}; |
| 139 |
template <typename _Tp> struct iterator_traits<_Tp *> { |
| 140 |
typedef random_access_iterator_tag iterator_category; |
| 141 |
typedef _Tp value_type; |
| 142 |
typedef ptrdiff_t difference_type; |
| 143 |
typedef _Tp &reference; |
| 144 |
}; |
| 145 |
template <typename _Iter> |
| 146 |
typename iterator_traits<_Iter>::iterator_category __iterator_category( |
| 147 |
const _Iter &) { |
| 148 |
return typename iterator_traits<_Iter>::iterator_category(); |
| 149 |
} |
| 150 |
template <typename _RandomAccessIterator> |
| 151 |
typename iterator_traits<_RandomAccessIterator>::difference_type __distance( |
| 152 |
_RandomAccessIterator __first, _RandomAccessIterator __last, |
| 153 |
random_access_iterator_tag) { |
| 154 |
return __last - __first; |
| 155 |
} |
| 156 |
template <typename _InputIterator> |
| 157 |
typename iterator_traits<_InputIterator>::difference_type distance( |
| 158 |
_InputIterator __first, _InputIterator __last) { |
| 159 |
return std::__distance(__first, __last, std::__iterator_category(__first)); |
| 160 |
} |
| 161 |
} // namespace ) |
| 162 |
namespace __gnu_cxx __attribute__((__visibility__("default"))) { |
| 163 |
template <typename _Iterator, typename _Container> class __normal_iterator { |
| 164 |
_Iterator _M_current; |
| 165 |
typedef std::iterator_traits<_Iterator> __traits_type; |
| 166 |
public: |
| 167 |
typedef typename __traits_type::value_type value_type; |
| 168 |
typedef typename __traits_type::difference_type difference_type; |
| 169 |
typedef typename __traits_type::reference reference; |
| 170 |
explicit __normal_iterator(const _Iterator &__i) noexcept |
| 171 |
: _M_current(__i) {} |
| 172 |
reference operator*() const noexcept { return *_M_current; } |
| 173 |
__normal_iterator &operator++() noexcept { |
| 174 |
++_M_current; |
| 175 |
return *this; |
| 176 |
} |
| 177 |
__normal_iterator &operator--() noexcept { |
| 178 |
--_M_current; |
| 179 |
return *this; |
| 180 |
} |
| 181 |
__normal_iterator operator+(difference_type __n) const noexcept { |
| 182 |
return __normal_iterator(_M_current + __n); |
| 183 |
} |
| 184 |
__normal_iterator operator-(difference_type __n) const noexcept { |
| 185 |
return __normal_iterator(_M_current - __n); |
| 186 |
} |
| 187 |
const _Iterator &base() const noexcept { return _M_current; } |
| 188 |
}; |
| 189 |
template <typename _IteratorL, typename _IteratorR, typename _Container> |
| 190 |
[[__nodiscard__]] inline bool operator!=( |
| 191 |
const __normal_iterator<_IteratorL, _Container> &__lhs, |
| 192 |
const __normal_iterator<_IteratorR, _Container> &__rhs) noexcept { |
| 193 |
return __lhs.base() != __rhs.base(); |
| 194 |
} |
| 195 |
template <typename _Iterator, typename _Container> |
| 196 |
typename __normal_iterator<_Iterator, _Container>::difference_type operator-( |
| 197 |
const __normal_iterator<_Iterator, _Container> &__lhs, |
| 198 |
const __normal_iterator<_Iterator, _Container> &__rhs) noexcept { |
| 199 |
return __lhs.base() - __rhs.base(); |
| 200 |
} |
| 201 |
} // namespace ) |
| 202 |
namespace std __attribute__((__visibility__("default"))) { |
| 203 |
} // namespace ) |
| 204 |
namespace __gnu_cxx { |
| 205 |
namespace __ops { |
| 206 |
template <typename _Compare> struct _Iter_comp_iter { |
| 207 |
_Compare _M_comp; |
| 208 |
explicit constexpr _Iter_comp_iter(_Compare __comp) |
| 209 |
: _M_comp(std::move(__comp)) {} |
| 210 |
template <typename _Iterator1, typename _Iterator2> |
| 211 |
constexpr bool operator()(_Iterator1 __it1, _Iterator2 __it2) { |
| 212 |
return bool(_M_comp(*__it1, *__it2)); |
| 213 |
} |
| 214 |
}; |
| 215 |
template <typename _Compare> |
| 216 |
constexpr inline _Iter_comp_iter<_Compare> __iter_comp_iter(_Compare __comp) { |
| 217 |
return _Iter_comp_iter<_Compare>(std::move(__comp)); |
| 218 |
} |
| 219 |
template <typename _Compare> struct _Val_comp_iter { |
| 220 |
_Compare _M_comp; |
| 221 |
explicit _Val_comp_iter(const _Iter_comp_iter<_Compare> &__comp) |
| 222 |
: _M_comp(std::move(__comp._M_comp)) {} |
| 223 |
template <typename _Value, typename _Iterator> |
| 224 |
bool operator()(_Value &__val, _Iterator __it) { |
| 225 |
return bool(_M_comp(__val, *__it)); |
| 226 |
} |
| 227 |
}; |
| 228 |
template <typename _Compare> |
| 229 |
inline _Val_comp_iter<_Compare> |
| 230 |
__val_comp_iter(_Iter_comp_iter<_Compare> __comp) { |
| 231 |
return _Val_comp_iter<_Compare>(std::move(__comp)); |
| 232 |
} |
| 233 |
} // namespace __ops |
| 234 |
} // namespace __gnu_cxx |
| 235 |
namespace std __attribute__((__visibility__("default"))) { |
| 236 |
template <typename _Tp> |
| 237 |
[[__nodiscard__]] constexpr inline const _Tp &min(const _Tp &__a, |
| 238 |
const _Tp &__b) { |
| 239 |
return __a; |
| 240 |
} |
| 241 |
template <typename _Tp> |
| 242 |
[[__nodiscard__]] constexpr inline const _Tp &max(const _Tp &__a, |
| 243 |
const _Tp &__b) { |
| 244 |
return __b; |
| 245 |
} |
| 246 |
template <typename _Iterator> |
| 247 |
inline _Iterator __niter_base(_Iterator __it) noexcept( |
| 248 |
std::is_nothrow_copy_constructible<_Iterator>::value) { |
| 249 |
return __it; |
| 250 |
} |
| 251 |
template <typename _Iterator> |
| 252 |
inline _Iterator __niter_wrap(const _Iterator &, _Iterator __res) { |
| 253 |
return __res; |
| 254 |
} |
| 255 |
template <bool _IsMove, bool _IsSimple, typename _Category> |
| 256 |
struct __copy_move { |
| 257 |
template <typename _Tp, typename _Up> |
| 258 |
static _Up *__copy_m(_Tp *__first, _Tp *__last, _Up *__result) { |
| 259 |
const ptrdiff_t _Num = __last - __first; |
| 260 |
return __result + _Num; |
| 261 |
} |
| 262 |
}; |
| 263 |
template <bool _IsMove, typename _II, typename _OI> |
| 264 |
inline _OI __copy_move_a2(_II __first, _II __last, _OI __result) { |
| 265 |
typedef typename iterator_traits<_II>::iterator_category _Category; |
| 266 |
return std::__copy_move<_IsMove, __memcpyable<_OI, _II>::__value, |
| 267 |
_Category>::__copy_m(__first, __last, __result); |
| 268 |
} |
| 269 |
template <bool _IsMove, typename _II, typename _OI> |
| 270 |
inline _OI __copy_move_a1(_II __first, _II __last, _OI __result) { |
| 271 |
return std::__copy_move_a2<_IsMove>(__first, __last, __result); |
| 272 |
} |
| 273 |
template <bool _IsMove, typename _II, typename _OI> |
| 274 |
inline _OI __copy_move_a(_II __first, _II __last, _OI __result) { |
| 275 |
return std::__niter_wrap( |
| 276 |
__result, std::__copy_move_a1<_IsMove>(std::__niter_base(__first), |
| 277 |
std::__niter_base(__last), |
| 278 |
std::__niter_base(__result))); |
| 279 |
} |
| 280 |
template <typename _II, typename _OI> |
| 281 |
inline _OI copy(_II __first, _II __last, _OI __result) { |
| 282 |
return std::__copy_move_a<__is_move_iterator<_II>::__value>( |
| 283 |
std::__miter_base(__first), std::__miter_base(__last), __result); |
| 284 |
} |
| 285 |
template <typename _Tp> class __new_allocator { |
| 286 |
public: |
| 287 |
typedef _Tp value_type; |
| 288 |
typedef std::size_t size_type; |
| 289 |
__attribute__((__always_inline__)) [[__nodiscard__]] _Tp * |
| 290 |
allocate(size_type __n, const void * = static_cast<const void *>(0)) { |
| 291 |
return static_cast<_Tp *>(::operator new(__n * sizeof(_Tp))); |
| 292 |
} |
| 293 |
__attribute__((__always_inline__)) size_type max_size() const noexcept { |
| 294 |
return _M_max_size(); |
| 295 |
} |
| 296 |
__attribute__((__always_inline__)) constexpr size_type |
| 297 |
_M_max_size() const noexcept { |
| 298 |
return std::size_t(0x7fffffffffffffffL) / sizeof(_Tp); |
| 299 |
} |
| 300 |
}; |
| 301 |
template <typename _Tp> using __allocator_base = __new_allocator<_Tp>; |
| 302 |
template <typename> struct allocator_traits; |
| 303 |
template <typename _Tp> class allocator : public __allocator_base<_Tp> {}; |
| 304 |
template <typename _Tp> struct allocator_traits<allocator<_Tp>> { |
| 305 |
using allocator_type = allocator<_Tp>; |
| 306 |
using value_type = _Tp; |
| 307 |
using pointer = _Tp *; |
| 308 |
using size_type = std::size_t; |
| 309 |
template <typename _Up> using rebind_alloc = allocator<_Up>; |
| 310 |
[[__nodiscard__, __gnu__::__always_inline__]] static pointer |
| 311 |
allocate(allocator_type &__a, size_type __n) { |
| 312 |
return __a.allocate(__n); |
| 313 |
} |
| 314 |
[[__gnu__::__always_inline__]] static size_type |
| 315 |
max_size(const allocator_type &__a __attribute__((__unused__))) noexcept { |
| 316 |
return __a.max_size(); |
| 317 |
} |
| 318 |
}; |
| 319 |
template <typename _Alloc, typename _Tp, typename = void> |
| 320 |
struct __is_alloc_insertable_impl : false_type {}; |
| 321 |
template <typename _Alloc> |
| 322 |
struct __is_move_insertable |
| 323 |
: __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type { |
| 324 |
}; |
| 325 |
template <typename _Tp> |
| 326 |
struct __is_move_insertable<allocator<_Tp>> : is_move_constructible<_Tp> {}; |
| 327 |
} // namespace ) |
| 328 |
namespace __gnu_cxx __attribute__((__visibility__("default"))) { |
| 329 |
template <typename _Alloc, typename = typename _Alloc::value_type> |
| 330 |
struct __alloc_traits : std::allocator_traits<_Alloc> { |
| 331 |
typedef std::allocator_traits<_Alloc> _Base_type; |
| 332 |
typedef typename _Base_type::value_type value_type; |
| 333 |
typedef value_type &reference; |
| 334 |
template <typename _Tp> struct rebind { |
| 335 |
typedef typename _Base_type::template rebind_alloc<_Tp> other; |
| 336 |
}; |
| 337 |
}; |
| 338 |
} // namespace ) |
| 339 |
namespace std __attribute__((__visibility__("default"))) { |
| 340 |
template <typename _ValueType, typename _Tp> |
| 341 |
constexpr bool __check_constructible() { |
| 342 |
return true; |
| 343 |
} |
| 344 |
template <bool _TrivialValueTypes> struct __uninitialized_copy { |
| 345 |
template <typename _InputIterator, typename _ForwardIterator> |
| 346 |
static _ForwardIterator __uninit_copy(_InputIterator __first, |
| 347 |
_InputIterator __last, |
| 348 |
_ForwardIterator __result) { |
| 349 |
return std::copy(__first, __last, __result); |
| 350 |
} |
| 351 |
}; |
| 352 |
template <typename _InputIterator, typename _ForwardIterator> |
| 353 |
inline _ForwardIterator uninitialized_copy(_InputIterator __first, |
| 354 |
_InputIterator __last, |
| 355 |
_ForwardIterator __result) { |
| 356 |
typedef typename iterator_traits<_InputIterator>::value_type _ValueType1; |
| 357 |
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType2; |
| 358 |
const bool __can_memmove = __is_trivial(_ValueType1); |
| 359 |
using _From = decltype(*__first); |
| 360 |
const bool __assignable = __is_trivial(_ValueType2) && |
| 361 |
std::__check_constructible<_ValueType2, _From>(); |
| 362 |
return std::__uninitialized_copy < __can_memmove && |
| 363 |
__assignable > ::__uninit_copy(__first, __last, __result); |
| 364 |
} |
| 365 |
template <typename _InputIterator, typename _ForwardIterator, typename _Tp> |
| 366 |
inline _ForwardIterator __uninitialized_copy_a( |
| 367 |
_InputIterator __first, _InputIterator __last, _ForwardIterator __result, |
| 368 |
allocator<_Tp> &) { |
| 369 |
return std::uninitialized_copy(__first, __last, __result); |
| 370 |
} |
| 371 |
template <typename _InputIterator, typename _ForwardIterator, |
| 372 |
typename _Allocator> |
| 373 |
inline _ForwardIterator __uninitialized_move_if_noexcept_a( |
| 374 |
_InputIterator __first, _InputIterator __last, _ForwardIterator __result, |
| 375 |
_Allocator & __alloc) { |
| 376 |
return std::__uninitialized_copy_a( |
| 377 |
__first, |
| 378 |
__last, __result, __alloc); |
| 379 |
} |
| 380 |
template <typename _Tp, typename = void> |
| 381 |
struct __is_bitwise_relocatable : is_trivial<_Tp> {}; |
| 382 |
template <typename _Tp, typename _Up> |
| 383 |
inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp *> |
| 384 |
__relocate_a_1(_Tp * __first, _Tp * __last, _Tp * __result, |
| 385 |
[[__maybe_unused__]] allocator<_Up> & __alloc) noexcept {} |
| 386 |
template <typename _InputIterator, typename _ForwardIterator, |
| 387 |
typename _Allocator> |
| 388 |
inline _ForwardIterator __relocate_a( |
| 389 |
_InputIterator __first, _InputIterator __last, _ForwardIterator __result, |
| 390 |
_Allocator & |
| 391 |
__alloc) noexcept(noexcept(__relocate_a_1(std::__niter_base(__first), |
| 392 |
std::__niter_base(__last), |
| 393 |
std::__niter_base(__result), |
| 394 |
__alloc))) {} |
| 395 |
template <class _E> class initializer_list { |
| 396 |
typedef size_t size_type; |
| 397 |
typedef const _E *iterator; |
| 398 |
typedef const _E *const_iterator; |
| 399 |
iterator _M_array; |
| 400 |
size_type _M_len; |
| 401 |
public: |
| 402 |
constexpr size_type size() const noexcept { return _M_len; } |
| 403 |
constexpr const_iterator begin() const noexcept { return _M_array; } |
| 404 |
constexpr const_iterator end() const noexcept { return begin() + size(); } |
| 405 |
}; |
| 406 |
template <typename _Tp, typename _Alloc> struct _Vector_base { |
| 407 |
typedef |
| 408 |
typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other |
| 409 |
_Tp_alloc_type; |
| 410 |
typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer pointer; |
| 411 |
struct _Vector_impl_data { |
| 412 |
pointer _M_start; |
| 413 |
pointer _M_finish; |
| 414 |
pointer _M_end_of_storage; |
| 415 |
_Vector_impl_data() noexcept |
| 416 |
: _M_start(), _M_finish(), _M_end_of_storage() {} |
| 417 |
}; |
| 418 |
struct _Vector_impl : public _Tp_alloc_type, public _Vector_impl_data { |
| 419 |
_Vector_impl() noexcept( |
| 420 |
is_nothrow_default_constructible<_Tp_alloc_type>::value) |
| 421 |
: _Tp_alloc_type() {} |
| 422 |
_Vector_impl(_Tp_alloc_type const &__a) noexcept : _Tp_alloc_type(__a) {} |
| 423 |
_Vector_impl(_Tp_alloc_type &&__a, _Vector_impl &&__rv) noexcept |
| 424 |
: _Tp_alloc_type(std::move(__a)), _Vector_impl_data(std::move(__rv)) { |
| 425 |
} |
| 426 |
}; |
| 427 |
typedef _Alloc allocator_type; |
| 428 |
_Tp_alloc_type &_M_get_Tp_allocator() noexcept { return this->_M_impl; } |
| 429 |
const _Tp_alloc_type &_M_get_Tp_allocator() const noexcept { |
| 430 |
return this->_M_impl; |
| 431 |
} |
| 432 |
_Vector_base() = default; |
| 433 |
_Vector_base(const allocator_type &__a) noexcept : _M_impl(__a) {} |
| 434 |
_Vector_impl _M_impl; |
| 435 |
pointer _M_allocate(size_t __n) { |
| 436 |
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; |
| 437 |
return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); |
| 438 |
} |
| 439 |
}; |
| 440 |
template <typename _Tp, typename _Alloc = std::allocator<_Tp>> |
| 441 |
class vector : protected _Vector_base<_Tp, _Alloc> { |
| 442 |
typedef _Vector_base<_Tp, _Alloc> _Base; |
| 443 |
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; |
| 444 |
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; |
| 445 |
typedef _Tp value_type; |
| 446 |
typedef typename _Base::pointer pointer; |
| 447 |
typedef typename _Alloc_traits::reference reference; |
| 448 |
typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator; |
| 449 |
typedef size_t size_type; |
| 450 |
typedef _Alloc allocator_type; |
| 451 |
static constexpr bool _S_nothrow_relocate(true_type) { |
| 452 |
return noexcept(std::__relocate_a( |
| 453 |
std::declval<pointer>(), std::declval<pointer>(), |
| 454 |
std::declval<pointer>(), std::declval<_Tp_alloc_type &>())); |
| 455 |
} |
| 456 |
static constexpr bool _S_use_relocate() { |
| 457 |
return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); |
| 458 |
} |
| 459 |
using _Base::_M_get_Tp_allocator; |
| 460 |
public: |
| 461 |
vector() = default; |
| 462 |
vector(initializer_list<value_type> __l, |
| 463 |
const allocator_type &__a = allocator_type()) |
| 464 |
: _Base(__a) { |
| 465 |
_M_range_initialize(__l.begin(), __l.end(), random_access_iterator_tag()); |
| 466 |
} |
| 467 |
[[__nodiscard__]] iterator begin() noexcept { |
| 468 |
return iterator(this->_M_impl._M_start); |
| 469 |
} |
| 470 |
[[__nodiscard__]] iterator end() noexcept { |
| 471 |
return iterator(this->_M_impl._M_finish); |
| 472 |
} |
| 473 |
[[__nodiscard__]] size_type size() const noexcept { |
| 474 |
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); |
| 475 |
} |
| 476 |
[[__nodiscard__]] size_type max_size() const noexcept { |
| 477 |
return _S_max_size(_M_get_Tp_allocator()); |
| 478 |
} |
| 479 |
[[__nodiscard__]] reference back() noexcept { return *(end() - 1); } |
| 480 |
void push_back(value_type &&__x) { emplace_back(std::move(__x)); } |
| 481 |
template <typename... _Args> reference emplace_back(_Args &&...__args); |
| 482 |
template <typename _ForwardIterator> |
| 483 |
void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, |
| 484 |
std::forward_iterator_tag) { |
| 485 |
const size_type __n = std::distance(__first, __last); |
| 486 |
this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator())); |
| 487 |
this->_M_impl._M_finish = std::__uninitialized_copy_a( |
| 488 |
__first, __last, this->_M_impl._M_start, _M_get_Tp_allocator()); |
| 489 |
} |
| 490 |
template <typename... _Args> void _M_realloc_append(_Args &&...__args); |
| 491 |
size_type _M_check_len(size_type __n, const char *__s) const { |
| 492 |
const size_type __len = size() + (std::max)(size(), __n); |
| 493 |
return (__len < size() || __len > max_size()) ? max_size() : __len; |
| 494 |
} |
| 495 |
static size_type _S_check_init_len(size_type __n, |
| 496 |
const allocator_type &__a) { |
| 497 |
if (__n > _S_max_size(_Tp_alloc_type(__a))) |
| 498 |
__throw_length_error( |
| 499 |
("cannot create std::vector larger than max_size()")); |
| 500 |
return __n; |
| 501 |
} |
| 502 |
static size_type _S_max_size(const _Tp_alloc_type &__a) noexcept { |
| 503 |
const size_t __diffmax = |
| 504 |
__gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp); |
| 505 |
return __diffmax; |
| 506 |
} |
| 507 |
}; |
| 508 |
|
| 509 |
template <typename _Tp> |
| 510 |
struct greater { |
| 511 |
constexpr bool operator()(const _Tp &__x, const _Tp &__y) const { |
| 512 |
return __x > __y; |
| 513 |
} |
| 514 |
}; |
| 515 |
template <typename _Tp, typename _Alloc> |
| 516 |
template <typename... _Args> |
| 517 |
typename vector<_Tp, _Alloc>::reference vector<_Tp, _Alloc>::emplace_back( |
| 518 |
_Args && ...__args) { |
| 519 |
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) { |
| 520 |
++this->_M_impl._M_finish; |
| 521 |
} else |
| 522 |
_M_realloc_append(std::forward<_Args>(__args)...); |
| 523 |
return back(); |
| 524 |
} |
| 525 |
template <typename _Tp, typename _Alloc> |
| 526 |
template <typename... _Args> |
| 527 |
void vector<_Tp, _Alloc>::_M_realloc_append(_Args && ...__args) { |
| 528 |
const size_type __len = _M_check_len(1u, "vector::_M_realloc_append"); |
| 529 |
pointer __old_start = this->_M_impl._M_start; |
| 530 |
pointer __old_finish = this->_M_impl._M_finish; |
| 531 |
pointer __new_start(this->_M_allocate(__len)); |
| 532 |
pointer __new_finish(__new_start); |
| 533 |
{ |
| 534 |
if constexpr (_S_use_relocate()) { |
| 535 |
__new_finish = std::__uninitialized_move_if_noexcept_a( |
| 536 |
__old_start, __old_finish, __new_start, _M_get_Tp_allocator()); |
| 537 |
} |
| 538 |
} |
| 539 |
this->_M_impl._M_start = __new_start; |
| 540 |
this->_M_impl._M_finish = __new_finish; |
| 541 |
this->_M_impl._M_end_of_storage = __new_start + __len; |
| 542 |
} |
| 543 |
template <typename _RandomAccessIterator, typename _Compare> |
| 544 |
void __unguarded_linear_insert(_RandomAccessIterator __last, |
| 545 |
_Compare __comp) { |
| 546 |
typename iterator_traits<_RandomAccessIterator>::value_type __val = |
| 547 |
std::move(*__last); |
| 548 |
_RandomAccessIterator __next = __last; |
| 549 |
--__next; |
| 550 |
while (__comp(__val, __next)) { |
| 551 |
*__last = std::move(*__next); |
| 552 |
__last = __next; |
| 553 |
} |
| 554 |
} |
| 555 |
template <typename _RandomAccessIterator, typename _Compare> |
| 556 |
void __insertion_sort(_RandomAccessIterator __first, |
| 557 |
_RandomAccessIterator __last, _Compare __comp) { |
| 558 |
for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) { |
| 559 |
std::__unguarded_linear_insert(__i, |
| 560 |
__gnu_cxx::__ops::__val_comp_iter(__comp)); |
| 561 |
} |
| 562 |
} |
| 563 |
template <typename _RandomAccessIterator, typename _Compare> |
| 564 |
inline void __unguarded_insertion_sort(_RandomAccessIterator __first, |
| 565 |
_RandomAccessIterator __last, |
| 566 |
_Compare __comp) { |
| 567 |
for (_RandomAccessIterator __i = __first; __i != __last; ++__i) |
| 568 |
std::__unguarded_linear_insert(__i, |
| 569 |
__gnu_cxx::__ops::__val_comp_iter(__comp)); |
| 570 |
} |
| 571 |
enum { _S_threshold = 16 }; |
| 572 |
template <typename _RandomAccessIterator, typename _Compare> |
| 573 |
void __final_insertion_sort(_RandomAccessIterator __first, |
| 574 |
_RandomAccessIterator __last, _Compare __comp) { |
| 575 |
if (__last - __first > int(_S_threshold)) { |
| 576 |
std::__insertion_sort(__first, __first + int(_S_threshold), __comp); |
| 577 |
std::__unguarded_insertion_sort(__first + int(_S_threshold), __last, |
| 578 |
__comp); |
| 579 |
} |
| 580 |
} |
| 581 |
template <typename _RandomAccessIterator, typename _Compare> |
| 582 |
inline void __sort(_RandomAccessIterator __first, |
| 583 |
_RandomAccessIterator __last, _Compare __comp) { |
| 584 |
if (__first != __last) { |
| 585 |
std::__final_insertion_sort(__first, __last, __comp); |
| 586 |
} |
| 587 |
} |
| 588 |
template <typename _RandomAccessIterator, typename _Compare> |
| 589 |
inline void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, |
| 590 |
_Compare __comp) { |
| 591 |
std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); |
| 592 |
} |
| 593 |
} |
| 594 |
|
| 595 |
|
| 596 |
void g(); |
| 597 |
|
| 598 |
void f(int nBands, double maxZErr) { |
| 599 |
for (int iBand = 0; iBand < nBands; iBand++) |
| 600 |
{ |
| 601 |
g(); |
| 602 |
std::vector<signed char> noDataCandVec; |
| 603 |
std::vector<signed char> distCandVec = {0, 1, 10, 100, 5, 6}; |
| 604 |
for (signed char dist : distCandVec) |
| 605 |
noDataCandVec.push_back(1); |
| 606 |
std::sort(noDataCandVec.begin(), noDataCandVec.end(), |
| 607 |
std::greater<double>()); |
| 608 |
} |
| 609 |
} |