]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/sv_conversion_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / core / test / sv_conversion_test.cpp
1 // Copyright 2021 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt
4
5 #include <boost/core/detail/string_view.hpp>
6 #include <boost/core/lightweight_test.hpp>
7 #include <string>
8 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
9 # include <string_view>
10 #endif
11 #if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
12 # include <memory_resource>
13 #endif
14
15 boost::core::string_view f( boost::core::string_view const& str )
16 {
17 return str;
18 }
19
20 int main()
21 {
22 {
23 std::string s1( "123" );
24 std::string s2 = f( s1 );
25
26 BOOST_TEST_EQ( s1, s2 );
27 }
28
29 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
30
31 {
32 std::string_view s1( "123" );
33 std::string_view s2 = f( s1 );
34
35 BOOST_TEST_EQ( s1, s2 );
36 }
37
38 #endif
39
40 #if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
41
42 {
43 using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
44
45 pmr_string s1( "123" );
46 pmr_string s2 = f( s1 );
47
48 BOOST_TEST_EQ( s1, s2 );
49 }
50
51 #endif
52
53 return boost::report_errors();
54 }