Operation on Inter-Tuple types
monarch_dodra
monarchdodra at gmail.com
Tue Feb 12 12:39:09 PST 2013
On Tuesday, 12 February 2013 at 14:35:18 UTC, kenji hara wrote:
> 2013/2/12 monarch_dodra <monarchdodra at gmail.com>
>
>> This question came up in the pulls.
>>
>> Given two different Tuple types, it is possible to run an
>> operator on said
>> tuples, if the operator is legal for each individual field in
>> the tuple.
>> For example.
>>
>
> Even if each field-wise operations is legal, the synthesis
> operation of
> individual results might not be obvious.
>
> Kenji Hara
Hum...
I went to C++ to see how they do it. Apparently, in C++,
cross-tuple operations are fair game:
//----
#include <iostream>
#include <tuple>
int main()
{
std::tuple<int, int> a;
std::tuple<short, short> b;
a = b;
if (a == b)
std::cout << "hello" << std::endl;
if (a < b)
std::cout << "hello" << std::endl;
}
//----
If we follow the rule of "least surprise" and that "things which
are common behave the same", it might be safer to keep this
behavior.
More information about the Digitalmars-d
mailing list