зеркало из https://github.com/microsoft/STL.git
P2166R1 Prohibiting basic_string And basic_string_view Construction From nullptr (#1995)
Co-authored-by: Casey Carter <cacarter@microsoft.com> Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
This commit is contained in:
Родитель
d6959662e7
Коммит
a8c7283e02
|
@ -1270,6 +1270,10 @@ public:
|
|||
/* implicit */ constexpr basic_string_view(_In_z_ const const_pointer _Ntcts) noexcept // strengthened
|
||||
: _Mydata(_Ntcts), _Mysize(_Traits::length(_Ntcts)) {}
|
||||
|
||||
#if _HAS_CXX23
|
||||
basic_string_view(nullptr_t) = delete;
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
constexpr basic_string_view(
|
||||
_In_reads_(_Count) const const_pointer _Cts, const size_type _Count) noexcept // strengthened
|
||||
: _Mydata(_Cts), _Mysize(_Count) {
|
||||
|
@ -2536,6 +2540,10 @@ public:
|
|||
_Proxy._Release();
|
||||
}
|
||||
|
||||
#if _HAS_CXX23
|
||||
basic_string(nullptr_t) = delete;
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
#if _HAS_CXX17
|
||||
template <class _Alloc2 = _Alloc, enable_if_t<_Is_allocator<_Alloc2>::value, int> = 0>
|
||||
#endif // _HAS_CXX17
|
||||
|
@ -3106,6 +3114,10 @@ public:
|
|||
return assign(_Ptr);
|
||||
}
|
||||
|
||||
#if _HAS_CXX23
|
||||
basic_string& operator=(nullptr_t) = delete;
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
_CONSTEXPR20_CONTAINER basic_string& operator=(const _Elem _Ch) { // assign {_Ch, _Elem()}
|
||||
_Mypair._Myval2._Mysize = 1;
|
||||
_Elem* const _Ptr = _Mypair._Myval2._Myptr();
|
||||
|
|
|
@ -262,6 +262,7 @@
|
|||
// P1048R1 is_scoped_enum
|
||||
// P1679R3 contains() For basic_string/basic_string_view
|
||||
// P1682R3 to_underlying() For Enumerations
|
||||
// P2166R1 Prohibiting basic_string And basic_string_view Construction From nullptr
|
||||
|
||||
// Parallel Algorithms Notes
|
||||
// C++ allows an implementation to implement parallel algorithms as calls to the serial algorithms.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include <constexpr_char_traits.hpp>
|
||||
|
||||
|
@ -1199,6 +1200,13 @@ static_assert(u8"abc"sv[1] == u8'b');
|
|||
static_assert(noexcept(u8"abc"sv));
|
||||
#endif // __cpp_char8_t
|
||||
|
||||
// P2166R1 Prohibiting basic_string And basic_string_view Construction From nullptr
|
||||
#if _HAS_CXX23
|
||||
static_assert(!is_constructible_v<string_view, nullptr_t>, "constructing string_view from nullptr_t is prohibited");
|
||||
static_assert(!is_constructible_v<string, nullptr_t>, "constructing string from nullptr_t is prohibited");
|
||||
static_assert(!is_assignable_v<string&, nullptr_t>, "assigning nullptr_t to string is prohibited");
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
int main() {
|
||||
test_case_default_constructor();
|
||||
test_case_ntcts_constructor();
|
||||
|
|
Загрузка…
Ссылка в новой задаче