xte::big_int {}

Defined in header <xte/math/big_int.hpp>

A fully constexpr arbitrary-precision integer class.


Definition

template<xte::is_unsigned T = xte::uz>
struct big_int {
	using value_type = T;

	template<xte::is_arithmetic T = U>
	explicit(!xte::is_int<U>)
	constexpr big_int(U = 0) noexcept(false);

	explicit(false) constexpr big_int(const xte::big_int<T>&) noexcept(false) = default;

	explicit(false) constexpr big_int(xte::big_int<T>&&) noexcept = default;

	template<typename U>
	requires(!xte::same_as<T, U>)
	explicit constexpr big_int(const xte::big_int<U>&) noexcept(false);

	template<typename Range = xte::array<T>>
	constexpr big_int(std::from_range_t, Range&&, bool = false) XTE_ARROW_CTOR(/* ... */)

	template<xte::is_int Radix = xte::uz>
	explicit constexpr big_int(xte::string_view, Radix = 10, const xte::number_format_config& = {}) noexcept(false);

	constexpr xte::big_int<T>& operator=(const xte::big_int<T>&) & noexcept(false) = default;

	constexpr xte::big_int<T>& operator=(xte::big_int<T>&&) & noexcept = default;

	template<xte::is_arithmetic U>
	explicit constexpr operator U() const noexcept;

	explicit constexpr operator bool() const noexcept;

	friend constexpr std::strong_ordering operator<=>(const xte::big_int<T>&, const xte::big_int<T>&) noexcept;

	friend constexpr std::strong_ordering operator<=>(const xte::big_int<T>&, xte::is_int auto) noexcept;

	friend constexpr std::partial_ordering operator<=>(const xte::big_int<T>&, xte::is_float auto) noexcept;

	friend constexpr bool operator==(const xte::big_int<T>&, const xte::big_int<T>&) noexcept = default;

	friend constexpr bool operator==(const xte::big_int<T>&, xte::is_int auto) noexcept;

	friend constexpr bool operator==(const xte::big_int<T>&, xte::is_float auto) noexcept;

	constexpr auto&& operator+(this auto&&) noexcept;

	friend constexpr xte::big_int<T> operator+(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	friend constexpr xte::big_int<T> operator+(xte::big_int<T>, xte::big_int<T>&&) noexcept(false);

	constexpr xte::big_int<T>& operator+=(const xte::big_int<T>&) & noexcept(false);

	constexpr xte::big_int<T>& operator+=(xte::big_int<T>&&) & noexcept(false);

	constexpr xte::big_int<T>& operator++() & noexcept(false);

	constexpr xte::big_int<T>& operator++(int) & noexcept(false);

	constexpr xte::big_int<T> operator-() const & noexcept(false);

	constexpr xte::big_int<T>&& operator-() && noexcept;

	friend constexpr xte::big_int<T> operator-(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	friend constexpr xte::big_int<T> operator-(xte::big_int<T>, xte::big_int<T>&&) noexcept(false);

	constexpr xte::big_int<T>& operator-=(const xte::big_int<T>&) & noexcept(false);

	constexpr xte::big_int<T>& operator-=(xte::big_int<T>&&) & noexcept(false);

	constexpr xte::big_int<T>& operator--() & noexcept(false);

	constexpr xte::big_int<T>& operator--(int) & noexcept(false);

	friend constexpr xte::big_int<T> operator*(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	friend constexpr xte::big_int<T> operator*(xte::big_int<T>, xte::big_int<T>&&) noexcept(false);

	constexpr xte::big_int<T>& operator*=(const xte::big_int<T>&) & noexcept(false);

	constexpr xte::big_int<T>& operator*=(xte::big_int<T>&&) & noexcept(false);

	friend constexpr xte::big_int<T> operator/(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	constexpr xte::big_int<T>& operator/=(const xte::big_int<T>&) & noexcept(false);

	friend constexpr xte::big_int<T> operator%(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	constexpr xte::big_int<T>& operator%=(const xte::big_int<T>&) & noexcept(false);

	constexpr auto operator~(this auto&&) noexcept(false);

	friend constexpr xte::big_int<T> operator&(xte::big_int<T>, xte::big_int<T>) noexcept(false);

	constexpr xte::big_int<T>& operator&=(xte::big_int<T>) & noexcept(false);

	friend constexpr xte::big_int<T> operator|(xte::big_int<T>, xte::big_int<T>) noexcept(false);

	constexpr xte::big_int<T>& operator|=(xte::big_int<T>) & noexcept(false);

	friend constexpr xte::big_int<T> operator^(xte::big_int<T>, xte::big_int<T>) noexcept(false);

	constexpr xte::big_int<T>& operator^=(xte::big_int<T>) & noexcept(false);

	friend constexpr xte::big_int<T> operator<<(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	constexpr xte::big_int<T>& operator<<=(const xte::big_int<T>&) & noexcept(false);

	friend constexpr xte::big_int<T> operator>>(xte::big_int<T>, const xte::big_int<T>&) noexcept(false);

	constexpr xte::big_int<T>& operator>>=(const xte::big_int<T>&) & noexcept(false);

	constexpr auto abs(this auto&&) XTE_ARROW(/* ... */)

	constexpr xte::big_int<T> pow(this auto&&, const xte::big_int<T>&) noexcept(false);

	constexpr xte::big_int<T> pow(this auto&&, xte::big_int<T>&&) noexcept(false);

	constexpr xte::big_int<T> root(const xte::big_int<T>&) const noexcept(false);

	constexpr xte::big_int<T> log(const xte::big_int<T>&) const noexcept(false);

	static constexpr struct { /* ... */ } parse;

	template<xte::is_int Radix = xte::uz>
	constexpr xte::string str(this auto&&, Radix = 10, const xte::number_format_config& = {}) noexcept(false);
};


Literal suffix

namespace literal::big_int {
	template<char...>
	constexpr xte::big_int<> operator""_big() noexcept(false);
}


Specialization for formatting

template<typename T>
struct std::formatter<xte::big_int<T>>;



Example

std::println("{}", xte::big_int(99).pow(99));
Output:
369729637649726772657187905628805440595668764281741102430259972423552570455277523421410650010128232727940978889548326540119429996769494359451621570193644014418071060667659301384999779999159200499899
[View in Compiler Explorer]