Skip to content

Commit d40e8c0

Browse files
Implement LWG-4140 Useless default constructors for bit reference types (#5129)
1 parent b60bb78 commit d40e8c0

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

stl/inc/bitset

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public:
109109
}
110110

111111
private:
112-
_CONSTEXPR23 reference() noexcept : _Pbitset(nullptr), _Mypos(0) {}
113-
114112
_CONSTEXPR23 reference(bitset<_Bits>& _Bitset, const size_t _Pos) noexcept : _Pbitset(&_Bitset), _Mypos(_Pos) {}
115113

116114
bitset<_Bits>* _Pbitset;

stl/inc/vector

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,9 +2444,6 @@ private:
24442444
using _Mycont = typename _Mybase::_Mycont;
24452445
using _Difference_type = typename _Mybase::_Difference_type;
24462446

2447-
// TRANSITION, ABI: non-trivial constructor
2448-
_CONSTEXPR20 _Vb_reference() = default;
2449-
24502447
public:
24512448
_CONSTEXPR20 _Vb_reference(const _Vb_reference&) = default;
24522449

tests/std/tests/Dev10_860410_bitset_ctors/test.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ using namespace std;
1212

1313
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
1414

15+
// Also test LWG-4140 "Useless default constructors for bit reference types" for bitset<N>::reference.
16+
namespace lwg_4140 {
17+
struct default_constructible_type {};
18+
19+
void test_default_constructor(default_constructible_type) {}
20+
void test_default_constructor(bitset<0>::reference) {}
21+
void test_default_constructor(bitset<1>::reference) {}
22+
void test_default_constructor(bitset<8>::reference) {}
23+
void test_default_constructor(bitset<16>::reference) {}
24+
void test_default_constructor(bitset<32>::reference) {}
25+
void test_default_constructor(bitset<48>::reference) {}
26+
void test_default_constructor(bitset<64>::reference) {}
27+
void test_default_constructor(bitset<96>::reference) {}
28+
29+
void test() { // COMPILE-ONLY
30+
test_default_constructor({});
31+
}
32+
} // namespace lwg_4140
33+
1534
const char parsedStr[] = "1000110111110011110111111111111111010111110111100101010100001001"
1635
"1111111111111111111111111111111111111111111111111111111111111111"
1736
"0111111111111111111111111111111111111111111111111111111111111111"

tests/std/tests/Dev11_0437519_container_requirements/test.compile.pass.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,23 @@ void assert_vector_bool_noexcept() {
30313031
assert_vector_bool_noexcept_impl<non_pocma_allocator<bool>>();
30323032
}
30333033

3034+
// Also test LWG-4140 "Useless default constructors for bit reference types" for vector<bool, Alloc>::reference.
3035+
namespace lwg_4140 {
3036+
struct default_constructible_type {};
3037+
3038+
void test_default_constructor(default_constructible_type) {}
3039+
void test_default_constructor(std::vector<bool>::reference) {}
3040+
void test_default_constructor(std::vector<bool, pocma_allocator<bool>>::reference) {}
3041+
void test_default_constructor(std::vector<bool, non_pocma_allocator<bool>>::reference) {}
3042+
#if _HAS_CXX17
3043+
void test_default_constructor(std::pmr::vector<bool>::reference) {}
3044+
#endif // _HAS_CXX17
3045+
3046+
void test() {
3047+
test_default_constructor({});
3048+
}
3049+
} // namespace lwg_4140
3050+
30343051
template <container_tag Tag>
30353052
void assert_container() {
30363053
check_all_container_requirements<Tag>();

0 commit comments

Comments
 (0)