#pragma once
#include<cassert>
#include<type_traits>#include"internal/dev_env.hpp"namespaceuni{template<classEngine>structrandom_adaptor{usingresult_type=typenameEngine::result_type;usingsigned_result_type=typenamestd::make_signed_t<result_type>;private:Engineengine;public:staticconstexprresult_typeMIN=Engine::min();staticconstexprresult_typeMAX=Engine::max();staticconstexprresult_typemin()noexcept(NO_EXCEPT){returnMIN;}staticconstexprresult_typemax()noexcept(NO_EXCEPT){returnMAX;}constexprrandom_adaptor(unsignedlongseed=3141592653UL)noexcept(NO_EXCEPT){this->engine.seed(seed);};inlineconstexprresult_typeoperator()()noexcept(NO_EXCEPT){returnthis->engine();}inlineconstexprresult_typeoperator()(constresult_typesup)noexcept(NO_EXCEPT){assert(0<sup);returnthis->engine()%sup;}inlineconstexprsigned_result_typeoperator()(constsigned_result_typemin,constsigned_result_typesup)noexcept(NO_EXCEPT){assert(min<sup);returnmin+(*this)(sup-min);};template<classT=double>inlineconstexprautoreal()noexcept(NO_EXCEPT){constautov=static_cast<T>((this->engine()+0.5)/(1.0+this->max()));returnstatic_cast<T>((this->operator()()+v)/(1.0+this->max()));}};}// namespace uni