//
// Copyright 2005-2007 Adobe Systems Incorporated
+// Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
#include <boost/gil/concepts.hpp>
#include <boost/gil/utilities.hpp>
+#include <boost/gil/detail/mp11.hpp>
#include <boost/config.hpp>
-#include <boost/mpl/at.hpp>
-#include <boost/mpl/contains.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/type_traits.hpp>
#include <algorithm>
#include <type_traits>
namespace boost { namespace gil {
///////////////////////////////////////
-///
/// size: Semantic channel size
-///
///////////////////////////////////////
/**
\defgroup ColorBaseAlgorithmSize size
\ingroup ColorBaseAlgorithm
-\brief Returns an MPL integral type specifying the number of elements in a color base
+\brief Returns an integral constant type specifying the number of elements in a color base
Example:
\code
\endcode
*/
-/// \brief Returns an MPL integral type specifying the number of elements in a color base
+/// \brief Returns an integral constant type specifying the number of elements in a color base
/// \ingroup ColorBaseAlgorithmSize
template <typename ColorBase>
-struct size : public mpl::size<typename ColorBase::layout_t::color_space_t> {};
+struct size : public mp11::mp_size<typename ColorBase::layout_t::color_space_t> {};
///////////////////////////////////////
-///
/// semantic_at_c: Semantic channel accessors
-///
///////////////////////////////////////
/**
Example:
\code
// 16-bit BGR pixel, 4 bits for the blue, 3 bits for the green, 2 bits for the red channel and 7 unused bits
-using bgr432_pixel_t = packed_pixel_type<uint16_t, mpl::vector3_c<unsigned,4,3,2>, bgr_layout_t>::type;
+using bgr432_pixel_t = packed_pixel_type<uint16_t, mp11::mp_list_c<unsigned,4,3,2>, bgr_layout_t>::type;
// A reference to its red channel. Although the red channel is the third, its semantic index is 0 in the RGB color space
using red_channel_reference_t = kth_semantic_element_reference_type<bgr432_pixel_t, 0>::type;
struct kth_semantic_element_type
{
using channel_mapping_t = typename ColorBase::layout_t::channel_mapping_t;
- static_assert(K < mpl::size<channel_mapping_t>::value,
+ static_assert(K < mp11::mp_size<channel_mapping_t>::value,
"K index should be less than size of channel_mapping_t sequence");
- static constexpr int semantic_index = mpl::at_c<channel_mapping_t, K>::type::value;
+ static constexpr int semantic_index = mp11::mp_at_c<channel_mapping_t, K>::type::value;
using type = typename kth_element_type<ColorBase, semantic_index>::type;
};
struct kth_semantic_element_reference_type
{
using channel_mapping_t = typename ColorBase::layout_t::channel_mapping_t;
- static_assert(K < mpl::size<channel_mapping_t>::value,
+ static_assert(K < mp11::mp_size<channel_mapping_t>::value,
"K index should be less than size of channel_mapping_t sequence");
- static constexpr int semantic_index = mpl::at_c<channel_mapping_t, K>::type::value;
+ static constexpr int semantic_index = mp11::mp_at_c<channel_mapping_t, K>::type::value;
using type = typename kth_element_reference_type<ColorBase, semantic_index>::type;
static type get(ColorBase& cb) { return gil::at_c<semantic_index>(cb); }
};
/// \brief Specifies the return type of the constant semantic_at_c<K>(color_base);
/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <typename ColorBase, int K> struct kth_semantic_element_const_reference_type
+template <typename ColorBase, int K>
+struct kth_semantic_element_const_reference_type
{
using channel_mapping_t = typename ColorBase::layout_t::channel_mapping_t;
- static_assert(K < mpl::size<channel_mapping_t>::value,
+ static_assert(K < mp11::mp_size<channel_mapping_t>::value,
"K index should be less than size of channel_mapping_t sequence");
- static constexpr int semantic_index = mpl::at_c<channel_mapping_t, K>::type::value;
+ static constexpr int semantic_index = mp11::mp_at_c<channel_mapping_t, K>::type::value;
using type = typename kth_element_const_reference_type<ColorBase,semantic_index>::type;
static type get(const ColorBase& cb) { return gil::at_c<semantic_index>(cb); }
};
typename kth_semantic_element_reference_type<ColorBase, K>::type
>::type
{
- return kth_semantic_element_reference_type<ColorBase,K>::get(p);
+ return kth_semantic_element_reference_type<ColorBase, K>::get(p);
}
/// \brief A constant accessor to the K-th semantic element of a color base
/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <int K, typename ColorBase> inline
-typename kth_semantic_element_const_reference_type<ColorBase,K>::type
-semantic_at_c(const ColorBase& p) {
- return kth_semantic_element_const_reference_type<ColorBase,K>::get(p);
+template <int K, typename ColorBase>
+inline
+auto semantic_at_c(ColorBase const& p)
+ -> typename kth_semantic_element_const_reference_type<ColorBase, K>::type
+{
+ return kth_semantic_element_const_reference_type<ColorBase, K>::get(p);
}
///////////////////////////////////////
-///
/// get_color: Named channel accessors
-///
///////////////////////////////////////
/**
/// \brief A predicate metafunction determining whether a given color base contains a given color
/// \ingroup ColorBaseAlgorithmColor
template <typename ColorBase, typename Color>
-struct contains_color : public mpl::contains<typename ColorBase::layout_t::color_space_t,Color> {};
+struct contains_color
+ : mp11::mp_contains<typename ColorBase::layout_t::color_space_t, Color>
+{};
template <typename ColorBase, typename Color>
struct color_index_type : public detail::type_to_index<typename ColorBase::layout_t::color_space_t,Color> {};
struct element_recursion
{
-#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
+#if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wfloat-equal"
semantic_at_c<N-1>(dst)=op();
}
-#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
+#if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
#pragma GCC diagnostic pop
#endif
template <typename Src,typename Dst>
BOOST_FORCEINLINE
-void static_copy(const Src& src, Dst& dst) { detail::element_recursion<size<Dst>::value>::static_copy(src,dst); }
+void static_copy(const Src& src, Dst& dst)
+{
+ detail::element_recursion<size<Dst>::value>::static_copy(src, dst);
+}
/// \}
template <typename P,typename V>
BOOST_FORCEINLINE
-void static_fill(P& p, const V& v) { detail::element_recursion<size<P>::value>::static_fill(p,v); }
+void static_fill(P& p, const V& v)
+{
+ detail::element_recursion<size<P>::value>::static_fill(p,v);
+}
+
/// \}
/// \defgroup ColorBaseAlgorithmGenerate static_generate