本文整理汇总了C++中vector_t::rbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_t::rbegin方法的具体用法?C++ vector_t::rbegin怎么用?C++ vector_t::rbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector_t
的用法示例。
在下文中一共展示了vector_t::rbegin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: string_test
void string_test()
{
using namespace adobe;
adobe::test_movable(string_t("01234"));
{ // empty properties
string_t x;
BOOST_CHECK(x.begin() == x.end());
BOOST_CHECK(x.empty());
BOOST_CHECK(x.begin() == 0);
BOOST_CHECK(x.capacity() == 0);
BOOST_CHECK(x.size() == 0);
}
{ // non-empty properties
string_t x("01234");
BOOST_CHECK(x.begin() != x.end());
BOOST_CHECK(!x.empty());
BOOST_CHECK(x.begin() != 0);
BOOST_CHECK(x.begin() + 5 == x.end());
BOOST_CHECK(x.capacity() != 0);
BOOST_CHECK(x.size() == 5);
}
#if 0
{ // fill c-tor
vector_t x(5, 7);
BOOST_CHECK(x.front() == 7 && x.back() == 7 && x[2] == 7);
}
{ // zero fill c-tor
vector_t x(5);
BOOST_CHECK(x.size() == 5);
BOOST_CHECK(x.back() == 0);
}
{ // iterators & indexing
const vector_t x(5, 7);
vector_t y(5, 8);
BOOST_CHECK(x.begin() + 5 == x.end());
BOOST_CHECK(x.rbegin() + 5 == x.rend());
BOOST_CHECK(y.rbegin() + 5 == y.rend());
BOOST_CHECK(y[3] == 8);
BOOST_CHECK(x[3] == 7);
}
{ // iterator based ctor
int a[] = { 0, 1, 2, 3, 4, 5 };
vector_t x(&a[0], &a[0] + sizeof(a) / sizeof(int));
BOOST_CHECK(x.front() == 0);
BOOST_CHECK(x.back() == 5);
BOOST_CHECK(x.size() == 6);
}
{ // iterator based move ctor
vector_vector_t x(5, vector_t(3, 7));
const void* addr = remote_address(x.back());
vector_vector_t y(x.begin(), x.end(), move_ctor());
BOOST_CHECK(x.front().empty() && x.back().empty());
BOOST_CHECK(addr = remote_address(y.back()));
}
{ // reserve
vector_vector_t x(5, vector_t(3, 7));
const void* addr = remote_address(x.back());
std::size_t c = x.capacity();
x.reserve(2 * x.capacity());
BOOST_CHECK(x.capacity() == 2 * c);
BOOST_CHECK(x.size() == 5);
BOOST_CHECK(addr = remote_address(x.back()));
}
{ // push_back
vector_t x(3, 7);
const void* addr = remote_address(x);
vector_vector_t y;
y.push_back(x);
BOOST_CHECK(y.front() == x);
y.push_back(move(x));
BOOST_CHECK(y.front() == y.back());
BOOST_CHECK(y.size() == 2);
BOOST_CHECK(addr == remote_address(y.back()));
BOOST_CHECK(x.empty());
y.pop_back();
y.pop_back();
BOOST_CHECK(y.size() == 0);
}
{ // swap
vector_t x(3, 7);
vector_t y(4, 5);
const void* addr_x = remote_address(x);
const void* addr_y = remote_address(y);
swap(x, y);
BOOST_CHECK(addr_x = remote_address(y));
BOOST_CHECK(addr_y = remote_address(x));
}
{ // insert
int a[] = { 0, 1, 2, 3, 4, 5 };
vector_t x(boost::begin(a), boost::end(a));
int b[] = { 0, 1, 7, 2, 3, 4, 5 };
vector_t y(boost::begin(b), boost::end(b));
x.insert(x.begin() + 2, 7);
BOOST_CHECK(x == y);
}
//.........这里部分代码省略.........