- simd[meta header]
- std::simd[meta namespace]
- function template[meta id-type]
- cpp26[meta cpp]
namespace std::simd {
template<math-floating-point V>
constexpr rebind_t<int, deduced-vec-t<V>>
fpclassify(const V& x); // C++26
}- deduced-vec-t[link /reference/simd/deduced-vec-t.md]
- math-floating-point[link /reference/simd/math-floating-point.md]
- rebind_t[link rebind.md]
浮動小数点要素型のbasic_vecについて、各要素を浮動小数点数の種別に分類する。各要素にstd::fpclassifyを適用する。
制約math-floating-pointは、Vが浮動小数点要素型のbasic_vec、またはそれと組み合わせてbasic_vecを導出できる型であることを表す説明専用のコンセプトである。deduced-vec-t<V>は、引数から導出されるbasic_vec型である。戻り値の型は、要素型をintとした整数のbasic_vecとなる。
各要素i(0以上deduced-vec-t<V>::size()未満)について、x[i]にstd::fpclassifyを適用した結果で初期化されたbasic_vecオブジェクトを返す。各要素の値は、FP_INFINITE・FP_NAN・FP_NORMAL・FP_SUBNORMAL・FP_ZERO、または処理系が定義する分類のいずれかである。
#include <simd>
#include <print>
#include <cmath>
#include <limits>
#include <array>
namespace simd = std::simd;
int main()
{
constexpr float inf = std::numeric_limits<float>::infinity();
constexpr float nan = std::numeric_limits<float>::quiet_NaN();
simd::vec<float, 4> v{
[&](int i) { return std::array{1.0f, 0.0f, inf, nan}[i]; }
}; // {1, 0, inf, nan}
simd::rebind_t<int, simd::vec<float, 4>> r = simd::fpclassify(v);
for (std::size_t i = 0; i < r.size(); ++i)
std::print("{} ", r[i] == FP_NORMAL);
std::println("");
}- simd::fpclassify[color ff0000]
- simd::vec[link basic_vec.md]
- simd::rebind_t[link rebind.md]
- FP_NORMAL[link /reference/cmath/fp_normal.md]
true false false false
- C++26
- Clang: 22 [mark noimpl]
- GCC: 16.1 [mark noimpl]
- Visual C++: 2026 Update 2 [mark noimpl]