There are three types of construction methods:
(Default) Construct a range instance whose upper and lower bounds are nullptr.
Construct a range instance by specifying the upper and lower bounds.
Construct a range instance with the same upper and lower bounds by passing only one pointer of any type.
Therefore, there are three constructor prototypes.
Range() // Default constructor. Both the upper and lower bounds are null pointers. Range(T *min, T* max) : min_(min), max_(max) // The upper bound (max) and lower bound (min) are specified by developers. Range(T *same_ele) : min_(same_ele), max_(same_ele) // Both the upper and lower bounds are same_ele.
| Parameter | Input/Output | Description |
|---|---|---|
| min | Input | Pointer to the lower bound, of the T* type. |
| max | Input | Pointer to the upper bound, of the T* type. |
| same_ele | Input | Used to construct a range instance with the same upper and lower bounds. The values of the upper and lower bounds are assigned by same_ele and are of the T* type. |
// 1. Default construction Range<int> range1; // Both the upper and lower bounds are nullptr. // 2. Specify the upper and lower bounds. int min = 0; int max = 1024; Range<int> range2(&min, &max); // The upper bound is 1024 bytes and the lower bound is 0. // 3. Construct a range with the same upper and lower bounds. Range<int> range3(&min); // Both the upper and lower bounds are 0.