@@ -952,6 +952,13 @@ protected:
952
952
typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
953
953
difference_type> const_iterator;
954
954
955
+ public:
956
+ typedef integral_constant<bool ,
957
+ is_trivially_relocatable<pointer>::value &&
958
+ is_trivially_relocatable<__pointer_allocator>::value &&
959
+ is_trivially_relocatable<size_type>::value &&
960
+ is_trivially_relocatable<allocator_type>::value
961
+ > __allow_trivial_relocation;
955
962
protected:
956
963
__map __map_;
957
964
size_type __start_;
@@ -1190,9 +1197,43 @@ __deque_base<_Tp, _Allocator>::clear() _NOEXCEPT
1190
1197
}
1191
1198
}
1192
1199
1200
+ template <class _Tp , class _Allocator , bool = __deque_base<_Tp, _Allocator>::__allow_trivial_relocation::value>
1201
+ class _LIBCPP_TEMPLATE_VIS __deque_relocate_base
1202
+ : protected __deque_base<_Tp, _Allocator>
1203
+ {
1204
+ protected:
1205
+ #ifndef _LIBCPP_CXX03_LANG
1206
+ using __deque_base<_Tp, _Allocator>::__deque_base;
1207
+ #else
1208
+ _LIBCPP_INLINE_VISIBILITY
1209
+ __deque_relocate_base () = default;
1210
+
1211
+ _LIBCPP_INLINE_VISIBILITY
1212
+ __deque_relocate_base (const _Allocator& __a)
1213
+ : __deque_base<_Tp, _Allocator>(__a) {}
1214
+ #endif // _LIBCPP_CXX03_LANG
1215
+ };
1216
+
1217
+ template <class _Tp , class _Allocator >
1218
+ class _LIBCPP_TEMPLATE_VIS _LIBCPP_TRIVIALLY_RELOCATABLE __deque_relocate_base<_Tp, _Allocator, true >
1219
+ : protected __deque_base<_Tp, _Allocator>
1220
+ {
1221
+ protected:
1222
+ #ifndef _LIBCPP_CXX03_LANG
1223
+ using __deque_base<_Tp, _Allocator>::__deque_base;
1224
+ #else
1225
+ _LIBCPP_INLINE_VISIBILITY
1226
+ __deque_relocate_base () = default;
1227
+
1228
+ _LIBCPP_INLINE_VISIBILITY
1229
+ __deque_relocate_base (const _Allocator& __a)
1230
+ : __deque_base<_Tp, _Allocator>(__a) {}
1231
+ #endif // _LIBCPP_CXX03_LANG
1232
+ };
1233
+
1193
1234
template <class _Tp , class _Allocator /* = allocator<_Tp>*/ >
1194
1235
class _LIBCPP_TEMPLATE_VIS deque
1195
- : private __deque_base <_Tp, _Allocator>
1236
+ : private __deque_relocate_base <_Tp, _Allocator>
1196
1237
{
1197
1238
public:
1198
1239
// types:
@@ -1203,6 +1244,7 @@ public:
1203
1244
static_assert ((is_same<typename allocator_type::value_type, value_type>::value),
1204
1245
" Allocator::value_type must be same type as value_type" );
1205
1246
1247
+ typedef __deque_relocate_base<value_type, allocator_type> __relocate_base;
1206
1248
typedef __deque_base<value_type, allocator_type> __base;
1207
1249
1208
1250
typedef typename __base::__alloc_traits __alloc_traits;
@@ -1223,7 +1265,7 @@ public:
1223
1265
deque ()
1224
1266
_NOEXCEPT_ (is_nothrow_default_constructible<allocator_type>::value)
1225
1267
{}
1226
- _LIBCPP_INLINE_VISIBILITY explicit deque (const allocator_type& __a) : __base (__a) {}
1268
+ _LIBCPP_INLINE_VISIBILITY explicit deque (const allocator_type& __a) : __relocate_base (__a) {}
1227
1269
explicit deque (size_type __n);
1228
1270
#if _LIBCPP_STD_VER > 11
1229
1271
explicit deque (size_type __n, const _Allocator& __a);
@@ -1249,7 +1291,7 @@ public:
1249
1291
deque& operator =(initializer_list<value_type> __il) {assign (__il); return *this ;}
1250
1292
1251
1293
_LIBCPP_INLINE_VISIBILITY
1252
- deque (deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) ;
1294
+ deque (deque&& __c) = default ;
1253
1295
_LIBCPP_INLINE_VISIBILITY
1254
1296
deque (deque&& __c, const allocator_type& __a);
1255
1297
_LIBCPP_INLINE_VISIBILITY
@@ -1495,7 +1537,7 @@ deque<_Tp, _Allocator>::deque(size_type __n)
1495
1537
#if _LIBCPP_STD_VER > 11
1496
1538
template <class _Tp , class _Allocator >
1497
1539
deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
1498
- : __base (__a)
1540
+ : __relocate_base (__a)
1499
1541
{
1500
1542
if (__n > 0 )
1501
1543
__append (__n);
@@ -1511,7 +1553,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
1511
1553
1512
1554
template <class _Tp , class _Allocator >
1513
1555
deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v, const allocator_type& __a)
1514
- : __base (__a)
1556
+ : __relocate_base (__a)
1515
1557
{
1516
1558
if (__n > 0 )
1517
1559
__append (__n, __v);
@@ -1529,21 +1571,21 @@ template <class _Tp, class _Allocator>
1529
1571
template <class _InputIter >
1530
1572
deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
1531
1573
typename enable_if<__is_input_iterator<_InputIter>::value>::type*)
1532
- : __base (__a)
1574
+ : __relocate_base (__a)
1533
1575
{
1534
1576
__append (__f, __l);
1535
1577
}
1536
1578
1537
1579
template <class _Tp , class _Allocator >
1538
1580
deque<_Tp, _Allocator>::deque(const deque& __c)
1539
- : __base (__alloc_traits::select_on_container_copy_construction(__c.__alloc()))
1581
+ : __relocate_base (__alloc_traits::select_on_container_copy_construction(__c.__alloc()))
1540
1582
{
1541
1583
__append (__c.begin (), __c.end ());
1542
1584
}
1543
1585
1544
1586
template <class _Tp , class _Allocator >
1545
1587
deque<_Tp, _Allocator>::deque(const deque& __c, const allocator_type& __a)
1546
- : __base (__a)
1588
+ : __relocate_base (__a)
1547
1589
{
1548
1590
__append (__c.begin (), __c.end ());
1549
1591
}
@@ -1570,23 +1612,15 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)
1570
1612
1571
1613
template <class _Tp , class _Allocator >
1572
1614
deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)
1573
- : __base (__a)
1615
+ : __relocate_base (__a)
1574
1616
{
1575
1617
__append (__il.begin (), __il.end ());
1576
1618
}
1577
1619
1578
- template <class _Tp , class _Allocator >
1579
- inline
1580
- deque<_Tp, _Allocator>::deque(deque&& __c)
1581
- _NOEXCEPT_ (is_nothrow_move_constructible<__base>::value)
1582
- : __base(_VSTD::move(__c))
1583
- {
1584
- }
1585
-
1586
1620
template <class _Tp , class _Allocator >
1587
1621
inline
1588
1622
deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a)
1589
- : __base (_VSTD::move(__c), __a)
1623
+ : __relocate_base (_VSTD::move(__c), __a)
1590
1624
{
1591
1625
if (__a != __c.__alloc ())
1592
1626
{
0 commit comments