本文整理汇总了C++中range::size方法的典型用法代码示例。如果您正苦于以下问题:C++ range::size方法的具体用法?C++ range::size怎么用?C++ range::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类range
的用法示例。
在下文中一共展示了range::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strncmp
inline bool
operator == (range<char const*> const &value, range<char const*> const &other) {
if (value.size() == other.size()) {
return value.empty() ? true : strncmp(value.begin(), other.begin(), value.size()) == 0;
}
return false;
}
示例2:
template <typename Iter, typename Other> inline bool
operator == (range<Iter> const &value, range<Other> const &other) {
if (value.size() == other.size()) {
return value.empty() ? true : std::equal(value.begin(), value.end(), other.begin());
}
return false;
}
示例3:
inline range<Iter2_t> init_move ( const range<Iter2_t> & dest,
const range<Iter1_t> & src)
{ //------------- static checking ------------------------------------------
typedef typename iterator_traits<Iter1_t>::value_type type1 ;
typedef typename iterator_traits<Iter2_t>::value_type type2 ;
static_assert ( std::is_same<type1, type2>::value,
"Incompatible iterators\n");
//------------------------------- begin ----------------------------------
if ( src.size() == 0 ) return range<Iter2_t>(dest.first, dest.first);
init_move(dest.first ,src.first, src.last );
return range<Iter2_t>(dest.first, dest.first + src.size()) ;
};
示例4: generic_par_for_wg
void generic_par_for_wg(range<Dimensions> k_range,
range<Dimensions> workgroup_size) {
queue my_queue;
// the product of all Dimensions e.g. 10*10*10 for {10,10,10}
auto linr_size = k_range.size(), linwg_size = workgroup_size.size();
// these will simply have the group, local and global linear ids assigned to
// them
auto group_lin = buffer<int>(linr_size / linwg_size);
auto loc_lin = buffer<int>(linr_size);
auto gl_lin = buffer<int>(linr_size);
my_queue.submit([&](handler &cgh) {
auto group_lin_acc = group_lin.get_access<access::mode::write>(cgh);
auto loc_lin_acc = loc_lin.get_access<access::mode::write>(cgh);
auto gl_lin_acc = gl_lin.get_access<access::mode::read_write>(cgh);
cgh.parallel_for_work_group<kernel_name>(
nd_range<Dimensions>(k_range, workgroup_size),
[=](group<Dimensions> group) {
group_lin_acc[group.get_linear_id()] = group.get_linear_id();
group.parallel_for_work_item([=](h_item<Dimensions> tile) {
loc_lin_acc[tile.get_global_linear_id()] =
tile.get_local_linear_id();
gl_lin_acc[tile.get_global_linear_id()] =
tile.get_global_linear_id();
});
});
});
auto loc_lin_out = loc_lin.get_access<access::mode::read>();
auto group_lin_out = group_lin.get_access<access::mode::read>();
auto gl_lin_out = gl_lin.get_access<access::mode::read>();
for (int i = 0; i < linr_size / linwg_size; ++i) {
BOOST_CHECK(group_lin_out[i] == i); // group id
}
for (int i = 0; i < linr_size; ++i) {
BOOST_CHECK(gl_lin_out[i] == i); // w1 global id
BOOST_CHECK(loc_lin_out[i] == loc_lin_out[i] % linwg_size); // local id
}
/* We must wait for for the queue to finish as none of buffer's destruction
is blocking.
*/
my_queue.wait();
}
示例5: add
void database::add(range key, range data)
{
assert(_db);
struct slice sk, sv;
sk.data = const_cast<char*>(key.begin());
sk.len = key.size();
sv.data = const_cast<char*>(data.begin());
sv.len = data.size();
if (::db_add(_db, &sk, &sv) == 0)
{
throw exception("error adding to ness backend");
}
}
示例6: take
virtual std::size_t take (const range& data)
{
detail::dummy_input_take_impl ();
typename range::value_type zero (
sound::sample_traits<
typename sound::sample_type<range>::type
>::zero_value ());
fill_frames (data, zero);
return data.size ();
}
示例7: del
void database::del(range key)
{
assert(_db);
struct slice sk;
sk.data = const_cast<char*>(key.begin());
sk.len = key.size();
::db_remove(_db, &sk);
}
示例8: operator
__forceinline NodeRef operator() (const PrimRef* prims, const range<size_t>& set, const FastAllocator::CachedAllocator& alloc) const
{
size_t n = set.size();
size_t items = Primitive::blocks(n);
size_t start = set.begin();
Primitive* accel = (Primitive*) alloc.malloc1(items*sizeof(Primitive),BVH::byteAlignment);
typename BVH::NodeRef node = BVH::encodeLeaf((char*)accel,items);
for (size_t i=0; i<items; i++) {
accel[i].fill(prims,start,set.end(),bvh->scene);
}
return node;
}
示例9: read
[[nodiscard]]
inline size_t read(std::istream& Stream, const range<char*>& Buffer)
{
{
const auto Exceptions = Stream.exceptions();
Stream.exceptions(Exceptions & ~(Stream.failbit | Stream.eofbit));
SCOPE_EXIT{ Stream.exceptions(Exceptions); };
Stream.read(Buffer.data(), Buffer.size());
if (!Stream.bad() && Stream.eof())
Stream.clear();
}
return Stream.gcount();
}
示例10: read
range<byte*> read(const range<byte*>& buf)
{
zstream.avail_out = uInt(buf.size());
zstream.next_out = (Bytef*)buf.begin();
for(;zstream.avail_out != 0;){
if (zstream.avail_in == 0){
new_input_();
}
auto res = ::inflate(&zstream, Z_NO_FLUSH);
switch(res)
{
case Z_NEED_DICT:
{
if (dict.empty())
AIO_THROW(inflate_exception)("Need dictionary");
auto dic_err = inflateSetDictionary(&zstream, (Bytef*)dict.begin(), dict.size());
if (dic_err != Z_OK)
AIO_THROW(inflate_exception)("Bad dictionary");
}
case Z_OK:
break;
case Z_DATA_ERROR:
AIO_THROW(inflate_exception)("Z_DATA_ERROR");
case Z_MEM_ERROR:
AIO_THROW(inflate_exception)("Z_MEM_ERROR");
case Z_STREAM_END:
uncompressed_size = zstream.total_out;
return range<byte*>((buf.size() - zstream.avail_out) + buf.begin(), buf.end());
default:
AIO_THROW(inflate_exception)("zlib internal error");
}
}
return range<byte*>(buf.end() - zstream.avail_out, buf.end());
}
示例11: get
std::string database::get(range key)
{
assert(_db);
struct slice sk, sv;
sk.data = const_cast<char*>(key.begin());
sk.len = key.size();
if (::db_get(_db, &sk, &sv) == 0)
{
throw exception("error reading from ness backend");
}
// copy the data out
std::string result(sv.data, sv.len);
::free(sv.data);
return result;
}
示例12: write
range<const byte*> write(const range<const byte*>& buf){
AIO_PRE_CONDITION(!finished);
AIO_PRE_CONDITION(zstream.avail_in == 0);
crc = crc32(buf, crc);
zstream.next_in = (Bytef*)buf.begin();
zstream.avail_in = uInt(buf.size());
for(;zstream.avail_in != 0;){
if (zstream.avail_out ==0 )
new_buffer_();
switch (deflate(&zstream, Z_NO_FLUSH)){
case Z_OK:
case Z_BUF_ERROR:
break;
default:
AIO_THROW(deflate_exception)("deflate with Z_NO_FLUSH failed");
}
}
return range<const byte*>(buf.end(), buf.end());
}
示例13: ProcessServiceModes
static bool ProcessServiceModes(range<const wchar_t* const*> const Args, int& ServiceResult)
{
const auto& isArg = [](const wchar_t* Arg, string_view const Name)
{
return (*Arg == L'/' || *Arg == L'-') && equal_icase(Arg + 1, Name);
};
if (Args.size() == 4 && IsElevationArgument(Args[0])) // /service:elevation {GUID} PID UsePrivileges
{
ServiceResult = ElevationMain(Args[1], std::wcstoul(Args[2], nullptr, 10), *Args[3] == L'1');
return true;
}
if (InRange(2u, Args.size(), 5u) && (isArg(Args[0], L"export"sv) || isArg(Args[0], L"import"sv)))
{
const auto Export = isArg(Args[0], L"export"sv);
string strProfilePath(Args.size() > 2 ? Args[2] : L""), strLocalProfilePath(Args.size() > 3 ? Args[3] : L""), strTemplatePath(Args.size() > 4 ? Args[4] : L"");
InitTemplateProfile(strTemplatePath);
InitProfile(strProfilePath, strLocalProfilePath);
Global->m_ConfigProvider = new config_provider(Export? config_provider::mode::m_export : config_provider::mode::m_import);
ServiceResult = !ConfigProvider().ServiceMode(Args[1]);
return true;
}
if (InRange(1u, Args.size(), 3u) && isArg(Args[0], L"clearcache"sv))
{
string strProfilePath(Args.size() > 1 ? Args[1] : L"");
string strLocalProfilePath(Args.size() > 2 ? Args[2] : L"");
InitProfile(strProfilePath, strLocalProfilePath);
config_provider::ClearPluginsCache();
ServiceResult = 0;
return true;
}
return false;
}
示例14:
vector_range(VectorType & v, range const & entry_range)
: base_type(v.handle(), entry_range.size(), v.start() + v.stride() * entry_range.start(), v.stride()) {}
示例15: put
virtual std::size_t put (const range& data)
{
detail::dummy_output_put_impl ();
return data.size ();
}