cuda::experimental::stf::optionally_static

Defined in include/cuda/experimental/__stf/utility/core.cuh

template<auto static_v, __copy_type_t<static_v> reserved = get_reserved_default<__copy_type_t<static_v>>()>
class optionally_static

A class to represent a value that can be either static or dynamic.

All arithmetic and logic operators are supported (if the original type supports them).

Template Parameters
  • static_v – The static value. If the value is ‘reserved’, it means it’s dynamic.

  • reserved – A reserved value indicating the value is dynamic.

Public Types

using type = decltype(static_v)

The type of the underlying data.

Public Functions

constexpr optionally_static() = default

Special functions.

constexpr optionally_static(const optionally_static&) = default

Special functions.

constexpr optionally_ &operator=(const optionally_static&) = default

Special functions.

inline constexpr optionally_static(type dynamic_value)

Constructor that initializes a dynamic value.

Works only if static_v == reserved.

Parameters

dynamic – The dynamic value.

inline constexpr type get() const

Retrieves the stored value (either static or dynamic).

Returns

The stored value.

inline constexpr operator type() const

Forwards to get().

Returns

The stored value.

inline constexpr type &get_ref()

Retrieves a reference to the stored value (assumed dynamic).

Returns

The stored value.

inline optionally_ &operator++()
inline optionally_static operator++(int)
inline optionally_ &operator--()
inline optionally_static operator--(int)
inline optionally_static operator+() const
inline auto operator-() const

Public Static Attributes

static constexpr bool is_static = static_v != reserved

Indicates whether the value is static.