// Copyright (C) 2026 Kiyotsugu Arai
// SPDX-License-Identifier: LGPL-3.0-or-later
// ModularInt.hpp
#ifndef SANGI_MODULAR_INT_HPP
#define SANGI_MODULAR_INT_HPP
// Modular integer class (C++20/23 ready, concept-aware version)
//
// This file defines a class template that provides efficient modular integer
// arithmetic.
// ModularInt
represents an element of the residue field Z/PZ for the
// prime modulus P.
// It supports basic arithmetic operations (addition, subtraction,
// multiplication, division), exponentiation, and comparison operations.
//
// Main features:
// - Modulus is specified through a template parameter
// - Integrates with C++20 concepts
// - Efficient algorithms
// - Integrates with algebraic structures (monoid, group, ring, field)
// - Stream I/O support
//
// Usage example:
// ```
// ModularInt<1000000007> a = 42; // 42 mod 10^9+7
// ModularInt<1000000007> b = 987654321;
// auto c = a * b; // 41477417 mod 10^9+7
// auto d = a.pow(12345); // a^12345 mod 10^9+7
// ```
#include