Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / core / 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 // FIXME: Avoid Clang's flooding of non-disableable warnings like:
9 // "T does not declare any constructor to initialize its non-modifiable members"
10 // when compiling with concepts check enabled.
11 // See https://bugs.llvm.org/show_bug.cgi?id=41759
12 #if !defined(BOOST_GIL_USE_CONCEPT_CHECK) && !defined(__clang__)
13 #error Compile with BOOST_GIL_USE_CONCEPT_CHECK defined
14 #endif
15 #include <boost/gil/concepts.hpp>
16 #include <boost/gil/point.hpp>
17
18 #include <type_traits>
19
20 namespace gil = boost::gil;
21
22
23 template <typename Point>
24 void test_members()
25 {
26     static_assert(Point::num_dimensions == 2U, "point is not 2D");
27
28     using value_t = typename Point::value_type;
29     using coord_t = typename Point::template axis<0>::coord_t;
30     static_assert(std::is_same<value_t, coord_t>::value,
31                   "point and axis type mismatch");
32 }
33
34 int main()
35 {
36     boost::function_requires<gil::PointNDConcept<gil::point<int>>>();
37     boost::function_requires<gil::PointNDConcept<gil::point_t>>();
38
39     boost::function_requires<gil::Point2DConcept<gil::point<int>>>();
40     boost::function_requires<gil::Point2DConcept<gil::point_t>>();
41
42     test_members<gil::point<int>>();
43     test_members<gil::point_t>();
44
45     // NOTE: point2 is deprecated, available for backward compatibility
46     boost::function_requires<gil::PointNDConcept<gil::point2<int>>>();
47     boost::function_requires<gil::Point2DConcept<gil::point2<int>>>();
48     test_members<gil::point2<int>>();
49
50     return 0;
51 }