xieite::try_unsign<>

Defined in fragment xieite:try_unsign
(header-only: <xieite/meta/try_unsign.hpp>)


If a type is a signed integer, evaluates to its unsigned counterpart.
Otherwise, leaves the type unchanged.


Declaration

template<typename T>
using try_unsign = std::conditional_t<std::signed_integral<T>, std::make_unsigned<T>, std::type_identity<T>>::type;


Example

import std;
import xieite;

int main() {
	xieite::dump(std::same_as<unsigned int, xieite::try_unsign<int>>);
	xieite::dump(std::same_as<double, xieite::try_unsign<double>>);
}
Output:
true
true