Add data() member

git-svn-id: http://svn.boost.org/svn/boost/sandbox/endian@62439 b8fc166d-592f-0410-95f2-cb63ce0dd405
This commit is contained in:
bemandawes committed 2010-06-05 11:45:21 +00:00
1 parent 22ccd7a2e4
commit c60b7d2171
7 files changed
+237 -19

No files matched your search

+5
View File
@@ -198,6 +198,7 @@ namespace boost
# endif
return detail::load_big_endian<T, n_bits/8>(m_value);
}
const char* data() const { return m_value; }
private:
char m_value[n_bits/8];
};
@@ -230,6 +231,7 @@ namespace boost
# endif
return detail::load_little_endian<T, n_bits/8>(m_value);
}
const char* data() const { return m_value; }
private:
char m_value[n_bits/8];
};
@@ -257,6 +259,7 @@ namespace boost
endian & operator=(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); return *this; }
operator T() const { return detail::load_little_endian<T, n_bits/8>(m_value); }
# endif
const char* data() const { return m_value; }
private:
char m_value[n_bits/8];
};
@@ -288,6 +291,7 @@ namespace boost
endian & operator=(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); return *this; }
operator T() const { return detail::load_big_endian<T, sizeof(T)>(&m_value); }
# endif
const char* data() const { return reinterpret_cast<const char *>(&m_value); }
private:
T m_value;
};
@@ -316,6 +320,7 @@ namespace boost
endian & operator=(T val) { detail::store_little_endian<T, sizeof(T)>(&m_value, val); return *this; }
operator T() const { return detail::load_little_endian<T, sizeof(T)>(&m_value); }
#endif
const char* data() const { return reinterpret_cast<const char *>(&m_value); }
private:
T m_value;
};
+1 -1
View File
@@ -119,7 +119,7 @@ namespace boost
inline typename boost::enable_if< is_endian<Endian>, std::ostream & >::type
operator<=( std::ostream & os, const Endian & e )
{
return os.write( reinterpret_cast<const char*>(&e), sizeof(e) );
return os.write( e.data(), sizeof(e) );
}
template < class Endian >