text
stringlengths 0
2.2M
|
---|
++rstart;
|
}
|
}
|
//..
|
// The preceding loop produces the following output on 'stdout':
|
//..
|
// Traverse array using reverse iterator:
|
// Element: 5
|
// Element: 4
|
// Element: 3
|
// Element: 2
|
// Element: 1
|
//..
|
} break;
|
case 16: {
|
// --------------------------------------------------------------------
|
// TEST CONTAINER SIZE CALLS
|
//
|
// Concern:
|
//: 1 That the functions under test return the number of elements in a
|
//: container that provides a 'size' accessor.
|
//
|
// Plan:
|
//: 1 Create a type, 'MyContainer', in the unnamed namespace.
|
//:
|
//: 2 Create an object of type 'MyContainer'.
|
//:
|
//: 3 Call the functions under test on that object.
|
//
|
// Testing:
|
// size_t size(const CONTAINER&);
|
// ptrdiff_t ssize(const CONTAINER&);
|
// --------------------------------------------------------------------
|
if (verbose) printf("TEST CONTAINER SIZE CALLS\n"
|
"=========================\n");
|
for (unsigned uu = 0; uu <= 10 * 1000; uu += 100) {
|
SizeContainer c(uu);
|
ASSERT(bsl::size(c) == uu);
|
ASSERT(bsl::size(c) == c.size());
|
const int ii = uu;
|
ASSERT(bsl::ssize(c) == ii);
|
ASSERT(bsl::ssize(c) == static_cast<int>(c.size()));
|
}
|
} break;
|
case 15: {
|
// --------------------------------------------------------------------
|
// TESTING ADL CONCERN
|
//
|
// Concerns:
|
//: 1 Range functions can be used with 'std' containers under ADL.
|
//
|
// Plan:
|
//: 1 Call all 10 range functions (unqualified) for a 'bsl::set<int>',
|
//: as this will be associated with both namespace 'bsl' and native
|
//: 'std' (for 'std::less' as a template parameter). Note that this
|
//: test scenario is implemented in the test driver of the
|
//: 'bslim_bslstandardheadertest' component to avoid include loop.
|
//:
|
//: 2 Explicitly introduce both namespaces ('bsl' and 'native_std') and
|
//: call all 10 range functions for an array of integers. (C-1)
|
//
|
// Testing
|
// CONCERN: Range functions are not ambiguous with 'std' under ADL
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING ADL CONCERN"
|
"\n===================\n");
|
using namespace bsl;
|
using namespace native_std;
|
{
|
bsl::set<int> mY;
|
mY.insert(1);
|
mY.insert(2);
|
mY.insert(3);
|
bsl::set<int>::iterator it;
|
bsl::reverse_iterator<bsl::set<int>::iterator> rit;
|
ASSERT(1 == *begin(mY));
|
it = end(mY);
|
ASSERT(3 == *--it);
|
ASSERT(3 == *rbegin(mY));
|
rit = rend(mY);
|
ASSERT(1 == *--rit);
|
ASSERT(1 == *cbegin(mY));
|
it = cend(mY);
|
ASSERT(3 == *--it);
|
ASSERT(3 == *crbegin(mY));
|
rit = crend(mY);
|
ASSERT(1 == *--rit);
|
ASSERT(3 == size(mY));
|
ASSERT(3 == ssize(mY));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.