Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:54

0001 //
0002 // Copyright 2005-2007 Adobe Systems Incorporated
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 #ifndef BOOST_GIL_CONCEPTS_BASIC_HPP
0009 #define BOOST_GIL_CONCEPTS_BASIC_HPP
0010 
0011 #include <boost/config.hpp>
0012 
0013 #if defined(BOOST_CLANG)
0014 #pragma clang diagnostic push
0015 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0016 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0017 #pragma clang diagnostic ignored "-Wuninitialized"
0018 #endif
0019 
0020 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0021 #pragma GCC diagnostic push
0022 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0023 #pragma GCC diagnostic ignored "-Wuninitialized"
0024 #endif
0025 
0026 #include <boost/gil/concepts/concept_check.hpp>
0027 
0028 #include <type_traits>
0029 #include <utility> // std::swap
0030 
0031 namespace boost { namespace gil {
0032 
0033 /// \brief Concept of default construction requirement.
0034 /// \code
0035 /// auto concept DefaultConstructible<typename T>
0036 /// {
0037 ///     T::T();
0038 /// };
0039 /// \endcode
0040 /// \ingroup BasicConcepts
0041 ///
0042 template <typename T>
0043 struct DefaultConstructible
0044 {
0045     void constraints()
0046     {
0047         function_requires<boost::DefaultConstructibleConcept<T>>();
0048     }
0049 };
0050 
0051 /// \brief Concept of copy construction requirement.
0052 /// \code
0053 /// auto concept CopyConstructible<typename T>
0054 /// {
0055 ///     T::T(T);
0056 ///     T::~T();
0057 /// };
0058 /// \endcode
0059 /// \ingroup BasicConcepts
0060 ///
0061 template <typename T>
0062 struct CopyConstructible
0063 {
0064     void constraints()
0065     {
0066         function_requires<boost::CopyConstructibleConcept<T>>();
0067     }
0068 };
0069 
0070 /// \brief Concept of copy assignment requirement.
0071 /// \code
0072 /// auto concept Assignable<typename T, typename U = T>
0073 /// {
0074 ///     typename result_type;
0075 ///     result_type operator=(T&, U);
0076 /// };
0077 /// \endcode
0078 /// \ingroup BasicConcepts
0079 ///
0080 template <typename T>
0081 struct Assignable
0082 {
0083     void constraints()
0084     {
0085         function_requires<boost::AssignableConcept<T>>();
0086     }
0087 };
0088 
0089 /// \brief Concept of == and != comparability requirement.
0090 /// \code
0091 /// auto concept EqualityComparable<typename T, typename U = T>
0092 /// {
0093 ///     bool operator==(T x, T y);
0094 ///     bool operator!=(T x, T y) { return !(x==y); }
0095 /// };
0096 /// \endcode
0097 /// \ingroup BasicConcepts
0098 ///
0099 template <typename T>
0100 struct EqualityComparable
0101 {
0102     void constraints()
0103     {
0104         function_requires<boost::EqualityComparableConcept<T>>();
0105     }
0106 };
0107 
0108 /// \brief Concept of swap operation requirement.
0109 /// \code
0110 /// auto concept Swappable<typename T>
0111 /// {
0112 ///     void swap(T&,T&);
0113 /// };
0114 /// \endcode
0115 /// \ingroup BasicConcepts
0116 ///
0117 template <typename T>
0118 struct Swappable
0119 {
0120     void constraints()
0121     {
0122         using std::swap;
0123         swap(x,y);
0124     }
0125     T x,y;
0126 };
0127 
0128 /// \brief Concept for type regularity requirement.
0129 /// \code
0130 /// auto concept Regular<typename T>
0131 ///     : DefaultConstructible<T>
0132 ///     , CopyConstructible<T>
0133 ///     , EqualityComparable<T>
0134 ///     , Assignable<T>
0135 ///     , Swappable<T>
0136 /// {};
0137 /// \endcode
0138 /// \ingroup BasicConcepts
0139 ///
0140 template <typename T>
0141 struct Regular
0142 {
0143     void constraints()
0144     {
0145         gil_function_requires< boost::DefaultConstructibleConcept<T>>();
0146         gil_function_requires< boost::CopyConstructibleConcept<T>>();
0147         gil_function_requires< boost::EqualityComparableConcept<T>>(); // ==, !=
0148         gil_function_requires< boost::AssignableConcept<T>>();
0149         gil_function_requires< Swappable<T>>();
0150     }
0151 };
0152 
0153 /// \brief Concept for type as metafunction requirement.
0154 /// \code
0155 /// auto concept Metafunction<typename T>
0156 /// {
0157 ///     typename type;
0158 /// };
0159 /// \endcode
0160 /// \ingroup BasicConcepts
0161 ///
0162 template <typename T>
0163 struct Metafunction
0164 {
0165     void constraints()
0166     {
0167         using type = typename T::type;
0168     }
0169 };
0170 
0171 /// \brief Concept of types equivalence requirement.
0172 /// \code
0173 /// auto concept SameType<typename T, typename U>; // unspecified
0174 /// \endcode
0175 /// \ingroup BasicConcepts
0176 ///
0177 template <typename T, typename U>
0178 struct SameType
0179 {
0180     void constraints()
0181     {
0182         static_assert(std::is_same<T, U>::value, "");
0183     }
0184 };
0185 
0186 }} // namespace boost::gil
0187 
0188 #if defined(BOOST_CLANG)
0189 #pragma clang diagnostic pop
0190 #endif
0191 
0192 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0193 #pragma GCC diagnostic pop
0194 #endif
0195 
0196 #endif