Skip to content

Commit

Permalink
Replace Boost.MPL with Boost.MP11 in promote_integral.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
codejaeger committed Mar 9, 2020
1 parent 316b7d6 commit 8f8ea7d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions include/boost/gil/promote_integral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// Copyright (c) 2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
//
// Copyright (c) 2020, Debabrata Mandal <mandaldebabrata123@gmail.com>
//
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
Expand All @@ -12,15 +14,12 @@
// - Rename include guards
// - Remove support for boost::multiprecision types
// - Remove support for 128-bit integer types
// - Replace mpl meta functions with mp11 equivalents
//
#ifndef BOOST_GIL_PROMOTE_INTEGRAL_HPP
#define BOOST_GIL_PROMOTE_INTEGRAL_HPP

#include <boost/mpl/begin.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/end.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mp11/list.hpp>

#include <climits>
#include <cstddef>
Expand All @@ -47,13 +46,13 @@ struct bit_size<T, true> : std::integral_constant<std::size_t, (CHAR_BIT * sizeo
template
<
typename T,
typename Iterator,
typename EndIterator,
typename type_list,
std::size_t MinSize
>
struct promote_to_larger
{
using current_type = typename boost::mpl::deref<Iterator>::type;
using current_type = boost::mp11::mp_first<type_list>;
using list_after_front = boost::mp11::mp_rest<type_list>;

using type = typename std::conditional
<
Expand All @@ -62,17 +61,16 @@ struct promote_to_larger
typename promote_to_larger
<
T,
typename boost::mpl::next<Iterator>::type,
EndIterator,
list_after_front,
MinSize
>::type
>::type;
};

// The following specialization is required to finish the loop over
// all list elements
template <typename T, typename EndIterator, std::size_t MinSize>
struct promote_to_larger<T, EndIterator, EndIterator, MinSize>
template <typename T, std::size_t MinSize>
struct promote_to_larger<T, boost::mp11::mp_list<>, MinSize>
{
// if promotion fails, keep the number T
// (and cross fingers that overflow will not occur)
Expand Down Expand Up @@ -148,7 +146,7 @@ class promote_integral

// Define the list of signed integral types we are going to use
// for promotion
using signed_integral_types = boost::mpl::list
using signed_integral_types = boost::mp11::mp_list
<
short, int, long
#if defined(BOOST_HAS_LONG_LONG)
Expand All @@ -158,7 +156,7 @@ class promote_integral

// Define the list of unsigned integral types we are going to use
// for promotion
using unsigned_integral_types = boost::mpl::list
using unsigned_integral_types = boost::mp11::mp_list
<
unsigned short, unsigned int, unsigned long, std::size_t
#if defined(BOOST_HAS_LONG_LONG)
Expand All @@ -180,8 +178,7 @@ class promote_integral
using type = typename detail::promote_integral::promote_to_larger
<
T,
typename boost::mpl::begin<integral_types>::type,
typename boost::mpl::end<integral_types>::type,
integral_types,
min_bit_size_type::value
>::type;
};
Expand Down

0 comments on commit 8f8ea7d

Please sign in to comment.