本文整理汇总了C++中Span::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Span::data方法的具体用法?C++ Span::data怎么用?C++ Span::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Span
的用法示例。
在下文中一共展示了Span::data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
URI::URI(uri_identifier_code_t id, const Span<const uint8_t> &uri_field) :
_uri(uri_field.size() ? new uint8_t[uri_id_code_size + uri_field.size()] : NULL),
_uri_size(uri_id_code_size + uri_field.size())
{
_uri[uri_id_index] = id;
memcpy(_uri + uri_field_index, uri_field.data(), uri_field.size());
}
示例2: set_text
void Text::set_text(
encoding_t text_encoding,
const Span<const uint8_t> &language_code,
const Span<const uint8_t> &text
)
{
delete[] _text_record;
_text_record_size = header_size + language_code.size() + text.size();
_text_record = new uint8_t[_text_record_size];
// build the header
_text_record[header_index] = 0;
if (text_encoding == UTF16) {
_text_record[header_index] |= utf16_encoding_bit;
}
_text_record[header_index] |= language_code.size();
// language code
memcpy(_text_record + language_code_index, language_code.data(), language_code.size());
// actual text
memcpy(_text_record + language_code_index + language_code.size(), text.data(), text.size());
}
示例3: testRuntimeSpan
void testRuntimeSpan(Span sp)
{
ASSERT_NOEXCEPT(std::as_bytes(sp));
auto spBytes = std::as_bytes(sp);
using SB = decltype(spBytes);
ASSERT_SAME_TYPE(const std::byte, typename SB::element_type);
if (sp.extent == std::dynamic_extent)
assert(spBytes.extent == std::dynamic_extent);
else
assert(spBytes.extent == sizeof(typename Span::element_type) * sp.extent);
assert((void *) spBytes.data() == (void *) sp.data());
assert(spBytes.size() == sp.size_bytes());
}
示例4: set_uri
void URI::set_uri(
uri_identifier_code_t id,
const Span<const uint8_t> &uri_field
)
{
delete[] _uri;
if (uri_field.empty()) {
_uri = NULL;
_uri_size = 0;
return;
}
_uri = new uint8_t[uri_id_code_size + uri_field.size()];
_uri_size = uri_id_code_size + uri_field.size();
_uri[uri_id_index] = id;
memcpy(_uri + uri_field_index, uri_field.data(), uri_field.size());
}
示例5: set_payload
void set_payload(Span new_load)
{
pckt_->set_data_end(pckt_->ip_header_length() + header_size() + new_load.size());
memcpy(payload().data(), new_load.data(), payload().size());
}
示例6: testRuntimeSpan
void testRuntimeSpan(Span sp)
{
_LIBCPP_ASSERT(sp.back(), "");
assert(std::addressof(sp.back()) == sp.data() + sp.size() - 1);
}
示例7: testConstexprSpan
constexpr bool testConstexprSpan(Span sp)
{
_LIBCPP_ASSERT(sp.back(), "");
return std::addressof(sp.back()) == sp.data() + sp.size() - 1;
}