ALib C++ Library
Library Version: 2412 R0
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#pragma once
13#if !defined(DOXYGEN)
14# include "alib/alib.hpp"
15#endif
16
18
19#include "alib/boxing/enum.hpp"
20
21// #################################################################################################
22// #################################################################################################
23// #### std::hash, std::equal_to, std::is_less for classes Box and Enum
24// #################################################################################################
25// #################################################################################################
26#if DOXYGEN
28#else
29 namespace std {
30#endif
31
32//==================================================================================================
33/// Specialization of functor <c>std::hash</c> for type \alib{boxing;Box}.
34///
35/// This specialization is provided with the inclusion of header file
36/// \alibheader{compatibility/std_boxing_functional.hpp}.<br>
37/// While the documentation indicates namespace <c>alib::compatibility::std</c>, the
38/// specialization is (as needed) implemented in namespace <c>std</c>.
39//==================================================================================================
40template<> struct hash<alib::boxing::Box>
41{
42 /// Invokes and returns the result of box-function \alib{boxing;FHashcode}.
43 /// @param src The box object to hash.
44 /// @return The hash code.
45 size_t operator()(const alib::boxing::Box& src) const
46 {
47 return src.Hashcode();
48 }
49};
50
51
52//==================================================================================================
53/// Specialization of functor <c>std::equal_to</c> for type \alib{boxing;Box}.
54///
55/// This specialization is provided with the inclusion of header file
56/// \alibheader{compatibility/std_boxing_functional.hpp}.<br>
57/// While the documentation indicates namespace <c>alib::compatibility::std</c>, the
58/// specialization is (as needed) implemented in namespace <c>std</c>.
59//==================================================================================================
60template<> struct equal_to<alib::boxing::Box>
61{
62 /// Invokes \alib{boxing;Box::operator==} passing \p{lhs} and \p{rhs}.
63 /// @param lhs The left-hand side box.
64 /// @param rhs The right-hand side box.
65 /// @return The result of the comparison.
67 const alib::boxing::Box& rhs ) const
68 {
69 return lhs.operator==( rhs );
70 }
71
72};
73
74//==================================================================================================
75/// Specialization of functor <c>std::less</c> for type \alib{boxing;Box}.
76///
77/// For the comparison, box-function \alib{boxing;FIsLess} is invoked on \p{lhs} with passing
78/// \p{rhs}.
79///
80/// This specialization is provided with the inclusion of header file
81/// \alibheader{compatibility/std_boxing_functional.hpp}.<br>
82/// While the documentation indicates namespace <c>alib::compatibility::std</c>, the
83/// specialization is (as needed) implemented in namespace <c>std</c>.
84//==================================================================================================
85template<> struct less<alib::boxing::Box>
86{
87 /// Invokes box-function \alib{boxing;FIsLess} on \p{lhs} and returns the result.
88 /// @param lhs The left-hand side box.
89 /// @param rhs The right-hand side box.
90 /// @return The result of the comparison.
92 const alib::boxing::Box& rhs) const
93 {
94 return lhs.operator<( rhs );
95 }
96
97};
98
99//==================================================================================================
100/// Specialization of functor <c>std::hash</c> for type \alib{boxing;Enum}.
101///
102/// This specialization is provided with the inclusion of header file
103/// \alibheader{compatibility/std_boxing_functional.hpp}.<br>
104/// While the documentation indicates namespace <c>alib::compatibility::std</c>, the
105/// specialization is (as needed) implemented in namespace <c>std</c>.
106//==================================================================================================
107template<> struct hash<alib::boxing::Enum>
108{
109 /// Calculates the hash code for class \b Enum.
110 /// @param src The \b %Enum object to hash.
111 /// @return The hash code.
112 size_t operator()(const alib::boxing::Enum& src) const
113 {
114 return src.Hashcode();
115 }
116};
117
118//==================================================================================================
119/// Specialization of functor <c>std::equal_to</c> for type \alib{boxing;Enum}.
120///
121/// This specialization is provided with the inclusion of header file
122/// \alibheader{compatibility/std_boxing_functional.hpp}.<br>
123/// While the documentation indicates namespace <c>alib::compatibility::std</c>, the
124/// specialization is (as needed) implemented in namespace <c>std</c>.
125//==================================================================================================
126template<> struct equal_to<alib::boxing::Enum>
127{
128 /// Invokes \alib{boxing;Enum::operator==} on \p{lhs} and \p{rhs}.
129 /// @param lhs The left-hand side \b %Enum.
130 /// @param rhs The right-hand side \b %Enum.
131 /// @return The result of the comparison.
133 const alib::boxing::Enum rhs) const
134 {
135 return lhs == rhs;
136 }
137};
138
139//==================================================================================================
140/// Specialization of functor <c>std::less</c> for type \alib{boxing;Enum}.
141///
142/// This specialization is provided with the inclusion of header file
143/// \alibheader{compatibility/std_boxing_functional.hpp}.<br>
144/// While the documentation indicates namespace <c>alib::compatibility::std</c>, the
145/// specialization is (as needed) implemented in namespace <c>std</c>.
146//==================================================================================================
147template<> struct less<alib::boxing::Enum>
148{
149 /// Invokes box-function \alib{boxing;FIsLess} on \p{lhs} and returns the result.
150 /// @param lhs The left-hand side \b Enum.
151 /// @param rhs The right-hand side \b Enum.
152 /// @return The result of the comparison.
154 const alib::boxing::Enum& rhs) const
155 {
156 return lhs < rhs;
157 }
158
159};
160
161
162} // namespace [std]
163
164
165#endif // HPP_ALIB_COMPATIBILITY_STD_BOXING_FUNCTIONAL
166
ALIB_API size_t Hashcode() const
Definition boxing.cpp:163
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
Definition alib.cpp:69
ALIB_API size_t Hashcode() const
Definition boxing.cpp:163
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