]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/test/core/channel/concepts.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / gil / test / core / channel / concepts.cpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 // Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
4 //
5 // Distributed under the Boost Software License, Version 1.0
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
8 //
9 #include <boost/config.hpp>
10
11 #if defined(BOOST_CLANG)
12 #pragma clang diagnostic push
13 #pragma GCC diagnostic ignored "-Wuninitialized"
14 #endif
15
16 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
17 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wuninitialized"
19 #endif
20
21 #include <boost/gil/concepts.hpp>
22 #include <cstdint>
23
24 #define BOOST_TEST_MODULE test_channel_concepts
25 #include "unit_test.hpp"
26 #include "test_fixture.hpp"
27
28 namespace gil = boost::gil;
29 namespace fixture = boost::gil::test::fixture;
30
31 // A channel archetype - to test the minimum requirements of the concept
32 struct channel_value_archetype;
33
34 struct channel_archetype
35 {
36 // equality comparable
37 friend bool operator==(channel_archetype const&, channel_archetype const&)
38 { return true; }
39 // inequality comparable
40 friend bool operator!=(channel_archetype const&, channel_archetype const&)
41 { return false; }
42 // less-than comparable
43 friend bool operator<(channel_archetype const&, channel_archetype const&)
44 { return false; }
45 // convertible to a scalar
46 operator std::uint8_t() const { return 0; }
47
48 channel_archetype& operator++() { return *this; }
49 channel_archetype& operator--() { return *this; }
50 channel_archetype operator++(int) { return *this; }
51 channel_archetype operator--(int) { return *this; }
52
53 template <typename Scalar>
54 channel_archetype operator+=(Scalar) { return *this; }
55 template <typename Scalar>
56 channel_archetype operator-=(Scalar) { return *this; }
57 template <typename Scalar>
58 channel_archetype operator*=(Scalar) { return *this; }
59 template <typename Scalar>
60 channel_archetype operator/=(Scalar) { return *this; }
61
62 using value_type = channel_value_archetype;
63 using reference = channel_archetype;
64 using const_reference = channel_archetype const;
65 using pointer = channel_value_archetype*;
66 using const_pointer = channel_value_archetype const*;
67 static constexpr bool is_mutable = true;
68
69 static value_type min_value();
70 static value_type max_value();
71 };
72
73 struct channel_value_archetype : public channel_archetype
74 {
75 // default constructible
76 channel_value_archetype() {}
77 // copy constructible
78 channel_value_archetype(channel_value_archetype const&) = default;
79 // assignable
80 channel_value_archetype& operator=(channel_value_archetype const&)
81 {return *this;}
82 channel_value_archetype(std::uint8_t) {}
83 };
84
85 channel_value_archetype channel_archetype::min_value()
86 {
87 return channel_value_archetype();
88 }
89
90 channel_value_archetype channel_archetype::max_value()
91 {
92 return channel_value_archetype();
93 }
94
95 BOOST_AUTO_TEST_CASE(channel_minimal_requirements)
96 {
97 // Do only compile-time tests for the archetype
98 // (because asserts like val1<val2 fail)
99 boost::function_requires<gil::MutableChannelConcept<channel_archetype>>();
100
101 fixture::channel_value<channel_value_archetype>();
102 fixture::channel_reference<channel_archetype>();
103 fixture::channel_reference<channel_archetype const&>();
104 }