Blaze 3.9
Loading...
Searching...
No Matches
Minmax.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_UTIL_ALGORITHMS_MINMAX_H_
36#define _BLAZE_UTIL_ALGORITHMS_MINMAX_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/util/EnableIf.h>
45#include <blaze/util/mpl/If.h>
53
54
55namespace blaze {
56
57//=================================================================================================
58//
59// MINMAX ALGORITHMS
60//
61//=================================================================================================
62
63//*************************************************************************************************
75template< typename T1, typename T2
76 , typename R1 = RemoveCVRef_t<T1>
77 , typename R2 = RemoveCVRef_t<T2>
80 !( IsUnsigned_v<T1> && IsSigned_v<T2> ) >* = nullptr >
81constexpr decltype(auto) minmax( T1&& a, T2&& b )
82{
83 using RT =
85 , const R1&
87
88 if( b < a )
89 return std::pair<RT,RT>( std::forward<T2>( b ), std::forward<T1>( a ) );
90 else
91 return std::pair<RT,RT>( std::forward<T1>( a ), std::forward<T2>( b ) );
92}
93//*************************************************************************************************
94
95} // namespace blaze
96
97#endif
Header file for the CommonType type trait.
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 IsReference type trait.
Header file for the IsSame and IsStrictlySame type traits.
Header file for the IsSigned type trait.
Header file for the IsUnsigned type trait.
Header file for the RemoveCVRef type trait.
constexpr decltype(auto) minmax(T1 &&a, T2 &&b)
Minmax function for two values/objects.
Definition Minmax.h:81
constexpr bool IsSigned_v
Auxiliary variable template for the IsSigned type trait.
Definition IsSigned.h:97
constexpr bool IsSame_v
Auxiliary variable template for the IsSame type trait.
Definition IsSame.h:159
typename RemoveCVRef< T >::Type RemoveCVRef_t
Auxiliary alias declaration for the RemoveCVRef type trait.
Definition RemoveCVRef.h:99
constexpr bool IsUnsigned_v
Auxiliary variable template for the IsUnsigned type trait.
Definition IsUnsigned.h:97
constexpr bool IsReference_v
Auxiliary variable template for the IsReference type trait.
Definition IsReference.h:95
typename CommonType< T... >::Type CommonType_t
Auxiliary alias declaration for the CommonType type trait.
Definition CommonType.h:95
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108