1 /*=============================================================================
2 Copyright (c) 2017 Daniel James
3 http://spirit.sourceforge.net/
5 Use, modification and distribution is subject to the Boost Software
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_QUICKBOOK_STRING_VIEW_HPP)
10 #define BOOST_SPIRIT_QUICKBOOK_STRING_VIEW_HPP
12 #include <boost/functional/hash/hash_fwd.hpp>
13 #include <boost/utility/string_view.hpp>
17 // boost::string_view now can't be constructed from an rvalue std::string,
18 // which is something that quickbook does in several places, so this wraps
21 struct string_view : boost::string_view
23 typedef boost::string_view base;
25 string_view() : base() {}
26 string_view(string_view const& x) : base(x) {}
27 string_view(std::string const& x) : base(x) {}
28 string_view(const char* x) : base(x) {}
29 string_view(const char* x, base::size_type len) : base(x, len) {}
31 std::string to_s() const { return std::string(begin(), end()); }
34 typedef quickbook::string_view::const_iterator string_iterator;
36 inline std::size_t hash_value(string_view const& x)
38 return boost::hash_range(x.begin(), x.end());
41 inline std::string& operator+=(std::string& x, string_view const& y)
43 return x.append(y.begin(), y.end());