diff --git a/include/boost/core/detail/string_view.hpp b/include/boost/core/detail/string_view.hpp index 7e85aac..5a1f6c8 100644 --- a/include/boost/core/detail/string_view.hpp +++ b/include/boost/core/detail/string_view.hpp @@ -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 diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 5cdcb61..94b465e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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 ; diff --git a/test/sv_nullptr_fail.cpp b/test/sv_nullptr_fail.cpp new file mode 100644 index 0000000..2afbcd0 --- /dev/null +++ b/test/sv_nullptr_fail.cpp @@ -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 + +int main() +{ + return boost::core::string_view( nullptr ).size() == 0; +}