- simd[meta header]
- std::simd[meta namespace]
- function template[meta id-type]
- cpp26[meta cpp]
namespace std::simd {
template<math-floating-point V>
constexpr deduced-vec-t<V> exp2(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]
浮動小数点数型を要素とするbasic_vecについて、各要素の2を底とする指数関数(2をx乗した値)を求める。各要素に<cmath>のexp2を要素ごとに適用したものである。
制約math-floating-pointは、Vが浮動小数点数型を要素とするbasic_vecであることを表す説明専用のコンセプトである。deduced-vec-t<V>はVから導出されるbasic_vec型(通常はV自身)を表す。
各要素i(0以上V::size()未満)について、x[i]に<cmath>のexp2を適用した結果に要素ごとに等しいbasic_vecオブジェクトを返す。
ある要素iについて定義域エラー・極エラー・値域エラーが発生する場合、その要素の値は未規定である。
errnoにアクセスするか否かは未規定である。
#include <simd>
#include <print>
namespace simd = std::simd;
int main()
{
simd::vec<float, 4> v([](int i) { return float(i + 1); }); // {1, 2, 3, 4}
// 各要素の2の指数関数を求める
simd::vec<float, 4> r = simd::exp2(v);
for (std::size_t i = 0; i < r.size(); ++i)
std::print("{} ", r[i]);
std::println("");
}- simd::exp2[color ff0000]
2 4 8 16
- C++26
- Clang: 22 [mark noimpl]
- GCC: 16.1 [mark noimpl]
- Visual C++: 2026 Update 2 [mark noimpl]