Skip to content

Commit ac2b4e9

Browse files
committed
Document std::common_type_t<bfloat16,...>
1 parent 4da9833 commit ac2b4e9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

sycl/doc/syclcompat/README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,31 @@ signed otherwise.
17281728
Various maths functions are defined operate on any floating point types.
17291729
`syclcompat::is_floating_point_v` extends the standard library's
17301730
`std::is_floating_point_v` to include `sycl::half` and, where available,
1731-
`sycl::ext::oneapi::bfloat16`.
1731+
`sycl::ext::oneapi::bfloat16`. The current version of SYCLcompat also provides
1732+
a specialization of `std::common_type_t` for `sycl::ext::oneapi::bfloat16`,
1733+
though this will be moved to the `sycl_ext_oneapi_bfloat16` extension in
1734+
future.
1735+
1736+
```cpp
1737+
namespace std {
1738+
template <> struct common_type<sycl::ext::oneapi::bfloat16> {
1739+
using type = sycl::ext::oneapi::bfloat16;
1740+
};
1741+
1742+
template <>
1743+
struct common_type<sycl::ext::oneapi::bfloat16, sycl::ext::oneapi::bfloat16> {
1744+
using type = sycl::ext::oneapi::bfloat16;
1745+
};
1746+
1747+
template <typename T> struct common_type<sycl::ext::oneapi::bfloat16, T> {
1748+
using type = sycl::ext::oneapi::bfloat16;
1749+
};
1750+
1751+
template <typename T> struct common_type<T, sycl::ext::oneapi::bfloat16> {
1752+
using type = sycl::ext::oneapi::bfloat16;
1753+
};
1754+
} // namespace std
1755+
```
17321756
17331757
```cpp
17341758
namespace syclcompat{

0 commit comments

Comments
 (0)