Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / gil / test / point / concepts.cpp
1 //
2 // Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
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_USE_CONCEPT_CHECK
9 #error Compile with BOOST_GIL_USE_CONCEPT_CHECK defined
10 #endif
11 #include <boost/gil/concepts.hpp>
12 #include <boost/gil/point.hpp>
13
14 #include <type_traits>
15
16 namespace gil = boost::gil;
17
18
19 template <typename Point>
20 void test_members()
21 {
22     static_assert(Point::num_dimensions == 2U, "point is not 2D");
23
24     using value_t = typename Point::value_type;
25     using coord_t = typename Point::template axis<0>::coord_t;
26     static_assert(std::is_same<value_t, coord_t>::value,
27                   "point and axis type mismatch");
28 }
29
30 int main()
31 {
32     boost::function_requires<gil::PointNDConcept<gil::point<int>>>();
33     boost::function_requires<gil::PointNDConcept<gil::point_t>>();
34
35     boost::function_requires<gil::Point2DConcept<gil::point<int>>>();
36     boost::function_requires<gil::Point2DConcept<gil::point_t>>();
37
38     test_members<gil::point<int>>();
39     test_members<gil::point_t>();
40
41     // NOTE: point2 is deprecated, available for backward compatibility
42     boost::function_requires<gil::PointNDConcept<gil::point2<int>>>();
43     boost::function_requires<gil::Point2DConcept<gil::point2<int>>>();
44     test_members<gil::point2<int>>();
45
46     return 0;
47 }