ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
std_boxing_functional.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of the \aliblong.<br>
4 * With the inclusion of this header compatibility features between \alib and the C++ standard
5 * library are provided.
6 *
7 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
8 * Published under \ref mainpage_license "Boost Software License".
9 **************************************************************************************************/
10#ifndef HPP_ALIB_COMPATIBILITY_STD_BOXING_FUNCTIONAL
11#define HPP_ALIB_COMPATIBILITY_STD_BOXING_FUNCTIONAL 1
12
13#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
14# include "alib/alib.hpp"
15#endif
16
18
19#if !defined(HPP_ALIB_BOXING_ENUM)
20# include "alib/boxing/enum.hpp"
21#endif
22
23
24// #################################################################################################
25// #################################################################################################
26// #### std::hash, std::equal_to, std::is_less for classes Box and Enum
27// #################################################################################################
28// #################################################################################################
29#if defined(ALIB_DOX)
30 namespace alib { namespace boxing { namespace compatibility { namespace std {
31#else
32 namespace std {
33#endif
34
35/** ************************************************************************************************
36 * Specialization of functor <c>std::hash</c> for type \alib{boxing;Box}.
37 *
38 * This specialization is provided with the inclusion of header file
39 * \alibheader{compatibility/std_boxing_functional.hpp}.<br>
40 * While the documentation indicates namespace <c>alib::compatibility::std</c>, the
41 * specialization is (as needed) implemented in namespace <c>std</c>.
42 **************************************************************************************************/
43template<> struct hash<alib::boxing::Box>
44{
45 /**
46 * Invokes and returns the result of box-function \alib{boxing;FHashcode}.
47 * @param src The box object to hash.
48 * @return The hash code.
49 */
50 size_t operator()(const alib::boxing::Box& src) const
51 {
52 return src.Hashcode();
53 }
54};
55
56
57/** ************************************************************************************************
58 * Specialization of functor <c>std::equal_to</c> for type \alib{boxing;Box}.
59 *
60 * This specialization is provided with the inclusion of header file
61 * \alibheader{compatibility/std_boxing_functional.hpp}.<br>
62 * While the documentation indicates namespace <c>alib::compatibility::std</c>, the
63 * specialization is (as needed) implemented in namespace <c>std</c>.
64 **************************************************************************************************/
65template<> struct equal_to<alib::boxing::Box>
66{
67 /**
68 * Invokes \alib{boxing;Box::operator==} passing \p{lhs} and \p{rhs}.
69 * @param lhs The left-hand side box.
70 * @param rhs The right-hand side box.
71 * @return The result of the comparison.
72 */
74 const alib::boxing::Box& rhs ) const
75 {
76 return lhs.operator==( rhs );
77 }
78
79};
80
81/** ************************************************************************************************
82 * Specialization of functor <c>std::less</c> for type \alib{boxing;Box}.
83 *
84 * For the comparison, box-function \alib{boxing;FIsLess} is invoked on \p{lhs} with passing
85 * \p{rhs}.
86 *
87 * This specialization is provided with the inclusion of header file
88 * \alibheader{compatibility/std_boxing_functional.hpp}.<br>
89 * While the documentation indicates namespace <c>alib::compatibility::std</c>, the
90 * specialization is (as needed) implemented in namespace <c>std</c>.
91 **************************************************************************************************/
92template<> struct less<alib::boxing::Box>
93{
94 /**
95 * Invokes box-function \alib{boxing;FIsLess} on \p{lhs} and returns the result.
96 * @param lhs The left-hand side box.
97 * @param rhs The right-hand side box.
98 * @return The result of the comparison.
99 */
101 const alib::boxing::Box& rhs) const
102 {
103 return lhs.operator<( rhs );
104 }
105
106};
107
108/** ************************************************************************************************
109 * Specialization of functor <c>std::hash</c> for type \alib{boxing;Enum}.
110 *
111 * This specialization is provided with the inclusion of header file
112 * \alibheader{compatibility/std_boxing_functional.hpp}.<br>
113 * While the documentation indicates namespace <c>alib::compatibility::std</c>, the
114 * specialization is (as needed) implemented in namespace <c>std</c>.
115 **************************************************************************************************/
116template<> struct hash<alib::boxing::Enum>
117{
118 /**
119 * Calculates the hash code for class \b Enum.
120 * @param src The \b %Enum object to hash.
121 * @return The hash code.
122 */
123 size_t operator()(const alib::boxing::Enum& src) const
124 {
125 return src.Hashcode();
126 }
127};
128
129/** ************************************************************************************************
130 * Specialization of functor <c>std::equal_to</c> for type \alib{boxing;Enum}.
131 *
132 * This specialization is provided with the inclusion of header file
133 * \alibheader{compatibility/std_boxing_functional.hpp}.<br>
134 * While the documentation indicates namespace <c>alib::compatibility::std</c>, the
135 * specialization is (as needed) implemented in namespace <c>std</c>.
136 **************************************************************************************************/
137template<> struct equal_to<alib::boxing::Enum>
138{
139 /**
140 * Invokes \alib{boxing;Enum::operator==} on \p{lhs} and \p{rhs}.
141 * @param lhs The left-hand side \b %Enum.
142 * @param rhs The right-hand side \b %Enum.
143 * @return The result of the comparison.
144 */
146 const alib::boxing::Enum rhs) const
147 {
148 return lhs == rhs;
149 }
150};
151
152/** ************************************************************************************************
153 * Specialization of functor <c>std::less</c> for type \alib{boxing;Enum}.
154 *
155 * This specialization is provided with the inclusion of header file
156 * \alibheader{compatibility/std_boxing_functional.hpp}.<br>
157 * While the documentation indicates namespace <c>alib::compatibility::std</c>, the
158 * specialization is (as needed) implemented in namespace <c>std</c>.
159 **************************************************************************************************/
160template<> struct less<alib::boxing::Enum>
161{
162 /**
163 * Invokes box-function \alib{boxing;FIsLess} on \p{lhs} and returns the result.
164 * @param lhs The left-hand side \b Enum.
165 * @param rhs The right-hand side \b Enum.
166 * @return The result of the comparison.
167 */
169 const alib::boxing::Enum& rhs) const
170 {
171 return lhs < rhs;
172 }
173
174};
175
176
177#if defined(ALIB_DOX)
178}}}} // namespace [alib::boxing::compatibility::std]
179#else
180} // namespace [std]
181#endif
182
183
184#endif // HPP_ALIB_COMPATIBILITY_STD_BOXING_FUNCTIONAL
ALIB_API size_t Hashcode() const
Definition boxing.cpp:195
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:190
Definition alib.cpp:57
ALIB_API size_t Hashcode() const
Definition boxing.cpp:195
bool operator()(const alib::boxing::Box &lhs, const alib::boxing::Box &rhs) const
bool operator()(const alib::boxing::Enum lhs, const alib::boxing::Enum rhs) const
bool operator()(const alib::boxing::Box &lhs, const alib::boxing::Box &rhs) const
bool operator()(const alib::boxing::Enum &lhs, const alib::boxing::Enum &rhs) const