Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
util
algorithms
Max.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_UTIL_ALGORITHMS_MAX_H_
36
#define _BLAZE_UTIL_ALGORITHMS_MAX_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <utility>
44
#include <
blaze/util/EnableIf.h
>
45
#include <
blaze/util/mpl/If.h
>
46
#include <
blaze/util/typetraits/HasLessThan.h
>
47
#include <
blaze/util/typetraits/IsSigned.h
>
48
#include <
blaze/util/typetraits/IsUnsigned.h
>
49
#include <
blaze/util/typetraits/RemoveConst.h
>
50
#include <
blaze/util/typetraits/RemoveCVRef.h
>
51
#include <
blaze/util/typetraits/RemoveRValueReference.h
>
52
53
54
namespace
blaze {
55
56
//=================================================================================================
57
//
58
// MAX ALGORITHMS
59
//
60
//=================================================================================================
61
62
//*************************************************************************************************
73
template
<
typename
T1,
typename
T2
74
,
typename
R1 =
RemoveCVRef_t<T1>
75
,
typename
R2 =
RemoveCVRef_t<T2>
76
,
EnableIf_t< HasLessThan_v<R1,R2>
&&
77
!(
IsSigned_v<R1>
&&
IsUnsigned_v<R2>
) &&
78
!(
IsUnsigned_v<R1>
&&
IsSigned_v<R2>
) >* =
nullptr
>
79
constexpr
decltype
(
auto
)
max
( T1&& a, T2&& b )
80
{
81
using
Result =
decltype
( a < b ? std::forward<T2>( b ) : std::forward<T1>( a ) );
82
using
Return =
RemoveConst_t< RemoveRValueReference_t< Result >
>;
83
84
return
static_cast<
Return
>
( a < b ? std::forward<T2>( b ) : std::forward<T1>( a ) );
85
}
86
//*************************************************************************************************
87
88
89
//*************************************************************************************************
101
template
<
typename
T1,
typename
T2,
typename
T3 >
102
constexpr
decltype
(
auto
)
max
( T1&& a, T2&& b, T3&& c )
103
{
104
using
std::forward;
105
using
blaze::max
;
106
107
return
max
(
max
( forward<T1>( a ), forward<T2>( b ) ), forward<T3>( c ) );
108
}
109
//*************************************************************************************************
110
111
112
//*************************************************************************************************
125
template
<
typename
T1,
typename
T2,
typename
T3,
typename
... Ts >
126
constexpr
decltype
(
auto
)
max
( T1&& a, T2&& b, T3&& c, Ts&&... args )
127
{
128
using
std::forward;
129
using
blaze::max
;
130
131
return
max
(
max
(
max
( forward<T1>( a ), forward<T2>( b ) ), forward<T3>( c ) ), forward<Ts>( args )... );
132
}
133
//*************************************************************************************************
134
135
}
// namespace blaze
136
137
#endif
EnableIf.h
Header file for the EnableIf class template.
HasLessThan.h
Header file for the HasLessThan type trait.
If.h
Header file for the If class template.
IsSigned.h
Header file for the IsSigned type trait.
IsUnsigned.h
Header file for the IsUnsigned type trait.
RemoveCVRef.h
Header file for the RemoveCVRef type trait.
RemoveConst.h
Header file for the RemoveConst type trait.
RemoveRValueReference.h
Header file for the RemoveRValueReference type trait.
blaze::max
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition
DMatDMatMapExpr.h:1375
blaze::IsSigned_v
constexpr bool IsSigned_v
Auxiliary variable template for the IsSigned type trait.
Definition
IsSigned.h:97
blaze::RemoveCVRef_t
typename RemoveCVRef< T >::Type RemoveCVRef_t
Auxiliary alias declaration for the RemoveCVRef type trait.
Definition
RemoveCVRef.h:99
blaze::IsUnsigned_v
constexpr bool IsUnsigned_v
Auxiliary variable template for the IsUnsigned type trait.
Definition
IsUnsigned.h:97
blaze::RemoveConst_t
typename RemoveConst< T >::Type RemoveConst_t
Auxiliary alias declaration for the RemoveConst type trait.
Definition
RemoveConst.h:96
blaze::EnableIf_t
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition
EnableIf.h:138
Generated by
1.18.0