Add endian_buffer stream inserter and extractor, beef up buffer_test a bit.

This commit is contained in:
Beman committed 2015-01-17 10:25:29 -05:00
1 parent 10bcb52d97
commit 35f4c47a22
4 files changed
+183 -6

No files matched your search

+24
View File
@@ -215,6 +215,30 @@ namespace endian
typedef little_float32_buf_t native_float32_buf_t;
typedef little_float64_buf_t native_float64_buf_t;
# endif
// Stream inserter
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const endian_buffer<Order, T, n_bits, A>& x)
{
return os << x.value();
}
// Stream extractor
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is,
endian_buffer<Order, T, n_bits, A>& x)
{
T i;
if (is >> i)
x = i;
return is;
}
} // namespace boost
} // namespace endian
@@ -39,6 +39,7 @@ namespace boost
// Define BOOST_NO_IO_COVER_OPERATORS if I/O cover operations are not desired.
//--------------------------------------------------------------------------------------//
template <class D, // D is the CRTP derived type, i.e. the cover class
class ArithmeticT>
class cover_operators