@@ -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 ***********************************/
@@ -1077,6 +1100,7 @@ namespace xsimd
10771100 {
10781101 }
10791102
1103+
10801104 template <class T , class A >
10811105 template <class U , class ... V, size_t I, size_t ... Is>
10821106 XSIMD_INLINE auto batch_bool<T, A>::make_register(detail::index_sequence<I, Is...>, U u, V... v) noexcept -> register_type
@@ -1248,6 +1272,13 @@ namespace xsimd
12481272 return kernel::get (*this , i, A {});
12491273 }
12501274
1275+ template <class T , class A >
1276+ XSIMD_INLINE auto batch<std::complex <T>, A>::first() const noexcept -> value_type
1277+ {
1278+ detail::static_check_supported_config<std::complex <T>, A>();
1279+ return kernel::first (*this , A {});
1280+ }
1281+
12511282 /* *************************************
12521283 * batch<complex> xtl-related methods *
12531284 **************************************/
0 commit comments