This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Tentatively NAD status.
simd::basic_vec constructorSection: 29.10.7.2 [simd.ctor] Status: Tentatively NAD Submitter: Hewill Kang Opened: 2025-09-29 Last modified: 2025-10-17
Priority: Not Prioritized
View other active issues in [simd.ctor].
View all other issues in [simd.ctor].
View all issues with Tentatively NAD status.
Discussion:
The broadcasting, generator-based, and range constructors of simd::basic_vec all take a single
argument, and their constraints are not mutually exclusive.
value_type, this will lead to ambiguity:
#include <simd>
struct S {
operator double() const; // basic_vec(U&& value)
double operator()(int) const; // basic_vec(G&& gen)
double* begin() const; // basic_vec(R&& r, flags<Flags...> = {});
double* end() const;
constexpr static int size() { return 2; }
};
int main() {
std::simd::vec<double> simd(S{}); // error: call of overloaded 'basic_simd(S)' is ambiguous
}
Do we need more constraints, similar to the one in string_view(R&& r) that requires
R not to be convertible to const char*, to make the above work, i.e., only invoke the
broadcasting constructor?
[2025-10-17; Reflector poll. Status changed: New → Tentatively NAD.]
Users of such types should do disambiguation explicitly, basic_vec should not guess what they mean.
Proposed resolution:
This wording is relative to N5014.
Modify 29.10.7.2 [simd.ctor] as indicated:
template<class G> constexpr explicit basic_vec(G&& gen);[…]-8- Let
-9- Constraints:Fromidenote the typedecltype(gen(integral_constant<simd-size-type, i>())).
(9.?) —
constructible_from<value_type, G>isfalse.(9.?) —
Fromisatisfiesconvertible_to<value_type>for alliin the range of [0, size()). In addition, for all i in the range of [0, size()), ifFromiis an arithmetic type, conversion fromFromitovalue_typeis value-preserving.template<class R, class... Flags> constexpr basic_vec(R&& r, flags<Flags...> = {}); template<class R, class... Flags> constexpr basic_vec(R&& r, const mask_type& mask, flags<Flags...> = {});-12- Let mask be
-13- Constraints:mask_type(true)for the overload with nomaskparameter.
(13.1) —
Rmodelsranges::contiguous_rangeandranges::sized_range,(13.2) —
ranges::size(r)is a constant expression,and(13.3) —
ranges::size(r)is equal tosize().,(13.?) —
constructible_from<value_type, R>isfalse, and(13.?) —
r(integral_constant<simd-size-type, 0>())is not a valid expression.