Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include"base/dependencies/index.hpp"
- #include"floats.hpp"
- #include"integers.hpp"
- // Type modification from a type to its base version.
- template<class Type>struct base{using type=remove_cvref_t<Type>;};
- template<class Type>using base_t=base<Type>::type;
- // Concept for standard integer type aliases.
- template<class Type>concept Integer=
- is_same_v<base_t<Type>,s32>||
- is_same_v<base_t<Type>,s64>||
- is_same_v<base_t<Type>,u32>||
- is_same_v<base_t<Type>,u64>;
- // Concept for all integer type aliases.
- template<class Type>concept Whole=
- Integer<Type>||is_same_v<base_t<Type>,s128>||is_same_v<base_t<Type>,u128>;
- // Concept for all floating point type aliases.
- template<class Type>concept Float=
- is_same_v<base_t<Type>,f32>||
- is_same_v<base_t<Type>,f64>||
- is_same_v<base_t<Type>,f80>;
- // Type modification from a base integer type to its next base version.
- template<Integer Int>struct grow_base{using type=void;};
- template<>struct grow_base<s32>{using type=s64;};
- template<>struct grow_base<s64>{using type=s128;};
- template<>struct grow_base<u32>{using type=u64;};
- template<>struct grow_base<u64>{using type=u128;};
- template<Integer Int>using grow_base_t=grow_base<Int>::type;
- // Type modification from an integer type to its next base version.
- template<Integer Int>struct grow{using type=grow_base_t<base_t<Int>>;};
- template<Integer Int>using grow_t=grow<Int>::type;
- // Type modification from a base integer type to its base signed version.
- template<Whole Int>struct sign_base{using type=make_signed_t<Int>;};
- template<>struct sign_base<s128>{using type=s128;};
- template<>struct sign_base<u128>{using type=s128;};
- template<Whole Int>using sign_base_t=sign_base<Int>::type;
- // Type modification from an integer type to its base signed version.
- template<Whole Int>struct sign{using type=sign_base_t<base_t<Int>>;};
- template<Whole Int>using sign_t=sign<Int>::type;
- // Type modification from a base integer type to its base unsigned version.
- template<Whole Int>struct unsign_base{using type=make_unsigned_t<Int>;};
- template<>struct unsign_base<s128>{using type=u128;};
- template<>struct unsign_base<u128>{using type=u128;};
- template<Whole Int>using unsign_base_t=unsign_base<Int>::type;
- // Type modification from an integer type to its base unsigned version.
- template<Whole Int>struct unsign{using type=unsign_base_t<base_t<Int>>;};
- template<Whole Int>using unsign_t=unsign<Int>::type;
- // Relative integer type casts.
- #define BASE(a)(static_cast<base_t<decltype(a)>>(a))
- #define GROW(a)(static_cast<grow_t<decltype(a)>>(a))
- #define SIGN(a)(static_cast<sign_t<decltype(a)>>(a))
- #define UNSIGN(a)(static_cast<unsign_t<decltype(a)>>(a))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement