Concepts

The following are the definitions of the concepts used throughout the library to ensure consistency. While these are from the detail folder of the library, they are included for clarity since they will be used in the function definitions of following sections.

Signed Integer

This is an extension of the <type_traits> definition to allow builtin __int128 to be used.

namespace boost {
namespace int128 {
namespace detail {

template <typename T>
struct signed_integer
{
    static constexpr bool value = (std::is_signed<T>::value && std::is_integral<T>::value)
    #ifdef BOOST_INT128_HAS_INT128
    || std::is_same<T, builtin_i128>::value;
    #endif
    ;
};

template <typename T>
static constexpr bool is_signed_integer_v = signed_integer<T>::value;

#define BOOST_INT128_DEFAULTED_SIGNED_INTEGER_CONCEPT typename SignedInteger, std::enable_if_t<detail::is_signed_integer_v<SignedInteger>, bool> = true

#define BOOST_INT128_SIGNED_INTEGER_CONCEPT typename SignedInteger, std::enable_if_t<detail::is_signed_integer_v<SignedInteger>, bool>

} // namespace detail
} // namespace int128
} // namespace boost

Unsigned Integer

This is an extension of the <type_traits> definition to allow builtin unsigned __int128 to be used.

namespace boost {
namespace int128 {
namespace detail {

template <typename T>
struct unsigned_integer
{
    static constexpr bool value = (std::is_unsigned<T>::value && std::is_integral<T>::value)
    #ifdef BOOST_INT128_HAS_INT128
    || std::is_same<T, builtin_u128>::value;
    #endif
    ;
};

template <typename T>
static constexpr bool is_unsigned_integer_v = unsigned_integer<T>::value;

#define BOOST_INT128_DEFAULTED_UNSIGNED_INTEGER_CONCEPT typename UnsignedInteger, std::enable_if_t<detail::is_unsigned_integer_v<UnsignedInteger>, bool> = true

#define BOOST_INT128_UNSIGNED_INTEGER_CONCEPT typename UnsignedInteger, std::enable_if_t<detail::is_unsigned_integer_v<UnsignedInteger>, bool>

} // namespace detail
} // namespace int128
} // namespace boost

Integer

This is a combination of the above two in which any integer can be detected

namespace boost {
namespace int128 {
namespace detail {

template <typename T>
static constexpr bool is_any_integer_v = signed_integer<T>::value || unsigned_integer<T>::value;

#define BOOST_INT128_DEFAULTED_INTEGER_CONCEPT typename Integer, std::enable_if_t<detail::is_any_integer_v<Integer>, bool> = true

#define BOOST_INT128_INTEGER_CONCEPT typename Integer, std::enable_if_t<detail::is_any_integer_v<Integer>, bool>

} // namespace detail
} // namespace int128
} // namespace boost