CPP-AP 3.0.1
Command-line argument parser for C++20
Loading...
Searching...
No Matches
ap::nargs::range Class Reference

Argument's number of values managing class. More...

#include <range.hpp>

Public Member Functions

constexpr range ()=default
 Default constructor: creates an unbound range.
 
constexpr range (const count_type n)
 Exact count constructor: creates range [n, n].
 
constexpr range (const count_type lower, const count_type upper)
 Concrete range constructor: creates range [lower, upper].
 
constexpr bool has_explicit_lower_bound () const noexcept
 
constexpr bool has_explicit_upper_bound () const noexcept
 
constexpr bool is_explicitly_bound () const noexcept
 
constexpr bool is_exactly_bound () const noexcept
 
constexpr bool operator== (const range &other) const =default
 

Private Attributes

count_type _lower_bound = min_bound
 
count_type _upper_bound = max_bound
 

Friends

constexpr std::weak_ordering operator<=> (const count_type n, const range &r) noexcept
 Determines the ordering of the count against a range instance.
 
std::ostream & operator<< (std::ostream &os, const range &r) noexcept
 
constexpr range at_least (const count_type) noexcept
 range class builder function. Creates a range [n, inf).
 
constexpr range more_than (const count_type) noexcept
 range class builder function. Creates a range [n + 1, inf).
 
constexpr range less_than (const count_type) noexcept
 range class builder function. Creates a range [0, n - 1].
 
constexpr range up_to (const count_type) noexcept
 range class builder function. Creates a range [0, n].
 
constexpr range any () noexcept
 range class builder function. Creates a range [0, inf].
 

Detailed Description

Argument's number of values managing class.

Definition at line 27 of file range.hpp.

Constructor & Destructor Documentation

◆ range() [1/3]

constexpr ap::nargs::range::range ( )
constexprdefault

Default constructor: creates an unbound range.

◆ range() [2/3]

constexpr ap::nargs::range::range ( const count_type  n)
inlineexplicitconstexpr

Exact count constructor: creates range [n, n].

Parameters
nExpected value count.

Definition at line 36 of file range.hpp.

◆ range() [3/3]

constexpr ap::nargs::range::range ( const count_type  lower,
const count_type  upper 
)
inlineconstexpr

Concrete range constructor: creates range [lower, upper].

Parameters
lowerThe lower bound.
upperThe upper bound.

Definition at line 43 of file range.hpp.

Member Function Documentation

◆ has_explicit_lower_bound()

constexpr bool ap::nargs::range::has_explicit_lower_bound ( ) const
inlineconstexprnoexcept

Definition at line 51 of file range.hpp.

◆ has_explicit_upper_bound()

constexpr bool ap::nargs::range::has_explicit_upper_bound ( ) const
inlineconstexprnoexcept

Definition at line 55 of file range.hpp.

◆ is_exactly_bound()

constexpr bool ap::nargs::range::is_exactly_bound ( ) const
inlineconstexprnoexcept

Definition at line 63 of file range.hpp.

◆ is_explicitly_bound()

constexpr bool ap::nargs::range::is_explicitly_bound ( ) const
inlineconstexprnoexcept

Definition at line 59 of file range.hpp.

◆ operator==()

constexpr bool ap::nargs::range::operator== ( const range other) const
constexprdefault

Friends And Related Symbol Documentation

◆ any

constexpr range any ( )
friend

range class builder function. Creates a range [0, inf].

Returns
Built range class instance.

Definition at line 163 of file range.hpp.

◆ at_least

constexpr range at_least ( const count_type  n)
friend

range class builder function. Creates a range [n, inf).

Parameters
nThe lower bound.
Returns
Built range class instance.

Definition at line 128 of file range.hpp.

◆ less_than

constexpr range less_than ( const count_type  n)
friend

range class builder function. Creates a range [0, n - 1].

Parameters
nThe upper bound
Returns
Built range class instance.

Definition at line 146 of file range.hpp.

◆ more_than

constexpr range more_than ( const count_type  n)
friend

range class builder function. Creates a range [n + 1, inf).

Parameters
nThe lower bound.
Returns
Built range class instance.

Definition at line 137 of file range.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const range r 
)
friend

Definition at line 92 of file range.hpp.

◆ operator<=>

constexpr std::weak_ordering operator<=> ( const count_type  n,
const range r 
)
friend

Determines the ordering of the count against a range instance.

For a [lower, upper] range and the count n the returned value is:

  • less if n < lower,
  • equivalent if n >= lower and n <= upper,
  • greater if n > upper.
Parameters
nThe value count to order.
Returns
Ordering relationship between the count and the range.

Definition at line 80 of file range.hpp.

◆ up_to

constexpr range up_to ( const count_type  n)
friend

range class builder function. Creates a range [0, n].

Parameters
nThe upper bound
Returns
Built range class instance.

Definition at line 155 of file range.hpp.

Member Data Documentation

◆ _lower_bound

count_type ap::nargs::range::_lower_bound = min_bound
private

Definition at line 119 of file range.hpp.

◆ _upper_bound

count_type ap::nargs::range::_upper_bound = max_bound
private

Definition at line 120 of file range.hpp.


The documentation for this class was generated from the following file: