PLCnext API Documentation 25.0.2.69
Range.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include <iterator>
9namespace Arp { namespace Base { namespace Core
10{
11
13template <class T>
14concept RangeValue = std::is_arithmetic_v<T>;
15
19template<RangeValue T>
20class Range
21{
22public: // usings
23 using Value = T;
24
25public: // construction/destruction
26 Range(void) = default;
27 Range(const Value& min, const Value& max);
28
29public: // setter/getter operations
30 const Value& GetMin(void)const;
31 const Value& GetMax(void)const;
32 bool IsEmpty(void)const;
33
34public: // operations
35 bool Contains(const Value& value)const;
36 bool IsDisjointTo(const Range& other, bool strictDisjoint = false)const;
37
38public: // operators
39 friend auto operator<=>(const Range& lhs, const Range& rhs) = default;
40
41 template<std::input_iterator InputIt>
42 static bool AreDisjoint(InputIt begin, InputIt end, bool strictDisjoint = false);
43
44private: // fields
45 Value min{};
46 Value max{};
47};
48
49}}} // end of namespace Arp::Base::Core
50
51
52namespace Arp {
55}
56#include "Arp/Base/Core/Detail/Range.ipp"
This class represents a range of values of any comparable type.
Definition: Range.hxx:21
const Value & GetMin(void) const
Gets the lower bound of this range.
Definition: Range.ipp:35
static bool AreDisjoint(InputIt begin, InputIt end, bool strictDisjoint=false)
Checks if all ranges in the sequence determined by begin and end a disjointed
Definition: Range.ipp:101
bool IsDisjointTo(const Range &other, bool strictDisjoint=false) const
Determines if the supplied other range is disjoint to this range.
Definition: Range.ipp:79
bool IsEmpty(void) const
Determines if this range is empty.
Definition: Range.ipp:53
const Value & GetMax(void) const
Gets the upper bound of this range.
Definition: Range.ipp:44
bool Contains(const Value &value) const
Determines of the supplied value is inside this range.
Definition: Range.ipp:63
This concept represent the allowed types to be used for class Range
Definition: Range.hxx:14
Root namespace for the PLCnext API