Blaze 3.9
Bind2nd.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_FUNCTORS_BIND2ND_H_
36#define _BLAZE_MATH_FUNCTORS_BIND2ND_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/math/simd/Set.h>
48#include <blaze/system/Inline.h>
49
50
51namespace blaze {
52
53//=================================================================================================
54//
55// CLASS DEFINITION
56//
57//=================================================================================================
58
59//*************************************************************************************************
63template< typename OP // Type of the operation
64 , typename A2 > // Type of the bound argument
65struct Bind2nd
66{
67 public:
68 //**********************************************************************************************
74 constexpr Bind2nd( const OP& op, const A2& a2 )
75 : op_( op ) // The wrapped operation.
76 , a2_( a2 ) // The 2nd argument
77 {}
78 //**********************************************************************************************
79
80 //**********************************************************************************************
87 template< typename A1, typename... Args >
88 BLAZE_ALWAYS_INLINE constexpr decltype(auto) operator()( A1&& a1, Args&&... args ) const
89 {
90 return op_( std::forward<A1>( a1 ), a2_, std::forward<Args>( args )... );
91 }
92 //**********************************************************************************************
93
94 //**********************************************************************************************
99 template< typename A1, typename... Args >
100 static constexpr bool simdEnabled() { return IsSIMDEnabled_v<OP,A1,A2,Args...>; }
101 //**********************************************************************************************
102
103 //**********************************************************************************************
108 static constexpr bool paddingEnabled() { return false; }
109 //**********************************************************************************************
110
111 //**********************************************************************************************
118 template< typename A1, typename... Args >
119 BLAZE_ALWAYS_INLINE decltype(auto) load( A1&& a1, Args&&... args ) const
120 {
121 return op_.load( std::forward<A1>( a1 ), set( a2_ ), std::forward<Args>( args )... );
122 }
123 //**********************************************************************************************
124
125 private:
126 //**Member variables****************************************************************************
127 OP op_;
128 A2 a2_;
129 //**********************************************************************************************
130};
131//*************************************************************************************************
132
133
134
135
136//=================================================================================================
137//
138// GLOBAL FUNCTIONS
139//
140//=================================================================================================
141
142//*************************************************************************************************
153template< typename OP // Type of the operation
154 , typename A2 > // Type of the bound argument
155constexpr Bind2nd<OP,A2> bind2nd( const OP& op, const A2& a2 )
156{
157 return Bind2nd<OP,A2>( op, a2 );
158}
159//*************************************************************************************************
160
161
162
163
164//=================================================================================================
165//
166// YIELDSUNIFORM SPECIALIZATIONS
167//
168//=================================================================================================
169
170//*************************************************************************************************
172template< typename OP, typename A2, typename T >
173struct YieldsUniform<Bind2nd<OP,A2>,T>
174 : public YieldsUniform<OP,T>
175{};
177//*************************************************************************************************
178
179
180
181
182//=================================================================================================
183//
184// YIELDSSYMMETRIC SPECIALIZATIONS
185//
186//=================================================================================================
187
188//*************************************************************************************************
190template< typename OP, typename A2, typename MT >
191struct YieldsSymmetric<Bind2nd<OP,A2>,MT>
192 : public YieldsSymmetric<OP,MT>
193{};
195//*************************************************************************************************
196
197} // namespace blaze
198
199#endif
Header file for the IsSIMDEnabled type trait.
Header file for the SIMD set functionality.
Header file for the YieldsSymmetric type trait.
Header file for the YieldsUniform type trait.
constexpr Bind2nd< OP, A2 > bind2nd(const OP &op, const A2 &a2)
Binds the given object/value to the 2nd parameter of the given operation.
Definition: Bind2nd.h:155
constexpr bool IsSIMDEnabled_v
Auxiliary variable template for the IsSIMDEnabled type trait.
Definition: IsSIMDEnabled.h:129
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Generic wrapper for an operation with fixed 2nd argument.
Definition: Bind2nd.h:66
A2 a2_
The 2nd argument.
Definition: Bind2nd.h:128
static constexpr bool paddingEnabled()
Returns whether the operation supports padding, i.e. whether it can deal with zeros.
Definition: Bind2nd.h:108
static constexpr bool simdEnabled()
Returns whether SIMD is enabled for the specified data types Ts.
Definition: Bind2nd.h:100
BLAZE_ALWAYS_INLINE decltype(auto) load(A1 &&a1, Args &&... args) const
Returns the result of the wrapped operation for the given SIMD vectors.
Definition: Bind2nd.h:119
OP op_
The wrapped operation.
Definition: Bind2nd.h:127
constexpr Bind2nd(const OP &op, const A2 &a2)
Constructor of the Bind2nd functor.
Definition: Bind2nd.h:74
System settings for the inline keywords.