lcast_basic_unlockedbuf.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright Kevlin Henney, 2000-2005.
  2. // Copyright Alexander Nasonov, 2006-2010.
  3. // Copyright Antony Polukhin, 2011-2024.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP
  9. #define BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP
  10. #include <boost/config.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. # pragma once
  13. #endif
  14. #ifdef BOOST_NO_STRINGSTREAM
  15. #include <strstream>
  16. #else
  17. #include <sstream>
  18. #endif
  19. #include <boost/detail/basic_pointerbuf.hpp>
  20. #ifndef BOOST_NO_CWCHAR
  21. # include <cwchar>
  22. #endif
  23. namespace boost { namespace detail { namespace lcast {
  24. // acts as a stream buffer which wraps around a pair of pointers
  25. // and gives acces to internals
  26. template <class BufferType, class CharT>
  27. class basic_unlockedbuf : public basic_pointerbuf<CharT, BufferType> {
  28. public:
  29. typedef basic_pointerbuf<CharT, BufferType> base_type;
  30. typedef typename base_type::streamsize streamsize;
  31. using base_type::pptr;
  32. using base_type::pbase;
  33. using base_type::setbuf;
  34. };
  35. #if defined(BOOST_NO_STRINGSTREAM)
  36. template <class CharT, class Traits>
  37. using out_stream_t = std::ostream;
  38. template <class CharT, class Traits>
  39. using stringbuffer_t = basic_unlockedbuf<std::strstreambuf, char>;
  40. #elif defined(BOOST_NO_STD_LOCALE)
  41. template <class CharT, class Traits>
  42. using out_stream_t = std::ostream;
  43. template <class CharT, class Traits>
  44. using stringbuffer_t = basic_unlockedbuf<std::stringbuf, char>;
  45. template <class CharT, class Traits>
  46. using buffer_t = basic_unlockedbuf<std::streambuf, char>;
  47. #else
  48. template <class CharT, class Traits>
  49. using out_stream_t = std::basic_ostream<CharT, Traits>;
  50. template <class CharT, class Traits>
  51. using stringbuffer_t = basic_unlockedbuf<std::basic_stringbuf<CharT, Traits>, CharT>;
  52. template <class CharT, class Traits>
  53. using buffer_t = basic_unlockedbuf<std::basic_streambuf<CharT, Traits>, CharT>;
  54. #endif
  55. }}} // namespace boost::detail::lcast
  56. #endif // BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP