This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4386. std::simd::select(bool c, const T& a, const U& b) is underconstrained

Section: 29.10.8.13 [simd.alg] Status: New Submitter: Hewill Kang Opened: 2025-09-27 Last modified: 2025-09-27

Priority: Not Prioritized

View all issues with New status.

Discussion:

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.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 29.10.3 [simd.syn] as indicated:

    namespace std::simd {
      […]
      // 29.10.8.13 [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 29.10.8.13 [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;