mirror of
				https://github.com/boostorg/utility.git
				synced 2025-11-04 02:11:45 +01:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
			boost-1.63
			...
			boost-1.64
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					00f02167e3 | ||
| 
						 | 
					9960d9f395 | ||
| 
						 | 
					ccfd741c0a | ||
| 
						 | 
					c5c479d49c | ||
| 
						 | 
					3e8f73c6ac | ||
| 
						 | 
					38121f2af3 | ||
| 
						 | 
					38b536ff05 | 
@@ -14,8 +14,8 @@
 | 
			
		||||
#include <boost/utility/binary.hpp>
 | 
			
		||||
#include <boost/utility/enable_if.hpp>
 | 
			
		||||
#include <boost/utility/identity_type.hpp>
 | 
			
		||||
#include <boost/checked_delete.hpp>
 | 
			
		||||
#include <boost/core/checked_delete.hpp>
 | 
			
		||||
#include <boost/core/noncopyable.hpp>
 | 
			
		||||
#include <boost/next_prior.hpp>
 | 
			
		||||
#include <boost/noncopyable.hpp>
 | 
			
		||||
 | 
			
		||||
#endif  // BOOST_UTILITY_HPP
 | 
			
		||||
 
 | 
			
		||||
@@ -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>&&)
 | 
			
		||||
            = delete;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        BOOST_CONSTEXPR basic_string_ref(const charT* str, size_type len) BOOST_NOEXCEPT
 | 
			
		||||
            : ptr_(str), len_(len) {}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -91,9 +91,15 @@ namespace boost {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
      template<typename Allocator>
 | 
			
		||||
        basic_string_view(const std::basic_string<charT, traits,
 | 
			
		||||
          Allocator>& str) BOOST_NOEXCEPT
 | 
			
		||||
        : ptr_(str.data()), len_(str.length()) {}
 | 
			
		||||
        basic_string_view(const std::basic_string<charT, traits, 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>&&)
 | 
			
		||||
          = delete;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
      BOOST_CONSTEXPR basic_string_view(const charT* str)
 | 
			
		||||
        : ptr_(str), len_(traits::length(str)) {}
 | 
			
		||||
@@ -121,10 +127,7 @@ namespace boost {
 | 
			
		||||
        BOOST_CONSTEXPR const_reference operator[](size_type pos) const BOOST_NOEXCEPT { return ptr_[pos]; }
 | 
			
		||||
 | 
			
		||||
        BOOST_CONSTEXPR const_reference at(size_t pos) const {
 | 
			
		||||
            return pos >= len_ ? BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")) : ptr_[pos];
 | 
			
		||||
//             if ( pos >= len_ )
 | 
			
		||||
//                 BOOST_THROW_EXCEPTION( std::out_of_range ( "boost::string_view::at" ) );
 | 
			
		||||
//             return ptr_[pos];
 | 
			
		||||
            return pos >= len_ ? BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")), ptr_[0] : ptr_[pos];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        BOOST_CONSTEXPR const_reference front() const                { return ptr_[0]; }
 | 
			
		||||
 
 | 
			
		||||
@@ -27,9 +27,11 @@ test-suite utility
 | 
			
		||||
        [ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
 | 
			
		||||
        [ compile result_of_test.cpp ]
 | 
			
		||||
        [ run ../shared_iterator_test.cpp ]
 | 
			
		||||
        [ compile-fail string_ref_from_rvalue.cpp ]
 | 
			
		||||
        [ run string_ref_test1.cpp unit_test_framework ]
 | 
			
		||||
        [ run string_ref_test2.cpp unit_test_framework ]
 | 
			
		||||
        [ run string_ref_test_io.cpp unit_test_framework ]
 | 
			
		||||
        [ compile-fail string_view_from_rvalue.cpp ]
 | 
			
		||||
        [ run string_view_test1.cpp unit_test_framework ]
 | 
			
		||||
        [ run string_view_test2.cpp unit_test_framework ]
 | 
			
		||||
        [ run string_view_test_io.cpp unit_test_framework ]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								test/string_ref_from_rvalue.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								test/string_ref_from_rvalue.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
/*
 | 
			
		||||
   Copyright (c) Marshall Clow 2017.
 | 
			
		||||
 | 
			
		||||
   Distributed under the Boost Software License, Version 1.0. (See accompanying
 | 
			
		||||
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
 | 
			
		||||
    For more information, see http://www.boost.org
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include <boost/utility/string_ref.hpp>
 | 
			
		||||
 | 
			
		||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
 | 
			
		||||
#error "Unsupported test"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "boost/test/minimal.hpp"
 | 
			
		||||
 | 
			
		||||
std::string makeatemp() { return "abc"; }
 | 
			
		||||
 | 
			
		||||
int test_main(int, char **)
 | 
			
		||||
{
 | 
			
		||||
  boost::basic_string_ref<char> sv(makeatemp());
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								test/string_view_from_rvalue.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								test/string_view_from_rvalue.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
/*
 | 
			
		||||
   Copyright (c) Marshall Clow 2017.
 | 
			
		||||
 | 
			
		||||
   Distributed under the Boost Software License, Version 1.0. (See accompanying
 | 
			
		||||
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
 | 
			
		||||
    For more information, see http://www.boost.org
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include <boost/utility/string_view.hpp>
 | 
			
		||||
 | 
			
		||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
 | 
			
		||||
#error "Unsupported test"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "boost/test/minimal.hpp"
 | 
			
		||||
 | 
			
		||||
std::string makeatemp() { return "abc"; }
 | 
			
		||||
 | 
			
		||||
int test_main(int, char **)
 | 
			
		||||
{
 | 
			
		||||
  boost::basic_string_view<char> sv(makeatemp());
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user