qvm: return type for mixed scalar type vector operations

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

qvm: return type for mixed scalar type vector operations

Boost - Dev mailing list
Hey all,

concerning vector operations in boost qvm,
is it possible to somehow specify the return type of a binary operator with mixed scalar input data, e.g.

operator+(vec<double, 3>, vec<int, 3>)

?

Could not find the customisation point to do this depending on the involved operation.

Thanks in advance,

Kai

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: qvm: return type for mixed scalar type vector operations

Boost - Dev mailing list
See deduce_vec2 (https://boostorg.github.io/qvm/#deduce_vec2): this
template is used by QVM whenever it needs to deduce a vector type of
certain dimension from the types of two user-supplied function parameters
(there is also deduce_vec, which is used by unary operations).

If you don't care about the resulting vector type but only about its scalar
type, you can specialize deduce_scalar instead (
https://boostorg.github.io/qvm/#deduce_scalar), which is used by
deduce_vec2 by default.

On Mon, Dec 7, 2020 at 8:58 AM Kai Szuttor via Boost <[hidden email]>
wrote:

> Hey all,
>
> concerning vector operations in boost qvm,
> is it possible to somehow specify the return type of a binary operator
> with mixed scalar input data, e.g.
>
> operator+(vec<double, 3>, vec<int, 3>)
>
> ?
>
> Could not find the customisation point to do this depending on the
> involved operation.
>
> Thanks in advance,
>
> Kai
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: qvm: return type for mixed scalar type vector operations

Boost - Dev mailing list
actually i’m aware of this template. However, it does not take into account the involved binary operator.
Am I missing something or is this template missing this customisation point?

A related follow up question, looking at the vectors operator*, e.g., if i want to express the resulting type of a scalar multiplication with mixed types like a Vector of ints with a double scalar type. How can I implement that? The return type of that function overload is determined by deduce_vec<A>::type which only takes into account the vector data type and not the type for the scalar.


> On 7. Dec 2020, at 21:29, Emil Dotchevski via Boost <[hidden email]> wrote:
>
> See deduce_vec2 (https://boostorg.github.io/qvm/#deduce_vec2): this
> template is used by QVM whenever it needs to deduce a vector type of
> certain dimension from the types of two user-supplied function parameters
> (there is also deduce_vec, which is used by unary operations).
>
> If you don't care about the resulting vector type but only about its scalar
> type, you can specialize deduce_scalar instead (
> https://boostorg.github.io/qvm/#deduce_scalar), which is used by
> deduce_vec2 by default.
>
> On Mon, Dec 7, 2020 at 8:58 AM Kai Szuttor via Boost <[hidden email]>
> wrote:
>
>> Hey all,
>>
>> concerning vector operations in boost qvm,
>> is it possible to somehow specify the return type of a binary operator
>> with mixed scalar input data, e.g.
>>
>> operator+(vec<double, 3>, vec<int, 3>)
>>
>> ?
>>
>> Could not find the customisation point to do this depending on the
>> involved operation.
>>
>> Thanks in advance,
>>
>> Kai
>>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost