@@ -159,6 +159,8 @@ namespace xsimd
159159
160160 XSIMD_INLINE T get (std::size_t i) const noexcept ;
161161
162+ XSIMD_INLINE T first () const noexcept ;
163+
162164 // comparison operators. Defined as friend to enable automatic
163165 // conversion of parameters from scalar to batch, at the cost of using a
164166 // proxy implementation from details::.
@@ -314,6 +316,8 @@ namespace xsimd
314316
315317 XSIMD_INLINE bool get (std::size_t i) const noexcept ;
316318
319+ XSIMD_INLINE bool first () const noexcept ;
320+
317321 // mask operations
318322 XSIMD_INLINE uint64_t mask () const noexcept ;
319323 XSIMD_INLINE static batch_bool from_mask (uint64_t mask) noexcept ;
@@ -405,6 +409,8 @@ namespace xsimd
405409
406410 XSIMD_INLINE value_type get (std::size_t i) const noexcept ;
407411
412+ XSIMD_INLINE value_type first () const noexcept ;
413+
408414#ifdef XSIMD_ENABLE_XTL_COMPLEX
409415 // xtl-related methods
410416 template <bool i3ec>
@@ -693,6 +699,16 @@ namespace xsimd
693699 return kernel::get (*this , i, A {});
694700 }
695701
702+ /* *
703+ * Retrieve the first scalar element in this batch.
704+ */
705+ template <class T , class A >
706+ XSIMD_INLINE T batch<T, A>::first() const noexcept
707+ {
708+ detail::static_check_supported_config<T, A>();
709+ return kernel::first (*this , A {});
710+ }
711+
696712 /* *****************************
697713 * batch comparison operators *
698714 ******************************/
@@ -1005,6 +1021,13 @@ namespace xsimd
10051021 return kernel::get (*this , i, A {});
10061022 }
10071023
1024+ template <class T , class A >
1025+ XSIMD_INLINE bool batch_bool<T, A>::first() const noexcept
1026+ {
1027+ detail::static_check_supported_config<T, A>();
1028+ return kernel::first (*this , A {});
1029+ }
1030+
10081031 /* **********************************
10091032 * batch_bool comparison operators *
10101033 ***********************************/
@@ -1248,6 +1271,13 @@ namespace xsimd
12481271 return kernel::get (*this , i, A {});
12491272 }
12501273
1274+ template <class T , class A >
1275+ XSIMD_INLINE auto batch<std::complex <T>, A>::first() const noexcept -> value_type
1276+ {
1277+ detail::static_check_supported_config<std::complex <T>, A>();
1278+ return kernel::first (*this , A {});
1279+ }
1280+
12511281 /* *************************************
12521282 * batch<complex> xtl-related methods *
12531283 **************************************/
0 commit comments