xte::wrap_value<>

Defined in header <xte/meta/wrap_value.hpp>

Wraps a constant value.


Definition

template<decltype(auto) x>
struct wrap_value {
	static constexpr decltype(auto) value = x;

	explicit(false) constexpr operator decltype(auto)() const noexcept;

	static constexpr decltype(auto) operator()() noexcept;

	friend constexpr auto operator<=>(xte::wrap_value<x>, auto&& rhs) XTE_ARROW(
		x <=> XTE_FWD(rhs)
	)

	friend constexpr auto operator==(xte::wrap_value<x>, auto&& rhs) XTE_ARROW(
		x == XTE_FWD(rhs)
	)
};


Example

template<typename T, xte::uz length>
struct fixed_array {
	static constexpr auto size = xte::wrap_value<length>();

	xte::type<T[length]> data;
};

static_assert(fixed_array<int, 5>::size == 5);

static_assert(fixed_array<int, 5>().size() == 5);
[View in Compiler Explorer]