Repository: numpy/numpy
File: numpy/_core/src/common/simd/simd.inc.hpp (C++)

Code before:
#endif

// NOTE: This file is included by simd.hpp multiple times with different namespaces
// so avoid including any headers here

/**
 * Determines whether the specified lane type is supported by the SIMD extension.
 * Always defined as false when SIMD is not enabled, so it can be used in SFINAE.
 *
 * @tparam TLane The lane type to check for support.
 */
template <typename TLane>
constexpr bool kSupportLane = NPY_SIMDX != 0;

#if NPY_SIMDX
// Define lane type support based on Highway capabilities
template <>
constexpr bool kSupportLane<hwy::float16_t> = HWY_HAVE_FLOAT16 != 0;
template <>
constexpr bool kSupportLane<double> = HWY_HAVE_FLOAT64 != 0;
template <>
constexpr bool kSupportLane<long double> =
        HWY_HAVE_FLOAT64 != 0 && sizeof(long double) == sizeof(double);

/// Maximum number of lanes supported by the SIMD extension for the specified lane type.
template <typename TLane>
constexpr size_t kMaxLanes = HWY_MAX_LANES_D(_Tag<TLane>);

/// Represents an N-lane vector based on the specified lane type.
/// @tparam TLane The scalar type for each vector lane
template <typename TLane>
using Vec = hn::Vec<_Tag<TLane>>;

/// Represents a mask vector with boolean values or as a bitmask.
/// @tparam TLane The scalar type the mask corresponds to
template <typename TLane>
using Mask = hn::Mask<_Tag<TLane>>;

/// Unaligned load of a vector from memory.
template <typename TLane>
HWY_API Vec<TLane>
LoadU(const TLane *ptr)
{
    return hn::LoadU(_Tag<TLane>(), ptr);
}

/// Unaligned store of a vector to memory.
template <typename TLane>
HWY_API void
StoreU(const Vec<TLane> &a, TLane *ptr)
{

Review comment (suggestion):
```suggestion
constexpr inline bool kSupportLane = NPY_SIMDX != 0;

#if NPY_SIMDX
// Define lane type support based on Highway capabilities
template <>
constexpr inline bool kSupportLane<hwy::float16_t> = HWY_HAVE_FLOAT16 != 0;
template <>
constexpr inline bool kSupportLane<double> = HWY_HAVE_FLOAT64 != 0;
template <>
constexpr inline bool kSupportLane<long double> =
```

Code after:
#endif

// Using anonymous namespace instead of inline to ensure each translation unit
// gets its own copy of constants based on local compilation flags
namespace {

// NOTE: This file is included by simd.hpp multiple times with different namespaces
// so avoid including any headers here

/**
 * Determines whether the specified lane type is supported by the SIMD extension.
 * Always defined as false when SIMD is not enabled, so it can be used in SFINAE.
 *
 * @tparam TLane The lane type to check for support.
 */
template <typename TLane>
constexpr bool kSupportLane = NPY_HWY != 0;

#if NPY_HWY
// Define lane type support based on Highway capabilities
template <>
constexpr bool kSupportLane<hwy::float16_t> = HWY_HAVE_FLOAT16 != 0;
template <>
constexpr bool kSupportLane<double> = HWY_HAVE_FLOAT64 != 0;
template <>
constexpr bool kSupportLane<long double> =
        HWY_HAVE_FLOAT64 != 0 && sizeof(long double) == sizeof(double);

/// Maximum number of lanes supported by the SIMD extension for the specified lane type.
template <typename TLane>
constexpr size_t kMaxLanes = HWY_MAX_LANES_D(_Tag<TLane>);

/// Represents an N-lane vector based on the specified lane type.
/// @tparam TLane The scalar type for each vector lane
template <typename TLane>
using Vec = hn::Vec<_Tag<TLane>>;

/// Represents a mask vector with boolean values or as a bitmask.
/// @tparam TLane The scalar type the mask corresponds to
template <typename TLane>
using Mask = hn::Mask<_Tag<TLane>>;

/// Unaligned load of a vector from memory.
template <typename TLane>
HWY_API Vec<TLane>
LoadU(const TLane *ptr)
{
    return hn::LoadU(_Tag<TLane>(), ptr);
}

/// Unaligned store of a vector to memory.