CTFE sort of tuples

Timon Gehr timon.gehr at gmx.ch
Fri May 3 08:06:43 UTC 2019


On 02.05.19 09:28, Stefan Koch wrote:
> On Thursday, 2 May 2019 at 02:54:03 UTC, Andrey wrote:
>> Hello, I have got this code:
>>
>>>     [...]
>>
>> I want to sort array of tuples using "data" element in CTFE. But this 
>> code give me errors:
>>> [...]
>>
>> As I understand the function "sort" sometimes can't be run at CT 
>> because of reinterpreting cast.
>> In this case how to sort?
> 
> write a sort?
> 
> a bubble-sort should be sufficient for if the arrays are as short as in 
> the example.

Well, clearly, we should be able to /swap values/ at compile time.


More information about the Digitalmars-d-learn mailing list