mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Tuple update (#2235)
* 'next_float' macro patch More optimized implementation. * tuple-type update * U suffix in 'next_float' * Do not add triplet, quadruplet, keep Tuple but deprecate. Add unpack --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
module std::collections::tuple{Type1, Type2};
|
||||
module std::collections::pair{Type1, Type2};
|
||||
|
||||
struct Tuple
|
||||
struct Pair
|
||||
{
|
||||
Type1 first;
|
||||
Type2 second;
|
||||
}
|
||||
|
||||
<*
|
||||
@param [&out] a
|
||||
@param [&out] b
|
||||
@require $assignable(self.first, $typeof(*a)) : "You cannot assign the first value to a"
|
||||
@require $assignable(self.second, $typeof(*b)) : "You cannot assign the second value to b"
|
||||
*>
|
||||
|
||||
macro void Pair.unpack(&self, a, b)
|
||||
{
|
||||
*a = self.first;
|
||||
*b = self.second;
|
||||
}
|
||||
|
||||
module std::collections::triple{Type1, Type2, Type3};
|
||||
|
||||
struct Triple
|
||||
@@ -13,4 +26,12 @@ struct Triple
|
||||
Type1 first;
|
||||
Type2 second;
|
||||
Type3 third;
|
||||
}
|
||||
}
|
||||
|
||||
module std::collections::tuple{Type1, Type2};
|
||||
|
||||
struct Tuple @deprecated("Use 'Pair' instead")
|
||||
{
|
||||
Type1 first;
|
||||
Type2 second;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ macro bool next_bool(random)
|
||||
*>
|
||||
macro float next_float(random)
|
||||
{
|
||||
uint val = random.next_int() & (1 << 24 - 1);
|
||||
uint val = random.next_int() & (1U << 24 - 1);
|
||||
return val * 0x1.0p-24f;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user