6 namespace boost {
namespace memory {
8 template <
typename po
inter_type>
10 pointer_type* pointer,
13 data_(reinterpret_cast<void*>(pointer)),
19 template <
typename po
inter_type>
21 const pointer_type* pointer,
24 data_(reinterpret_cast<void*>(const_cast<pointer_type*>(pointer))),
30 template <
typename po
inter_type>
33 data_(reinterpret_cast<void*>(pointer)),
34 length_(sizeof(pointer_type))
49 data_(reinterpret_cast<void*>(const_cast<char*>(s.data()))),
55 template <
typename reference_type>
58 static_assert(std::is_reference<reference_type>::value,
"must be a reference type!");
60 using base_type =
typename std::remove_reference<reference_type>::type;
61 using pointer_type =
typename std::add_pointer<base_type>::type;
63 return *
reinterpret_cast<pointer_type
>(data_);
66 template <
typename po
inter_type>
69 static_assert(std::is_pointer<pointer_type>::value,
"must be a pointer");
71 return reinterpret_cast<pointer_type
>(data_);
size_t length() const
Number of bytes in the buffer.
reference_type as()
Obtains a reference to the underlying memory block treating it as the given reference_type.
A non-owning reference to a buffer.
pointer_type as_pointer()
Obtains a reference to the underlying memory block treating it as a representation of the given point...
buffer_ref subbuf(size_t length) const
Obtains a sub buffer with the given size.
buffer_ref(pointer_type *data, size_t length)
Creates a reference through a pointer and length.
Represents an allocated memory block.