mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 02:44:10 +00:00
Don't construct string_view|string_ref from rvalue string. That way lies pain
This commit is contained in:
parent
ccfd741c0a
commit
9960d9f395
@ -92,6 +92,13 @@ namespace boost {
|
||||
basic_string_ref(const std::basic_string<charT, traits, Allocator>& str)
|
||||
: ptr_(str.data()), len_(str.length()) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
// Constructing a string_ref from a temporary string is a bad idea
|
||||
template<typename Allocator>
|
||||
basic_string_ref(std::basic_string<charT, traits, Allocator>&& str)
|
||||
= delete;
|
||||
#endif
|
||||
|
||||
BOOST_CONSTEXPR basic_string_ref(const charT* str, size_type len) BOOST_NOEXCEPT
|
||||
: ptr_(str), len_(len) {}
|
||||
|
||||
|
@ -95,6 +95,13 @@ namespace boost {
|
||||
Allocator>& str) BOOST_NOEXCEPT
|
||||
: ptr_(str.data()), len_(str.length()) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
// Constructing a string_view from a temporary string is a bad idea
|
||||
template<typename Allocator>
|
||||
basic_string_view(std::basic_string<charT, traits, Allocator>&& str)
|
||||
= delete;
|
||||
#endif
|
||||
|
||||
BOOST_CONSTEXPR basic_string_view(const charT* str)
|
||||
: ptr_(str), len_(traits::length(str)) {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user