2 // Copyright 2005-2007 Adobe Systems Incorporated
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 #ifndef BOOST_GIL_CONCEPTS_PIXEL_DEREFERENCE_HPP
9 #define BOOST_GIL_CONCEPTS_PIXEL_DEREFERENCE_HPP
11 #include <boost/gil/concepts/basic.hpp>
12 #include <boost/gil/concepts/concept_check.hpp>
13 #include <boost/gil/concepts/fwd.hpp>
14 #include <boost/gil/concepts/pixel.hpp>
15 #include <boost/gil/concepts/detail/type_traits.hpp>
17 #include <boost/concept_check.hpp>
20 #include <type_traits>
22 #if defined(BOOST_CLANG)
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
27 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
32 namespace boost { namespace gil {
34 /// \ingroup PixelDereferenceAdaptorConcept
35 /// \brief Represents a unary function object that can be invoked upon dereferencing a pixel iterator.
37 /// This can perform an arbitrary computation, such as color conversion or table lookup.
39 /// concept PixelDereferenceAdaptorConcept<boost::UnaryFunctionConcept D>
40 /// : DefaultConstructibleConcept<D>, CopyConstructibleConcept<D>, AssignableConcept<D>
42 /// typename const_t; where PixelDereferenceAdaptorConcept<const_t>;
43 /// typename value_type; where PixelValueConcept<value_type>;
44 /// typename reference; // may be mutable
45 /// typename const_reference; // must not be mutable
46 /// static const bool D::is_mutable;
48 /// where Convertible<value_type,result_type>;
52 struct PixelDereferenceAdaptorConcept
58 boost::UnaryFunctionConcept
61 typename detail::remove_const_and_reference<typename D::result_type>::type,
62 typename D::argument_type
65 gil_function_requires<boost::DefaultConstructibleConcept<D>>();
66 gil_function_requires<boost::CopyConstructibleConcept<D>>();
67 gil_function_requires<boost::AssignableConcept<D>>();
69 gil_function_requires<PixelConcept
71 typename detail::remove_const_and_reference<typename D::result_type>::type
74 using const_t = typename D::const_t;
75 gil_function_requires<PixelDereferenceAdaptorConcept<const_t>>();
77 using value_type = typename D::value_type;
78 gil_function_requires<PixelValueConcept<value_type>>();
80 // TODO: Should this be concept-checked after "if you remove const and reference"? --mloskot
81 using reference = typename D::reference; // == PixelConcept (if you remove const and reference)
82 using const_reference = typename D::const_reference; // == PixelConcept (if you remove const and reference)
84 bool const is_mutable = D::is_mutable;
85 ignore_unused_variable_warning(is_mutable);
91 struct PixelDereferenceAdaptorArchetype
93 using argument_type = P;
94 using result_type = P;
95 using const_t = PixelDereferenceAdaptorArchetype;
96 using value_type = typename std::remove_reference<P>::type;
97 using reference = typename std::add_lvalue_reference<P>::type;
98 using const_reference = reference;
100 static const bool is_mutable = false;
101 P operator()(P) const { throw; }
104 }} // namespace boost::gil
106 #if defined(BOOST_CLANG)
107 #pragma clang diagnostic pop
110 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
111 #pragma GCC diagnostic pop