Added support for int128 to counting_iterator.

This commit is contained in:
Andrey Semashev 2022-01-13 16:59:46 +03:00
parent abe6fbfd4b
commit eb0d01126a
2 changed files with 33 additions and 4 deletions

View File

@ -67,11 +67,21 @@ namespace detail
# if defined(BOOST_HAS_LONG_LONG)
template <>
struct is_numeric< ::boost::long_long_type>
struct is_numeric<boost::long_long_type>
: boost::true_type {};
template <>
struct is_numeric< ::boost::ulong_long_type>
struct is_numeric<boost::ulong_long_type>
: boost::true_type {};
# endif
# if defined(BOOST_HAS_INT128)
template <>
struct is_numeric<boost::int128_type>
: boost::true_type {};
template <>
struct is_numeric<boost::uint128_type>
: boost::true_type {};
# endif
@ -86,6 +96,21 @@ namespace detail
typedef typename boost::detail::numeric_traits<T>::difference_type type;
};
# if defined(BOOST_HAS_INT128)
// std::numeric_limits, which is used by numeric_traits, is not specialized for __int128 in some standard libraries
template <>
struct numeric_difference<boost::int128_type>
{
typedef boost::int128_type type;
};
template <>
struct numeric_difference<boost::uint128_type>
{
typedef boost::int128_type type;
};
# endif
template <class Incrementable, class CategoryOrTraversal, class Difference>
struct counting_iterator_base
{

View File

@ -271,8 +271,12 @@ int main()
test_integer<long>();
test_integer<unsigned long>();
#if defined(BOOST_HAS_LONG_LONG)
test_integer< ::boost::long_long_type>();
test_integer< ::boost::ulong_long_type>();
test_integer<boost::long_long_type>();
test_integer<boost::ulong_long_type>();
#endif
#if defined(BOOST_HAS_INT128)
test_integer<boost::int128_type>();
test_integer<boost::uint128_type>();
#endif
// Test user-defined type.