Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vec explicit conversion #669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions adoc/chapters/programming_interface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17869,6 +17869,21 @@ to which [code]#DataT# is implicitly convertible.
Note that conversion operator shall not be templated
to allow standard conversion sequence for implicit conversion.

a@
[source]
----
template<typename T>
explicit operator T() const
----
a@ _Constraints:_

* [code]#NumElements# is equal to 1, and
* [code]#DataT# can be explicitly converted to [code]#T# via
[code]#static_cast<T>#, and
* [code]#T# is not [code]#DataT#.

Returns the value of the vector's element converted to [code]#T#.

a@
[source]
----
Expand Down Expand Up @@ -18661,6 +18676,10 @@ operator vector_t() const
#endif

operator DataT() const

template<typename T>
explicit operator T() const

static constexpr size_t byte_size() noexcept
static constexpr size_t size() noexcept

Expand Down
4 changes: 4 additions & 0 deletions adoc/headers/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ template <typename DataT, int NumElements> class vec {
// Available only when: NumElements == 1
operator DataT() const;

// Available only when: NumElements == 1 and T is explicitly convertible to DataT
template<typename T>
explicit operator T() const;

static constexpr size_t byte_size() noexcept;

static constexpr size_t size() noexcept;
Expand Down
Loading