Celeritas  0.5.0-56+6b053cd
Classes | Macros | Functions
OpaqueId.hh File Reference
#include <cstddef>
#include <functional>
#include <type_traits>
#include "Assert.hh"
#include "Macros.hh"
#include "Types.hh"
This graph shows which files directly or indirectly include this file:

Classes

class  celeritas::OpaqueId< ValueT, SizeT >
 Type-safe index for accessing an array or collection of data. More...
 

Macros

#define CELER_DEFINE_OPAQUEID_CMP(TOKEN)
 

Functions

template<class IdT , class T >
IdT celeritas::id_cast (T value) noexcept(!CELERITAS_DEBUG)
 Safely create an OpaqueId from an integer of any type. More...
 
template<class V , class S , class U >
constexpr bool celeritas::operator< (OpaqueId< V, S > lhs, U rhs)
 Allow less-than comparison with integer for container comparison.
 
template<class V , class S , class U >
constexpr bool celeritas::operator<= (OpaqueId< V, S > lhs, U rhs)
 Allow less-than-equal comparison with integer for container comparison.
 
template<class V , class S >
celeritas::operator- (OpaqueId< V, S > self, OpaqueId< V, S > other)
 Get the distance between two opaque IDs.
 
template<class V , class S >
OpaqueId< V, S > celeritas::operator+ (OpaqueId< V, S > id, std::make_signed_t< S > offset)
 Increment an opaque ID by an offset.
 
template<class V , class S >
OpaqueId< V, S > celeritas::operator- (OpaqueId< V, S > id, std::make_signed_t< S > offset)
 Decrement an opaque ID by an offset.
 
template<class V , class S >
constexpr bool celeritas::operator== (OpaqueId< V, S > lhs, OpaqueId< V, S > rhs)
 
template<class V , class S >
constexpr bool celeritas::operator!= (OpaqueId< V, S > lhs, OpaqueId< V, S > rhs)
 
template<class V , class S >
constexpr bool celeritas::operator< (OpaqueId< V, S > lhs, OpaqueId< V, S > rhs)
 
template<class V , class S >
constexpr bool celeritas::operator> (OpaqueId< V, S > lhs, OpaqueId< V, S > rhs)
 
template<class V , class S >
constexpr bool celeritas::operator<= (OpaqueId< V, S > lhs, OpaqueId< V, S > rhs)
 
template<class V , class S >
constexpr bool celeritas::operator>= (OpaqueId< V, S > lhs, OpaqueId< V, S > rhs)
 

Macro Definition Documentation

◆ CELER_DEFINE_OPAQUEID_CMP

#define CELER_DEFINE_OPAQUEID_CMP (   TOKEN)
Value:
template<class V, class S> \
CELER_CONSTEXPR_FUNCTION bool operator TOKEN(OpaqueId<V, S> lhs, \
OpaqueId<V, S> rhs) \
{ \
return lhs.unchecked_get() TOKEN rhs.unchecked_get(); \
}

Function Documentation

◆ id_cast()

template<class IdT , class T >
IdT celeritas::id_cast ( value)
inlinenoexcept

Safely create an OpaqueId from an integer of any type.

This asserts that the integer is in the valid range of the target ID type, and casts to it.

Note
The value cannot be the underlying "invalid" value, i.e. static_cast<FooId>(FooId{}.unchecked_get()) will not work.

◆ operator!=()

template<class V , class S >
constexpr bool celeritas::operator!= ( OpaqueId< V, S >  lhs,
OpaqueId< V, S >  rhs 
)
inlineconstexpr

Comparison for OpaqueId

◆ operator<()

template<class V , class S >
constexpr bool celeritas::operator< ( OpaqueId< V, S >  lhs,
OpaqueId< V, S >  rhs 
)
inlineconstexpr

Comparison for OpaqueId

◆ operator<=()

template<class V , class S >
constexpr bool celeritas::operator<= ( OpaqueId< V, S >  lhs,
OpaqueId< V, S >  rhs 
)
inlineconstexpr

Comparison for OpaqueId

◆ operator==()

template<class V , class S >
constexpr bool celeritas::operator== ( OpaqueId< V, S >  lhs,
OpaqueId< V, S >  rhs 
)
inlineconstexpr

Comparison for OpaqueId

◆ operator>()

template<class V , class S >
constexpr bool celeritas::operator> ( OpaqueId< V, S >  lhs,
OpaqueId< V, S >  rhs 
)
inlineconstexpr

Comparison for OpaqueId

◆ operator>=()

template<class V , class S >
constexpr bool celeritas::operator>= ( OpaqueId< V, S >  lhs,
OpaqueId< V, S >  rhs 
)
inlineconstexpr

Comparison for OpaqueId