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