Celeritas 0.6.0-129+develop.846910afa
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
OpaqueId.hh File Reference
#include <cstddef>
#include <functional>
#include <type_traits>
#include "Assert.hh"
#include "Macros.hh"
#include "Types.hh"

Classes

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

Macros

#define CELER_DEFINE_OPAQUEID_CMP(TOKEN)
 

Functions

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

Variables

template<class T >
constexpr T celeritas::detail::nullid_value {static_cast<T>(-1)}
 Sentinel value for an unassigned opaque ID.
 

Macro Definition Documentation

◆ CELER_DEFINE_OPAQUEID_CMP

#define CELER_DEFINE_OPAQUEID_CMP (   TOKEN)
Value:
template<class I, class T> \
CELER_CONSTEXPR_FUNCTION bool operator TOKEN(OpaqueId<I, T> lhs, \
OpaqueId<I, T> rhs) \
{ \
return lhs.unchecked_get() TOKEN rhs.unchecked_get(); \
}
#define CELER_CONSTEXPR_FUNCTION
Decorate a function that works on both host and device, with and without NVCC, can be evaluated at co...
Definition Macros.hh:82

Function Documentation

◆ id_cast()

template<class IdT , class U >
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 "null" value; i.e. static_cast<FooId>(FooId{}.unchecked_get()) will not work.

◆ operator!=()

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

Comparison for OpaqueId

◆ operator<()

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

Comparison for OpaqueId

◆ operator<=()

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

Comparison for OpaqueId

◆ operator==()

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

Comparison for OpaqueId

◆ operator>()

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

Comparison for OpaqueId

◆ operator>=()

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

Comparison for OpaqueId