Boost GIL


pixel_dereference.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 //
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
7 //
8 #ifndef BOOST_GIL_CONCEPTS_PIXEL_DEREFERENCE_HPP
9 #define BOOST_GIL_CONCEPTS_PIXEL_DEREFERENCE_HPP
10 
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>
16 
17 #include <boost/concept_check.hpp>
18 
19 #include <cstddef>
20 #include <type_traits>
21 
22 #if defined(BOOST_CLANG)
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wunknown-pragmas"
25 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
26 #endif
27 
28 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
31 #endif
32 
33 namespace boost { namespace gil {
34 
52 template <typename D>
54 {
55  void constraints()
56  {
57  gil_function_requires
58  <
59  boost::UnaryFunctionConcept
60  <
61  D,
62  typename detail::remove_const_and_reference<typename D::result_type>::type,
63  typename D::argument_type
64  >
65  >();
66  gil_function_requires<boost::DefaultConstructibleConcept<D>>();
67  gil_function_requires<boost::CopyConstructibleConcept<D>>();
68  gil_function_requires<boost::AssignableConcept<D>>();
69 
70  gil_function_requires<PixelConcept
71  <
72  typename detail::remove_const_and_reference<typename D::result_type>::type
73  >>();
74 
75  using const_t = typename D::const_t;
76  gil_function_requires<PixelDereferenceAdaptorConcept<const_t>>();
77 
78  using value_type = typename D::value_type;
79  gil_function_requires<PixelValueConcept<value_type>>();
80 
81  // TODO: Should this be concept-checked after "if you remove const and reference"? --mloskot
82  using reference = typename D::reference; // == PixelConcept (if you remove const and reference)
83  using const_reference = typename D::const_reference; // == PixelConcept (if you remove const and reference)
84 
85  bool const is_mutable = D::is_mutable;
86  ignore_unused_variable_warning(is_mutable);
87  }
88  D d;
89 };
90 
91 template <typename P>
92 struct PixelDereferenceAdaptorArchetype
93 {
94  using argument_type = P;
95  using result_type = P;
96  using const_t = PixelDereferenceAdaptorArchetype;
97  using value_type = typename std::remove_reference<P>::type;
98  using reference = typename std::add_lvalue_reference<P>::type;
99  using const_reference = reference;
100 
101  static const bool is_mutable = false;
102  P operator()(P) const { throw; }
103 };
104 
105 }} // namespace boost::gil
106 
107 #if defined(BOOST_CLANG)
108 #pragma clang diagnostic pop
109 #endif
110 
111 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
112 #pragma GCC diagnostic pop
113 #endif
114 
115 #endif
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
Pixel concept - A color base whose elements are channels.
Definition: concepts/pixel.hpp:64
Represents a unary function object that can be invoked upon dereferencing a pixel iterator.
Definition: pixel_dereference.hpp:54