###  | #  |

basic.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_BASIC_HPP
9#define BOOST_GIL_CONCEPTS_BASIC_HPP
10
11#include <boost/config.hpp>
12
13#if defined(BOOST_CLANG)
14#pragma clang diagnostic push
15#pragma clang diagnostic ignored "-Wunknown-pragmas"
16#pragma clang diagnostic ignored "-Wunused-local-typedefs"
17#pragma clang diagnostic ignored "-Wuninitialized"
18#endif
19
20#if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23#pragma GCC diagnostic ignored "-Wuninitialized"
24#endif
25
26#include <boost/gil/concepts/concept_check.hpp>
27
28#include <type_traits>
29#include <utility> // std::swap
30
31 namespace boost { namespace gil {
32
42 template <typename T>
43 struct DefaultConstructible
44{
45 void constraints()
46 {
47 function_requires<boost::DefaultConstructibleConcept<T>>();
48 }
49};
50
61 template <typename T>
62 struct CopyConstructible
63{
64 void constraints()
65 {
66 function_requires<boost::CopyConstructibleConcept<T>>();
67 }
68};
69
80 template <typename T>
81 struct Assignable
82{
83 void constraints()
84 {
85 function_requires<boost::AssignableConcept<T>>();
86 }
87};
88
99 template <typename T>
100 struct EqualityComparable
101{
102 void constraints()
103 {
104 function_requires<boost::EqualityComparableConcept<T>>();
105 }
106};
107
117 template <typename T>
118 struct Swappable
119{
120 void constraints()
121 {
122 using std::swap;
123 swap(x,y);
124 }
125 T x,y;
126};
127
140 template <typename T>
141 struct Regular
142{
143 void constraints()
144 {
145 gil_function_requires< boost::DefaultConstructibleConcept<T>>();
146 gil_function_requires< boost::CopyConstructibleConcept<T>>();
147 gil_function_requires< boost::EqualityComparableConcept<T>>(); // ==, !=
148 gil_function_requires< boost::AssignableConcept<T>>();
149 gil_function_requires< Swappable<T>>();
150 }
151};
152
162 template <typename T>
163 struct Metafunction
164{
165 void constraints()
166 {
167 using type = typename T::type;
168 }
169};
170
177 template <typename T, typename U>
178 struct SameType
179{
180 void constraints()
181 {
182 static_assert(std::is_same<T, U>::value, "");
183 }
184};
185
186}} // namespace boost::gil
187
188#if defined(BOOST_CLANG)
189#pragma clang diagnostic pop
190#endif
191
192#if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
193#pragma GCC diagnostic pop
194#endif
195
196#endif
boost
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition algorithm.hpp:36
boost::gil::Assignable
Concept of copy assignment requirement.
Definition basic.hpp:82
boost::gil::CopyConstructible
Concept of copy construction requirement.
Definition basic.hpp:63
boost::gil::DefaultConstructible
Concept of default construction requirement.
Definition basic.hpp:44
boost::gil::EqualityComparable
Concept of == and != comparability requirement.
Definition basic.hpp:101
boost::gil::Metafunction
Concept for type as metafunction requirement.
Definition basic.hpp:164
boost::gil::Regular
Concept for type regularity requirement.
Definition basic.hpp:142
boost::gil::SameType
Concept of types equivalence requirement.
Definition basic.hpp:179
boost::gil::Swappable
Concept of swap operation requirement.
Definition basic.hpp:119
boost::gil::type