Title
std::simd::select(bool c, const T& a, const U& b) is underconstrained
Status
new
Section
[simd.alg]
Submitter
Hewill Kang

Created on 2025-09-27.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-09-27.09:47:57

Proposed resolution:

This wording is relative to N5014.

  1. Modify [simd.syn] as indicated:

    namespace std::simd {
      […]
      // [simd.alg], algorithms
      […]
      template<copyableclass T, copyableclass U>
        constexpr auto select(bool c, const T& a, const U& b)
        -> remove_cvref_t<decltype(c ? a : b)>;
      […]
    };
    
  2. Modify [simd.alg] as indicated:

    template<copyableclass T, copyableclass U>
      constexpr auto select(bool c, const T& a, const U& b)
        -> remove_cvref_t<decltype(c ? a : b)>;
    

    -9- Effects: Equivalent to: return c ? a : b;

Date: 2025-09-27.00:00:00

This function currently only requires that `c ? a : b` be a well-formed expression, which simply returns `c ? a : b`.

Given that it seems intended to work with `basic_vec`, `basic_mask`, or vectorizable type, requiring `T` and `U` to be copyable seems reasonable since they are trivially copyable. It shouldn't take non-copyable objects and produce hard errors in the function body.

History
Date User Action Args
2025-09-27 09:47:57adminsetmessages: + msg15090
2025-09-27 00:00:00admincreate