Blame view

3rdparty/boost_1_81_0/boost/gil/concepts/point.hpp 3.02 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  //
  // Copyright 2005-2007 Adobe Systems Incorporated
  //
  // Distributed under the Boost Software License, Version 1.0
  // See accompanying file LICENSE_1_0.txt or copy at
  // http://www.boost.org/LICENSE_1_0.txt
  //
  #ifndef BOOST_GIL_CONCEPTS_POINT_HPP
  #define BOOST_GIL_CONCEPTS_POINT_HPP
  
  #include <boost/gil/concepts/basic.hpp>
  #include <boost/gil/concepts/concept_check.hpp>
  
  #include <cstddef>
  
  #if defined(BOOST_CLANG)
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wunknown-pragmas"
  #pragma clang diagnostic ignored "-Wunused-local-typedefs"
  #endif
  
  #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
  #endif
  
  namespace boost { namespace gil {
  
  // Forward declarations
  template <typename T>
  class point;
  
  template <std::size_t K, typename T>
  T const& axis_value(point<T> const& p);
  
  template <std::size_t K, typename T>
  T& axis_value(point<T>& p);
  
  /// \brief N-dimensional point concept
  /// \code
  /// concept PointNDConcept<typename T> : Regular<T>
  /// {
  ///     // the type of a coordinate along each axis
  ///     template <size_t K>
  ///     struct axis; where Metafunction<axis>;
  ///
  ///     const size_t num_dimensions;
  ///
  ///     // accessor/modifier of the value of each axis.
  ///
  ///     template <size_t K>
  ///     typename axis<K>::type const& T::axis_value() const;
  ///
  ///     template <size_t K>
  ///     typename axis<K>::type& T::axis_value();
  /// };
  /// \endcode
  /// \ingroup PointConcept
  ///
  template <typename P>
  struct PointNDConcept
  {
      void constraints()
      {
          gil_function_requires<Regular<P>>();
  
          using value_type = typename P::value_type;
          ignore_unused_variable_warning(value_type{});
  
          static const std::size_t N = P::num_dimensions;
          ignore_unused_variable_warning(N);
          using FT = typename P::template axis<0>::coord_t;
          using LT = typename P::template axis<N - 1>::coord_t;
          FT ft = gil::axis_value<0>(point);
          axis_value<0>(point) = ft;
          LT lt = axis_value<N - 1>(point);
          axis_value<N - 1>(point) = lt;
  
          //value_type v=point[0];
          //ignore_unused_variable_warning(v);
      }
      P point;
  };
  
  /// \brief 2-dimensional point concept
  /// \code
  /// concept Point2DConcept<typename T> : PointNDConcept<T>
  /// {
  ///     where num_dimensions == 2;
  ///     where SameType<axis<0>::type, axis<1>::type>;
  ///
  ///     typename value_type = axis<0>::type;
  ///
  ///     value_type const& operator[](T const&, size_t i);
  ///     value_type& operator[](T&, size_t i);
  ///
  ///     value_type x,y;
  /// };
  /// \endcode
  /// \ingroup PointConcept
  ///
  template <typename P>
  struct Point2DConcept
  {
      void constraints()
      {
          gil_function_requires<PointNDConcept<P>>();
          static_assert(P::num_dimensions == 2, "");
          point.x = point.y;
          point[0] = point[1];
      }
      P point;
  };
  
  }} // namespace boost::gil
  
  #if defined(BOOST_CLANG)
  #pragma clang diagnostic pop
  #endif
  
  #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
  #pragma GCC diagnostic pop
  #endif
  
  #endif