Blaze 3.9
Min.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_UTIL_ALGORITHMS_MIN_H_
36#define _BLAZE_UTIL_ALGORITHMS_MIN_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/util/EnableIf.h>
45#include <blaze/util/mpl/If.h>
52
53
54namespace blaze {
55
56//=================================================================================================
57//
58// MIN ALGORITHMS
59//
60//=================================================================================================
61
62//*************************************************************************************************
73template< typename T1, typename T2
74 , typename R1 = RemoveCVRef_t<T1>
75 , typename R2 = RemoveCVRef_t<T2>
76 , EnableIf_t< HasLessThan_v<R2,R1> &&
77 !( IsSigned_v<R1> && IsUnsigned_v<R2> ) &&
78 !( IsUnsigned_v<R1> && IsSigned_v<R2> ) >* = nullptr >
79constexpr decltype(auto) min( T1&& a, T2&& b )
80{
81 using Result = decltype( b < a ? std::forward<T2>( b ) : std::forward<T1>( a ) );
83
84 return static_cast<Return>( b < a ? std::forward<T2>( b ) : std::forward<T1>( a ) );
85}
86//*************************************************************************************************
87
88
89//*************************************************************************************************
101template< typename T1, typename T2, typename T3 >
102constexpr decltype(auto) min( T1&& a, T2&& b, T3&& c )
103{
104 using std::forward;
105 using blaze::min;
106
107 return min( min( forward<T1>( a ), forward<T2>( b ) ), forward<T3>( c ) );
108}
109//*************************************************************************************************
110
111
112//*************************************************************************************************
125template< typename T1, typename T2, typename T3, typename... Ts >
126constexpr decltype(auto) min( T1&& a, T2&& b, T3&& c, Ts&&... args )
127{
128 using std::forward;
129 using blaze::min;
130
131 return min( min( min( forward<T1>( a ), forward<T2>( b ) ), forward<T3>( c ) ), forward<Ts>( args )... );
132}
133//*************************************************************************************************
134
135} // namespace blaze
136
137#endif
Header file for the EnableIf class template.
Header file for the HasLessThan type trait.
Header file for the If class template.
Header file for the IsSigned type trait.
Header file for the IsUnsigned type trait.
Header file for the RemoveCVRef type trait.
Header file for the RemoveConst type trait.
Header file for the RemoveRValueReference type trait.
constexpr decltype(auto) min(T1 &&a, T2 &&b, T3 &&c, Ts &&... args)
Minimum function for at least four values/objects.
Definition: Min.h:126
typename RemoveConst< T >::Type RemoveConst_t
Auxiliary alias declaration for the RemoveConst type trait.
Definition: RemoveConst.h:96