Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Range.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <limits>
#include <optional>
#include <type_traits>
#include "Stroika/Foundation/Characters/String.h"
#include "Stroika/Foundation/Characters/ToString.h"
#include "Stroika/Foundation/Common/Common.h"
#include "Stroika/Foundation/Common/TemplateUtilities.h"
#include "Stroika/Foundation/Traversal/Common.h"
#include "Range.inl"

Go to the source code of this file.

Classes

struct  Stroika::Foundation::Traversal::RangeTraits::ExplicitDifferenceTypes< DIFFERENCE_TYPE, UNSIGNED_DIFFERENCE_TYPE >
 
struct  Stroika::Foundation::Traversal::RangeTraits::DefaultDifferenceTypes< T >
 
struct  Stroika::Foundation::Traversal::RangeTraits::ExplicitOpenness< LOWER_BOUND, UPPER_BOUND >
 
struct  Stroika::Foundation::Traversal::RangeTraits::DefaultOpenness< T >
 This defines the default openness for a given type T, except for specializaitons. This is used by Explict<>, and indirectly by Range<> itself. Generally its eClosed, by default, except for the upper bound on floating point Ranges. The reason for this exception on floating point, is that its often helpful to have a series of ranges that form a partition, and that works out more easily with half-open intervals. More...
 
struct  Stroika::Foundation::Traversal::RangeTraits::ExplicitBounds< T, MIN, MAX >
 
struct  Stroika::Foundation::Traversal::RangeTraits::DefaultBounds< T >
 
struct  Stroika::Foundation::Traversal::RangeTraits::ExplicitOpennessAndDifferenceType< T, OPENNESS, DIFF_TYPE >
 
struct  Stroika::Foundation::Traversal::RangeTraits::Explicit< T, OPENNESS, BOUNDS, DIFF_TYPE >
 
struct  Stroika::Foundation::Traversal::RangeTraits::Default_Integral< T >
 
struct  Stroika::Foundation::Traversal::RangeTraits::Default_Enum< T >
 
struct  Stroika::Foundation::Traversal::RangeTraits::Default_Arithmetic< T >
 
struct  Stroika::Foundation::Traversal::RangeTraits::Default< T >
 
class  Stroika::Foundation::Traversal::Range< T, TRAITS >
 

Namespaces

namespace  Stroika::Foundation
 
namespace  Stroika::Foundation::Traversal::RangeTraits
 

Functions

template<typename T , typename TRAITS >
constexpr Range< T, TRAITS > Stroika::Foundation::Traversal::operator+ (const T &lhs, const Range< T, TRAITS > &rhs)
 
template<typename T , typename TRAITS >
constexpr Range< T, TRAITS > Stroika::Foundation::Traversal::operator* (const T &lhs, const Range< T, TRAITS > &rhs)
 
template<typename T , typename TRAITS >
constexpr Range< T, TRAITS > Stroika::Foundation::Traversal::operator^ (const Range< T, TRAITS > &lhs, const Range< T, TRAITS > &rhs)
 

Detailed Description

Note
Code-Status: Beta

Design Note This module was inspired by Ruby Range class, but in the end, it was mostly based on HealthFrame's DateRangeType/DateTimeRangeType code.

This notion of 'range' has VERY LITTLE todo with the std::range feature (which is more like Stroika 'Iterable')

TODO:

Definition in file Range.h.

Function Documentation

◆ operator+()

template<typename T , typename TRAITS >
constexpr Range< T, TRAITS > Stroika::Foundation::Traversal::operator+ ( const T &  lhs,
const Range< T, TRAITS > &  rhs 
)
constexpr

Alias: T + RANGE => RANGE.Offset(T) Alias: RANGE + RANGE => RANGE.Union (RANGE)

Definition at line 511 of file Range.inl.

◆ operator*()

template<typename T , typename TRAITS >
constexpr Range< T, TRAITS > Stroika::Foundation::Traversal::operator* ( const T &  lhs,
const Range< T, TRAITS > &  rhs 
)
constexpr

Alias: T * RANGE => RANGE.Times(T)

Precondition
T has operator* (T,T) -> T defined

Definition at line 527 of file Range.inl.

◆ operator^()

template<typename T , typename TRAITS >
constexpr Range< T, TRAITS > Stroika::Foundation::Traversal::operator^ ( const Range< T, TRAITS > &  lhs,
const Range< T, TRAITS > &  rhs 
)
constexpr

Alias for lhs.Intersection (rhs)

Example Usage
using RT = Range<int>;
constexpr auto eOpen = Openness::eOpen;
constexpr auto eClosed = Openness::eClosed;
Assert ((RT{1, 2, eOpen, eClosed} ^ RT{2, 3, eClosed, eOpen}));
Assert (((RT{1, 2, eOpen, eClosed} ^ RT{2, 3, eClosed, eOpen}) == RT{2,2,eClosed,eClosed}));

Definition at line 538 of file Range.inl.