本文整理汇总了C++中Span::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Span::begin方法的具体用法?C++ Span::begin怎么用?C++ Span::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Span
的用法示例。
在下文中一共展示了Span::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Closure
ContiguousSpan Closure(const Span &s)
{
ContiguousSpan result(-1,-1);
if (!s.empty()) {
result.first = *(s.begin());
result.second = *(s.rbegin());
}
return result;
}
示例2: SpansIntersect
bool SpansIntersect(const Span &a, const ContiguousSpan &b)
{
for (Span::const_iterator p = a.begin(); p != a.end(); ++p) {
if (*p >= b.first && *p <= b.second) {
return true;
}
}
return false;
}
示例3: testRuntimeSpan
void testRuntimeSpan(Span sp)
{
LIBCPP_ASSERT((noexcept(sp.template first<Count>())));
LIBCPP_ASSERT((noexcept(sp.first(Count))));
auto s1 = sp.template first<Count>();
auto s2 = sp.first(Count);
using S1 = decltype(s1);
using S2 = decltype(s2);
ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
static_assert(S1::extent == Count, "");
static_assert(S2::extent == std::dynamic_extent, "");
assert(s1.data() == s2.data());
assert(s1.size() == s2.size());
assert(std::equal(s1.begin(), s1.end(), sp.begin()));
}
示例4: testConstexprSpan
constexpr bool testConstexprSpan(Span sp)
{
LIBCPP_ASSERT((noexcept(sp.template subspan<Offset>())));
LIBCPP_ASSERT((noexcept(sp.subspan(Offset))));
auto s1 = sp.template subspan<Offset>();
auto s2 = sp.subspan(Offset);
using S1 = decltype(s1);
using S2 = decltype(s2);
ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
static_assert(S1::extent == (Span::extent == std::dynamic_extent ? std::dynamic_extent : Span::extent - Offset), "");
static_assert(S2::extent == std::dynamic_extent, "");
return
s1.data() == s2.data()
&& s1.size() == s2.size()
&& std::equal(s1.begin(), s1.end(), sp.begin() + Offset, sp.end());
}
示例5: begin
Iterator begin(Span<Iterator> range)
{
return range.begin();
}
示例6: makeSpan
Span<std::reverse_iterator<Iterator>>
makeReverseSpan(Span<Iterator> range)
{
return makeSpan(std::reverse_iterator<Iterator>(range.end()),
std::reverse_iterator<Iterator>(range.begin()));
}