@@ -23,8 +23,8 @@ _STL_DISABLE_CLANG_WARNINGS
23
23
#undef new
24
24
25
25
// TRANSITION, non-_Ugly attribute tokens
26
- #pragma push_macro("empty_bases ")
27
- #undef empty_bases
26
+ #pragma push_macro("msvc ")
27
+ #undef msvc
28
28
29
29
_STD_BEGIN
30
30
template <class _IndexType, size_t _Size>
@@ -1073,37 +1073,37 @@ concept _Elidable_layout_mapping =
1073
1073
|| (same_as<_LayoutPolicy, layout_stride> && _Extents::rank() == 0);
1074
1074
1075
1075
template <class _Extents, class _LayoutPolicy>
1076
- struct _Mdspan_mapping_base {
1076
+ struct _Mdspan_mapping_holder {
1077
1077
_STL_INTERNAL_STATIC_ASSERT(_Is_extents<_Extents>);
1078
1078
1079
1079
using _Mapping = _LayoutPolicy::template mapping<_Extents>;
1080
1080
1081
- constexpr _Mdspan_mapping_base () noexcept = default;
1081
+ constexpr _Mdspan_mapping_holder () noexcept = default;
1082
1082
1083
- constexpr explicit _Mdspan_mapping_base (const _Extents& _Exts) : _Map(_Exts) {}
1083
+ constexpr explicit _Mdspan_mapping_holder (const _Extents& _Exts) : _Map(_Exts) {}
1084
1084
1085
- constexpr explicit _Mdspan_mapping_base (_Extents&& _Exts) : _Map(_STD move(_Exts)) {}
1085
+ constexpr explicit _Mdspan_mapping_holder (_Extents&& _Exts) : _Map(_STD move(_Exts)) {}
1086
1086
1087
1087
template <class _OtherMapping>
1088
- constexpr explicit _Mdspan_mapping_base (const _OtherMapping& _Map_) : _Map(_Map_) {}
1088
+ constexpr explicit _Mdspan_mapping_holder (const _OtherMapping& _Map_) : _Map(_Map_) {}
1089
1089
1090
- _Mapping _Map = _Mapping();
1090
+ _MSVC_NO_UNIQUE_ADDRESS _Mapping _Map = _Mapping();
1091
1091
};
1092
1092
1093
1093
template <class _Extents, _Elidable_layout_mapping<_Extents> _LayoutPolicy>
1094
- struct _Mdspan_mapping_base <_Extents, _LayoutPolicy> {
1094
+ struct _Mdspan_mapping_holder <_Extents, _LayoutPolicy> {
1095
1095
_STL_INTERNAL_STATIC_ASSERT(_Is_extents<_Extents>);
1096
1096
1097
1097
using _Mapping = _LayoutPolicy::template mapping<_Extents>;
1098
1098
1099
- constexpr _Mdspan_mapping_base () noexcept = default;
1099
+ constexpr _Mdspan_mapping_holder () noexcept = default;
1100
1100
1101
- constexpr explicit _Mdspan_mapping_base (const _Extents&) noexcept {}
1101
+ constexpr explicit _Mdspan_mapping_holder (const _Extents&) noexcept {}
1102
1102
1103
- constexpr explicit _Mdspan_mapping_base (_Extents&&) noexcept {}
1103
+ constexpr explicit _Mdspan_mapping_holder (_Extents&&) noexcept {}
1104
1104
1105
1105
template <class _OtherMapping>
1106
- constexpr explicit _Mdspan_mapping_base (const _OtherMapping& _Map_) {
1106
+ constexpr explicit _Mdspan_mapping_holder (const _OtherMapping& _Map_) {
1107
1107
// NB: Constructing _Mapping from _OtherMapping may have side effects - we should create a temporary.
1108
1108
if constexpr (!_Elidable_layout_mapping<typename _OtherMapping::layout_type, _Extents>) {
1109
1109
(void) _Mapping{_Map_};
@@ -1117,21 +1117,21 @@ template <class _AccessorPolicy>
1117
1117
concept _Elidable_accessor_policy = _Is_specialization_v<_AccessorPolicy, default_accessor>;
1118
1118
1119
1119
template <class _AccessorPolicy>
1120
- struct _Mdspan_accessor_base {
1121
- constexpr _Mdspan_accessor_base () noexcept = default;
1120
+ struct _Mdspan_accessor_holder {
1121
+ constexpr _Mdspan_accessor_holder () noexcept = default;
1122
1122
1123
1123
template <class _OtherAccessorPolicy>
1124
- constexpr explicit _Mdspan_accessor_base (const _OtherAccessorPolicy& _Acc_) : _Acc(_Acc_) {}
1124
+ constexpr explicit _Mdspan_accessor_holder (const _OtherAccessorPolicy& _Acc_) : _Acc(_Acc_) {}
1125
1125
1126
- _AccessorPolicy _Acc = _AccessorPolicy();
1126
+ _MSVC_NO_UNIQUE_ADDRESS _AccessorPolicy _Acc = _AccessorPolicy();
1127
1127
};
1128
1128
1129
1129
template <_Elidable_accessor_policy _AccessorPolicy>
1130
- struct _Mdspan_accessor_base <_AccessorPolicy> {
1131
- constexpr _Mdspan_accessor_base () noexcept = default;
1130
+ struct _Mdspan_accessor_holder <_AccessorPolicy> {
1131
+ constexpr _Mdspan_accessor_holder () noexcept = default;
1132
1132
1133
1133
template <class _OtherAccessorPolicy>
1134
- constexpr explicit _Mdspan_accessor_base (const _OtherAccessorPolicy& _Acc_) {
1134
+ constexpr explicit _Mdspan_accessor_holder (const _OtherAccessorPolicy& _Acc_) {
1135
1135
// NB: Constructing _AccessorPolicy from _OtherAccessorPolicy may have side effects - we should create a
1136
1136
// temporary.
1137
1137
if constexpr (!_Elidable_accessor_policy<_OtherAccessorPolicy>) {
@@ -1160,8 +1160,7 @@ _NODISCARD constexpr _IndexType _Mdspan_checked_index_cast(_OtherIndexType&& _Id
1160
1160
1161
1161
_EXPORT_STD template <class _ElementType, class _Extents, class _LayoutPolicy = layout_right,
1162
1162
class _AccessorPolicy = default_accessor<_ElementType>>
1163
- class __declspec(empty_bases) mdspan : private _Mdspan_mapping_base<_Extents, _LayoutPolicy>,
1164
- private _Mdspan_accessor_base<_AccessorPolicy> {
1163
+ class mdspan {
1165
1164
public:
1166
1165
using extents_type = _Extents;
1167
1166
using layout_type = _LayoutPolicy;
@@ -1176,9 +1175,6 @@ public:
1176
1175
using reference = accessor_type::reference;
1177
1176
1178
1177
private:
1179
- using _Mapping_base = _Mdspan_mapping_base<extents_type, layout_type>;
1180
- using _Accessor_base = _Mdspan_accessor_base<accessor_type>;
1181
-
1182
1178
static_assert(
1183
1179
sizeof(element_type) > 0, "ElementType must be a complete type (N4950 [mdspan.mdspan.overview]/2.1).");
1184
1180
static_assert(
@@ -1208,7 +1204,7 @@ public:
1208
1204
}
1209
1205
1210
1206
_NODISCARD constexpr index_type extent(_In_range_(<, extents_type::_Rank) const rank_type _Idx) const noexcept {
1211
- return this-> _Map.extents().extent(_Idx);
1207
+ return _Mapping. _Map.extents().extent(_Idx);
1212
1208
}
1213
1209
1214
1210
constexpr mdspan() noexcept(is_nothrow_default_constructible_v<data_handle_type>
@@ -1229,8 +1225,7 @@ public:
1229
1225
constexpr explicit mdspan(data_handle_type _Ptr_, _OtherIndexTypes... _Exts)
1230
1226
noexcept(is_nothrow_constructible_v<mapping_type, extents_type>
1231
1227
&& is_nothrow_default_constructible_v<accessor_type>) // strengthened
1232
- : _Mapping_base(extents_type{static_cast<index_type>(_STD move(_Exts))...}), _Accessor_base(),
1233
- _Ptr(_STD move(_Ptr_)) {}
1228
+ : _Mapping(extents_type{static_cast<index_type>(_STD move(_Exts))...}), _Accessor(), _Ptr(_STD move(_Ptr_)) {}
1234
1229
1235
1230
template <class _OtherIndexType, size_t _Size>
1236
1231
requires is_convertible_v<const _OtherIndexType&, index_type>
@@ -1240,7 +1235,7 @@ public:
1240
1235
constexpr explicit(_Size != rank_dynamic()) mdspan(data_handle_type _Ptr_, span<_OtherIndexType, _Size> _Exts)
1241
1236
noexcept(is_nothrow_constructible_v<mapping_type, extents_type>
1242
1237
&& is_nothrow_default_constructible_v<accessor_type>) // strengthened
1243
- : _Mapping_base (extents_type{_Exts}), _Accessor_base (), _Ptr(_STD move(_Ptr_)) {}
1238
+ : _Mapping (extents_type{_Exts}), _Accessor (), _Ptr(_STD move(_Ptr_)) {}
1244
1239
1245
1240
template <class _OtherIndexType, size_t _Size>
1246
1241
requires is_convertible_v<const _OtherIndexType&, index_type>
@@ -1251,23 +1246,23 @@ public:
1251
1246
mdspan(data_handle_type _Ptr_, const array<_OtherIndexType, _Size>& _Exts)
1252
1247
noexcept(is_nothrow_constructible_v<mapping_type, extents_type>
1253
1248
&& is_nothrow_default_constructible_v<accessor_type>) // strengthened
1254
- : _Mapping_base (extents_type{_Exts}), _Accessor_base (), _Ptr(_STD move(_Ptr_)) {}
1249
+ : _Mapping (extents_type{_Exts}), _Accessor (), _Ptr(_STD move(_Ptr_)) {}
1255
1250
1256
1251
constexpr mdspan(data_handle_type _Ptr_, const extents_type& _Exts)
1257
1252
noexcept(is_nothrow_constructible_v<mapping_type, const extents_type&>
1258
1253
&& is_nothrow_default_constructible_v<accessor_type>) // strengthened
1259
1254
requires is_constructible_v<mapping_type, const extents_type&> && is_default_constructible_v<accessor_type>
1260
- : _Mapping_base (_Exts), _Accessor_base (), _Ptr(_STD move(_Ptr_)) {}
1255
+ : _Mapping (_Exts), _Accessor (), _Ptr(_STD move(_Ptr_)) {}
1261
1256
1262
1257
constexpr mdspan(data_handle_type _Ptr_, const mapping_type& _Map_)
1263
1258
noexcept(is_nothrow_copy_constructible_v<mapping_type>
1264
1259
&& is_nothrow_default_constructible_v<accessor_type>) // strengthened
1265
1260
requires is_default_constructible_v<accessor_type>
1266
- : _Mapping_base (_Map_), _Accessor_base (), _Ptr(_STD move(_Ptr_)) {}
1261
+ : _Mapping (_Map_), _Accessor (), _Ptr(_STD move(_Ptr_)) {}
1267
1262
1268
1263
constexpr mdspan(data_handle_type _Ptr_, const mapping_type& _Map_, const accessor_type& _Acc_) noexcept(
1269
1264
is_nothrow_copy_constructible_v<mapping_type> && is_nothrow_copy_constructible_v<accessor_type>) // strengthened
1270
- : _Mapping_base (_Map_), _Accessor_base (_Acc_), _Ptr(_STD move(_Ptr_)) {}
1265
+ : _Mapping (_Map_), _Accessor (_Acc_), _Ptr(_STD move(_Ptr_)) {}
1271
1266
1272
1267
template <class _OtherElementType, class _OtherExtents, class _OtherLayoutPolicy, class _OtherAccessor>
1273
1268
requires is_constructible_v<mapping_type, const typename _OtherLayoutPolicy::template mapping<_OtherExtents>&>
@@ -1280,7 +1275,7 @@ public:
1280
1275
&& is_nothrow_constructible_v<mapping_type,
1281
1276
const typename _OtherLayoutPolicy::template mapping<_OtherExtents>&>
1282
1277
&& is_nothrow_constructible_v<accessor_type, const _OtherAccessor&>) // strengthened
1283
- : _Mapping_base (_Other.mapping()), _Accessor_base (_Other.accessor()), _Ptr(_Other.data_handle()) {
1278
+ : _Mapping (_Other.mapping()), _Accessor (_Other.accessor()), _Ptr(_Other.data_handle()) {
1284
1279
static_assert(is_constructible_v<data_handle_type, const typename _OtherAccessor::data_handle_type&>,
1285
1280
"The data_handle_type must be constructible from const typename OtherAccessor::data_handle_type& (N4950 "
1286
1281
"[mdspan.mdspan.cons]/20.1).");
@@ -1346,20 +1341,21 @@ public:
1346
1341
_NODISCARD constexpr size_type size() const noexcept {
1347
1342
#if _ITERATOR_DEBUG_LEVEL != 0
1348
1343
if constexpr (rank_dynamic() != 0) {
1349
- _STL_VERIFY(this->_Map.extents().template _Is_dynamic_multidim_index_space_size_representable<size_type>(),
1344
+ _STL_VERIFY(
1345
+ _Mapping._Map.extents().template _Is_dynamic_multidim_index_space_size_representable<size_type>(),
1350
1346
"The size of the multidimensional index space extents() must be representable as a value of type "
1351
1347
"size_type (N4950 [mdspan.mdspan.members]/7).");
1352
1348
}
1353
1349
#endif // _ITERATOR_DEBUG_LEVEL != 0
1354
1350
return static_cast<size_type>(
1355
- _Fwd_prod_of_extents<extents_type>::_Calculate(this-> _Map.extents(), extents_type::_Rank));
1351
+ _Fwd_prod_of_extents<extents_type>::_Calculate(_Mapping. _Map.extents(), extents_type::_Rank));
1356
1352
}
1357
1353
1358
1354
_NODISCARD constexpr bool empty() const noexcept {
1359
1355
if constexpr (extents_type::_Multidim_index_space_size_is_always_zero) {
1360
1356
return true;
1361
1357
} else {
1362
- const extents_type& _Exts = this-> _Map.extents();
1358
+ const extents_type& _Exts = _Mapping. _Map.extents();
1363
1359
for (rank_type _Idx = 0; _Idx < extents_type::_Rank; ++_Idx) {
1364
1360
if (_Exts.extent(_Idx) == 0) {
1365
1361
return true;
@@ -1373,28 +1369,28 @@ public:
1373
1369
swap(_Left._Ptr, _Right._Ptr); // intentional ADL
1374
1370
1375
1371
if constexpr (!_Elidable_layout_mapping<layout_type, extents_type>) {
1376
- swap(_Left._Map, _Right._Map); // intentional ADL
1372
+ swap(_Left._Mapping. _Map, _Right._Mapping ._Map); // intentional ADL
1377
1373
}
1378
1374
1379
1375
if constexpr (!_Elidable_accessor_policy<accessor_type>) {
1380
- swap(_Left._Acc, _Right._Acc); // intentional ADL
1376
+ swap(_Left._Accessor. _Acc, _Right._Accessor ._Acc); // intentional ADL
1381
1377
}
1382
1378
}
1383
1379
1384
1380
_NODISCARD constexpr const extents_type& extents() const noexcept {
1385
- return this-> _Map.extents();
1381
+ return _Mapping. _Map.extents();
1386
1382
}
1387
1383
1388
1384
_NODISCARD constexpr const data_handle_type& data_handle() const noexcept {
1389
1385
return _Ptr;
1390
1386
}
1391
1387
1392
1388
_NODISCARD constexpr const mapping_type& mapping() const noexcept {
1393
- return this-> _Map;
1389
+ return _Mapping. _Map;
1394
1390
}
1395
1391
1396
1392
_NODISCARD constexpr const accessor_type& accessor() const noexcept {
1397
- return this-> _Acc;
1393
+ return _Accessor. _Acc;
1398
1394
}
1399
1395
1400
1396
_NODISCARD static constexpr bool is_always_unique() noexcept /* strengthened */ {
@@ -1412,38 +1408,42 @@ public:
1412
1408
return _Result;
1413
1409
}
1414
1410
1415
- _NODISCARD constexpr bool is_unique() const noexcept(noexcept(this-> _Map.is_unique())) /* strengthened */ {
1416
- return this-> _Map.is_unique();
1411
+ _NODISCARD constexpr bool is_unique() const noexcept(noexcept(_Mapping. _Map.is_unique())) /* strengthened */ {
1412
+ return _Mapping. _Map.is_unique();
1417
1413
}
1418
1414
1419
- _NODISCARD constexpr bool is_exhaustive() const noexcept(noexcept(this->_Map.is_exhaustive())) /* strengthened */ {
1420
- return this->_Map.is_exhaustive();
1415
+ _NODISCARD constexpr bool is_exhaustive() const
1416
+ noexcept(noexcept(_Mapping._Map.is_exhaustive())) /* strengthened */ {
1417
+ return _Mapping._Map.is_exhaustive();
1421
1418
}
1422
1419
1423
- _NODISCARD constexpr bool is_strided() const noexcept(noexcept(this-> _Map.is_strided())) /* strengthened */ {
1424
- return this-> _Map.is_strided();
1420
+ _NODISCARD constexpr bool is_strided() const noexcept(noexcept(_Mapping. _Map.is_strided())) /* strengthened */ {
1421
+ return _Mapping. _Map.is_strided();
1425
1422
}
1426
1423
1427
1424
_NODISCARD constexpr index_type stride(const rank_type _Idx) const
1428
- noexcept(noexcept(this-> _Map.stride(_Idx))) /* strengthened */ {
1429
- return this-> _Map.stride(_Idx);
1425
+ noexcept(noexcept(_Mapping. _Map.stride(_Idx))) /* strengthened */ {
1426
+ return _Mapping. _Map.stride(_Idx);
1430
1427
}
1431
1428
1432
1429
private:
1433
1430
template <class... _OtherIndexTypes>
1434
1431
_NODISCARD constexpr reference _Access_impl(_OtherIndexTypes... _Indices) const
1435
- noexcept(noexcept(this-> _Acc.access(_Ptr, static_cast<size_t>(this-> _Map(_Indices...))))) {
1432
+ noexcept(noexcept(_Accessor. _Acc.access(_Ptr, static_cast<size_t>(_Mapping. _Map(_Indices...))))) {
1436
1433
_STL_INTERNAL_STATIC_ASSERT(conjunction_v<is_same<_OtherIndexTypes, index_type>...>);
1437
1434
#if _MSVC_STL_HARDENING_MDSPAN || _ITERATOR_DEBUG_LEVEL != 0
1438
- _STL_VERIFY(this->_Map.extents()._Contains_multidimensional_index(make_index_sequence<rank()>{}, _Indices...),
1439
- "mdspan subscript out of range; extents_type::index-cast(std::move(indices)) must be "
1440
- "a multidimensional index in extents() (N5001 [mdspan.mdspan.members]/3).");
1435
+ _STL_VERIFY(
1436
+ _Mapping._Map.extents()._Contains_multidimensional_index(make_index_sequence<rank()>{}, _Indices...),
1437
+ "mdspan subscript out of range; extents_type::index-cast(std::move(indices)) must be a multidimensional "
1438
+ "index in extents() (N5001 [mdspan.mdspan.members]/3).");
1441
1439
#endif
1442
1440
1443
- return this-> _Acc.access(_Ptr, static_cast<size_t>(this-> _Map(_Indices...)));
1441
+ return _Accessor. _Acc.access(_Ptr, static_cast<size_t>(_Mapping. _Map(_Indices...)));
1444
1442
}
1445
1443
1446
- /* [[no_unique_address]] */ data_handle_type _Ptr = data_handle_type();
1444
+ _MSVC_NO_UNIQUE_ADDRESS _Mdspan_mapping_holder<extents_type, layout_type> _Mapping;
1445
+ _MSVC_NO_UNIQUE_ADDRESS _Mdspan_accessor_holder<accessor_type> _Accessor;
1446
+ _MSVC_NO_UNIQUE_ADDRESS data_handle_type _Ptr = data_handle_type();
1447
1447
};
1448
1448
1449
1449
template <class _CArray>
@@ -1480,7 +1480,7 @@ mdspan(const typename _AccessorType::data_handle_type&, const _MappingType&, con
1480
1480
_STD_END
1481
1481
1482
1482
// TRANSITION, non-_Ugly attribute tokens
1483
- #pragma pop_macro("empty_bases ")
1483
+ #pragma pop_macro("msvc ")
1484
1484
1485
1485
#pragma pop_macro("new")
1486
1486
_STL_RESTORE_CLANG_WARNINGS
0 commit comments