本文整理汇总了C++中boost::array::c_array方法的典型用法代码示例。如果您正苦于以下问题:C++ array::c_array方法的具体用法?C++ array::c_array怎么用?C++ array::c_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::array
的用法示例。
在下文中一共展示了array::c_array方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
boost::shared_ptr<NetPacket>
receiveMessage(tcp::socket &socket)
{
boost::shared_ptr<NetPacket> tmpPacket;
do {
// This is necessary, because we use TCP.
// Packets may be received in multiple chunks or
// several packets may be received at once.
if (recBufPos >= NET_HEADER_SIZE) {
// Read the size of the packet (first 4 bytes in network byte order).
uint32_t nativeVal;
memcpy(&nativeVal, recBuf.c_array(), sizeof(uint32_t));
size_t packetSize = ntohl(nativeVal);
if (packetSize > MAX_PACKET_SIZE) {
recBufPos = 0;
cout << "Packet too large" << endl;
return boost::shared_ptr<NetPacket>();
} else if (recBufPos >= packetSize + NET_HEADER_SIZE) {
try {
tmpPacket = NetPacket::Create(&recBuf.c_array()[NET_HEADER_SIZE], packetSize);
if (tmpPacket) {
recBufPos -= (packetSize + NET_HEADER_SIZE);
if (recBufPos) {
memmove(recBuf.c_array(), recBuf.c_array() + packetSize + NET_HEADER_SIZE, recBufPos);
}
}
} catch (const exception &) {
// Reset buffer on error.
recBufPos = 0;
cout << "Packet creation failed" << endl;
return boost::shared_ptr<NetPacket>();
}
}
}
if (!tmpPacket) {
recBufPos += socket.receive(boost::asio::buffer(recBuf.c_array() + recBufPos, BUF_SIZE - recBufPos));
if (recBufPos == 0) {
cout << "Receive failed" << endl;
return boost::shared_ptr<NetPacket>();
}
}
} while (!tmpPacket);
return tmpPacket;
}
示例2: buffer
inline mutable_buffer_container_1 buffer(boost::array<Pod_Type, N>& data,
std::size_t max_size_in_bytes)
{
return mutable_buffer_container_1(
mutable_buffer(data.c_array(),
data.size() * sizeof(Pod_Type) < max_size_in_bytes
? data.size() * sizeof(Pod_Type) : max_size_in_bytes));
}
示例3: container_type
inline typename detail::buffer_types<Pod_Type>::container_type
buffer(boost::array<Pod_Type, N>& data)
{
typedef typename asio::detail::buffer_types<Pod_Type>::buffer_type
buffer_type;
typedef typename asio::detail::buffer_types<Pod_Type>::container_type
container_type;
return container_type(
buffer_type(data.c_array(), data.size() * sizeof(Pod_Type)));
}
示例4: carray
carray( boost::array<T,N> & orig)
: m_t( orig.c_array() ), m_element_count( N ) {
if (m_element_count == 0)
m_t = 0;
}
示例5: operator
data_type operator()()
{
return data_type(_data.c_array(), size);
}
示例6: pop
size_t pop(OutputIterator it)
{
return ringbuffer_base<T>::pop(it, array_.c_array(), max_size_);
}
示例7: push
ConstIterator push(ConstIterator begin, ConstIterator end)
{
return ringbuffer_base<T>::push(begin, end, array_.c_array(), max_size_);
}