diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-02-09 17:06:20 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-03-22 22:39:06 +0000 |
commit | 142cc4c223d695e515ed2504501b91d8a7ac6eb8 (patch) | |
tree | 28b38d9292fc4d6e777044fcd170783787b5d3a5 /libstdc++-v3/include | |
parent | 8539c5610a7c36099af2ea756d8bbfa398a40e0b (diff) | |
download | gcc-142cc4c223d695e515ed2504501b91d8a7ac6eb8.zip gcc-142cc4c223d695e515ed2504501b91d8a7ac6eb8.tar.gz gcc-142cc4c223d695e515ed2504501b91d8a7ac6eb8.tar.bz2 |
libstdc++: Constrain std::vector default constructor [PR113841]
This is needed to avoid errors outside the immediate context when
evaluating is_default_constructible_v<vector<T, A>> when A is not
default constructible.
To avoid diagnostic regressions for 23_containers/vector/48101_neg.cc we
need to make the std::allocator<cv T> partial specializations default
constructible, which they probably should have been anyway.
libstdc++-v3/ChangeLog:
PR libstdc++/113841
* include/bits/allocator.h (allocator<cv T>): Add default
constructor to partial specializations for cv-qualified types.
* include/bits/stl_vector.h (_Vector_impl::_Vector_impl()):
Constrain so that it's only present if the allocator is default
constructible.
* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl()):
Likewise.
* testsuite/23_containers/vector/cons/113841.cc: New test.
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/allocator.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_bvector.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_vector.h | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index ff4f5b9..9e75b37 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -254,6 +254,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: typedef _Tp value_type; + allocator() { } template<typename _Up> allocator(const allocator<_Up>&) { } }; @@ -262,6 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: typedef _Tp value_type; + allocator() { } template<typename _Up> allocator(const allocator<_Up>&) { } }; @@ -270,6 +272,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: typedef _Tp value_type; + allocator() { } template<typename _Up> allocator(const allocator<_Up>&) { } }; /// @endcond diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index a3343d9..d567e26 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -593,6 +593,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR _Bvector_impl() _GLIBCXX_NOEXCEPT_IF( is_nothrow_default_constructible<_Bit_alloc_type>::value) +#if __cpp_concepts + requires is_default_constructible_v<_Bit_alloc_type> +#endif : _Bit_alloc_type() { } diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index a8d387f..3116971 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -135,6 +135,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR _Vector_impl() _GLIBCXX_NOEXCEPT_IF( is_nothrow_default_constructible<_Tp_alloc_type>::value) +#if __cpp_lib_concepts + requires is_default_constructible_v<_Tp_alloc_type> +#endif : _Tp_alloc_type() { } |