Range Constructor

Function Usage

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.

Prototype

1
2
3
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 users.
explicit 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.

Returns

Constructed range object

Constraints

None

Examples

1
2
3
4
5
6
7
8
// 1. Default construction
Range<int> range1; // Both the upper and lower bounds are nullptr.
// 2. Both upper and lower bounds are specified by users.
int min = 0;
int max = 1024;
Range<int> range2(&min, &max); // The upper bound is 1024 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.