本文整理汇总了C++中array_view::end方法的典型用法代码示例。如果您正苦于以下问题:C++ array_view::end方法的具体用法?C++ array_view::end怎么用?C++ array_view::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array_view
的用法示例。
在下文中一共展示了array_view::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: key_qvalue_pairs
inline std::string key_qvalue_pairs(array_view<kv_pair> pairs)
{
std::string buffer;
// Ensure string is large enough for our use, to avoid useless internal resize
size_t maj = std::accumulate(pairs.begin(), pairs.end(), size_t{0},
[](size_t acc, kv_pair p){return acc + p.key.size()+p.value.size()+8;});
// reserve some space for 8 quoted chars inside value
// if there is more string is on it's own and will spend slightly more time
buffer.reserve(maj+8);
return key_qvalue_pairs(buffer, pairs);
}
示例2: mdarray
explicit mdarray(const array_view<ATYPE> &view):
_imap(map_utils<map_type>::create(view.template shape<shape_t>())),
_data(container_utils<storage_type>::create(view.size()))
{
std::copy(view.begin(),view.end(),_data.begin());
}
示例3: pcx_decode
bitmap xtk::pcx_decode (const array_view<std::uint8_t>& data) {
static_assert (sizeof (pcx_header) == 128, "Header length incorrect");
const auto& header = *(const pcx_header*)data.data();
auto width = header.xmax - header.xmin + 1;
auto height = header.ymax - header.ymin + 1;
__xtk_assert (std::invalid_argument, header.vendor_id == 0x0A && header.version >= 5);
xtk::Debug::log(
"load_pcx: \n"
"\tversion = %d\n"
"\tbits_per_pixel = %d\n"
"\tcolor_planes = %d\n"
"\twidth = %u\n"
"\theight = %u\n"
,
header.version,
header.bits_per_pixel,
header.color_planes,
width,
height
);
__xtk_assert(std::invalid_argument,
header.bits_per_pixel == 8 &&
header.color_planes == 0);
auto buffer = std::make_unique<bitmap::value_type []> (width*height);
auto stream = array_view<const std::uint8_t> {data.begin() + sizeof (header), data.end()};
auto next_pixel = 0u;
auto next_sbyte = stream.begin ();
auto palette = xtk::array_view<glm::tvec3<std::uint8_t>> {
(const glm::tvec3<std::uint8_t> *)data.end () - 256,
(const glm::tvec3<std::uint8_t> *)data.end ()
};
while (next_sbyte < stream.end ()) {
auto rle = *next_sbyte;
++next_sbyte;
if (rle >= 0xc0) {
rle &= 0x3f;
auto pixel = bitmap::value_type (palette [*next_sbyte], 255);
++next_sbyte;
for (auto j = 0; j < rle; ++j) {
buffer [next_pixel] = pixel;
++next_pixel;
__xtk_assert (std::overflow_error, next_pixel <= width*height);
}
}
else {
buffer [next_pixel] = bitmap::value_type (palette [rle], 255);
++next_pixel;
__xtk_assert (std::overflow_error, next_pixel <= width*height);
}
if (next_pixel >= width*height) {
break;
}
}
__xtk_assert (std::invalid_argument, next_pixel == width*height);
return bitmap (std::move (buffer), width, height);
}