Add a deleted constructor from nullptr_t to string_view; closes #113

This commit is contained in:
Peter Dimov 2022-09-18 13:53:55 +03:00
parent 162a4e1d24
commit 1fa592c9ec
3 changed files with 28 additions and 0 deletions

View File

@ -403,6 +403,22 @@ public:
{
}
#if !defined(BOOST_NO_CXX11_NULLPTR)
# if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
basic_string_view( std::nullptr_t ) = delete;
# else
private:
basic_string_view( std::nullptr_t );
public:
# endif
#endif
// BOOST_CONSTEXPR basic_string_view& operator=( basic_string_view const& ) BOOST_NOEXCEPT & = default;
// conversions

View File

@ -327,6 +327,8 @@ run sv_conversion_test2.cpp : ;
run sv_common_reference_test.cpp ;
compile sv_common_reference_test2.cpp ;
compile sv_windows_h_test.cpp ;
compile-fail sv_nullptr_fail.cpp
: $(warning-as-errors-off) ;
run span_test.cpp ;
run span_types_test.cpp ;

10
test/sv_nullptr_fail.cpp Normal file
View File

@ -0,0 +1,10 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
int main()
{
return boost::core::string_view( nullptr ).size() == 0;
}