Implemented C++23 deleted nullptr_t constructor/assignment for AZStd string classes (#4158)
* Added string and string_view class constructor overloads which is deleted that prevents initializing them from a nullptr or an integer type Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed locations where string and string_view were initialized with nullptr Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fix IArchive::IsInstalledToHDD signature Updated calls to ConvertAbsolutePathToAliasedPath to use an list initialization instead of nullptr Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f1f35a0ba8
commit
58c227ceb1
@@ -96,6 +96,10 @@ namespace AZStd
|
||||
&& !is_convertible_v<const T&, const Element*>>>
|
||||
constexpr basic_fixed_string(const T& convertibleToView, size_type rhsOffset, size_type count);
|
||||
|
||||
|
||||
// #12
|
||||
constexpr basic_fixed_string(AZStd::nullptr_t) = delete;
|
||||
|
||||
constexpr operator AZStd::basic_string_view<Element, Traits>() const;
|
||||
|
||||
constexpr auto begin() -> iterator;
|
||||
@@ -120,6 +124,7 @@ namespace AZStd
|
||||
constexpr auto operator=(const T& convertible_to_view)
|
||||
-> AZStd::enable_if_t<is_convertible_v<const T&, basic_string_view<Element, Traits>>
|
||||
&& !is_convertible_v<const T&, const Element*>, basic_fixed_string&>;
|
||||
constexpr auto operator=(AZStd::nullptr_t) -> basic_fixed_string& = delete;
|
||||
|
||||
constexpr auto operator+=(const basic_fixed_string& rhs) -> basic_fixed_string&;
|
||||
constexpr auto operator+=(const_pointer ptr) -> basic_fixed_string&;
|
||||
|
||||
@@ -168,6 +168,9 @@ namespace AZStd
|
||||
{
|
||||
}
|
||||
|
||||
// C++23 overload to prevent initializing a string_view via a nullptr or integer type
|
||||
constexpr basic_string(AZStd::nullptr_t) = delete;
|
||||
|
||||
inline ~basic_string()
|
||||
{
|
||||
// destroy the string
|
||||
@@ -197,6 +200,7 @@ namespace AZStd
|
||||
inline this_type& operator=(AZStd::basic_string_view<Element, Traits> view) { return assign(view); }
|
||||
inline this_type& operator=(const_pointer ptr) { return assign(ptr); }
|
||||
inline this_type& operator=(Element ch) { return assign(1, ch); }
|
||||
inline this_type& operator=(AZStd::nullptr_t) = delete;
|
||||
inline this_type& operator+=(const this_type& rhs) { return append(rhs); }
|
||||
inline this_type& operator+=(const_pointer ptr) { return append(ptr); }
|
||||
inline this_type& operator+=(Element ch) { return append(1, ch); }
|
||||
|
||||
@@ -502,6 +502,9 @@ namespace AZStd
|
||||
swap(other);
|
||||
}
|
||||
|
||||
// C++23 overload to prevent initializing a string_view via a nullptr or integer type
|
||||
constexpr basic_string_view(AZStd::nullptr_t) = delete;
|
||||
|
||||
constexpr const_reference operator[](size_type index) const { return data()[index]; }
|
||||
/// Returns value, not reference. If index is out of bounds, 0 is returned (can't be reference).
|
||||
constexpr value_type at(size_type index) const
|
||||
|
||||
Reference in New Issue
Block a user