File indexing completed on 2025-01-18 09:39:13
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_LEXICAL_CAST_DETAIL_BUFFER_VIEW_HPP
0008 #define BOOST_LEXICAL_CAST_DETAIL_BUFFER_VIEW_HPP
0009
0010 #include <boost/config.hpp>
0011 #ifdef BOOST_HAS_PRAGMA_ONCE
0012 # pragma once
0013 #endif
0014
0015 #include <iosfwd>
0016
0017 namespace boost { namespace conversion { namespace detail {
0018
0019 template < typename CharT >
0020 struct buffer_view {
0021 const CharT* begin;
0022 const CharT* end;
0023 };
0024
0025 template < typename CharT >
0026 buffer_view<CharT> make_buffer_view(const CharT* begin, const CharT* end) {
0027 return buffer_view<CharT>{begin, end};
0028 }
0029
0030 inline buffer_view<char> make_buffer_view(const signed char* begin, const signed char* end) {
0031 return buffer_view<char>{
0032 reinterpret_cast<const char*>(begin),
0033 reinterpret_cast<const char*>(end)
0034 };
0035 }
0036
0037 inline buffer_view<char> make_buffer_view(const unsigned char* begin, const unsigned char* end) {
0038 return buffer_view<char>{
0039 reinterpret_cast<const char*>(begin),
0040 reinterpret_cast<const char*>(end)
0041 };
0042 }
0043
0044 template< typename CharT, typename Elem, typename Traits >
0045 std::basic_ostream<Elem,Traits>& operator<<(
0046 std::basic_ostream<Elem, Traits>& os,
0047 buffer_view<CharT> r)
0048 {
0049 while (r.begin != r.end) {
0050 os << r.begin[0];
0051 ++r.begin;
0052 }
0053 return os;
0054 }
0055
0056 }}}
0057
0058 #endif
0059