目录

Constructor

Function Description

There are three types of construction methods:

Therefore, there are three constructor prototypes.

Function Prototype

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.

Parameters

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.

Return Value

Constructed range object.

Restrictions

None

Calling Example

// 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.