BDE 4.14.0 Production release
|
Provide a pure input iterator for an empty range.
This components provides a mechanism, bdlb::TestInputIterator
, that defines an input iterator with the following attributes:
T
, all objects of type TestInputIterator<T>
compare equal. Thus, any pair of such iterators constitute an empty range.This iterator type is typically used to check algorithms for compatibility with input iterators. The goal is to make sure that their code is able to work even with the most restrictive input iterator.
This section illustrates intended use of this component.
In the following example we use a bdlb::TestInputIterator
to test that an aggregation function compiles when instantiated with a pure input iterator.
First, we define a function sum
that accepts two input iterators and returns the sum of all elements in range specified by them.
Now, we define a function testSum
that first verifies that sum
correctly accumulates a sum, and then verifies, using bdlb::TestInputIterator
, that sum
can be instantiated on an iterator that strictly matches the requirements of an empty input iterator: