Boost GIL


concepts/point.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_POINT_HPP
9 #define BOOST_GIL_CONCEPTS_POINT_HPP
10 
11 #include <boost/gil/concepts/basic.hpp>
12 #include <boost/gil/concepts/concept_check.hpp>
13 
14 #include <cstddef>
15 
16 #if defined(BOOST_CLANG)
17 #pragma clang diagnostic push
18 #pragma clang diagnostic ignored "-Wunknown-pragmas"
19 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
20 #endif
21 
22 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
25 #endif
26 
27 namespace boost { namespace gil {
28 
29 // Forward declarations
30 template <typename T>
31 class point;
32 
33 template <std::size_t K, typename T>
34 T const& axis_value(point<T> const& p);
35 
36 template <std::size_t K, typename T>
37 T& axis_value(point<T>& p);
38 
60 template <typename P>
62 {
63  void constraints()
64  {
65  gil_function_requires<Regular<P>>();
66 
67  using value_type = typename P::value_type;
68  ignore_unused_variable_warning(value_type{});
69 
70  static const std::size_t N = P::num_dimensions;
71  ignore_unused_variable_warning(N);
72  using FT = typename P::template axis<0>::coord_t;
73  using LT = typename P::template axis<N - 1>::coord_t;
74  FT ft = gil::axis_value<0>(point);
75  axis_value<0>(point) = ft;
76  LT lt = axis_value<N - 1>(point);
77  axis_value<N - 1>(point) = lt;
78 
79  //value_type v=point[0];
80  //ignore_unused_variable_warning(v);
81  }
82  P point;
83 };
84 
102 template <typename P>
104 {
105  void constraints()
106  {
107  gil_function_requires<PointNDConcept<P>>();
108  static_assert(P::num_dimensions == 2, "");
109  point.x = point.y;
110  point[0] = point[1];
111  }
112  P point;
113 };
114 
115 }} // namespace boost::gil
116 
117 #if defined(BOOST_CLANG)
118 #pragma clang diagnostic pop
119 #endif
120 
121 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
122 #pragma GCC diagnostic pop
123 #endif
124 
125 #endif
N-dimensional point concept.
Definition: concepts/point.hpp:61
2-dimensional point concept
Definition: concepts/point.hpp:103
2D point both axes of which have the same dimension typeModels: Point2DConcept
Definition: locator.hpp:28