/
redgpu
/
ispc
Обзор
Документация
Войти
/
redgpu
/
ispc
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/func-tests/operators5.ispc
60 строк
1 KB
Arina Neshlyaeva
Update couple of operators tests
21 июн 2025, 02:21
21 июн 2025, 02:21
93d6c0b
Код
Авторство
О чём код?
#include "test_static.isph" struct S { int a; }; // Prefix increment (++x) struct S& operator++(struct S &rs) { rs.a = rs.a + 2; return rs; } // Prefix decrement (--x) struct S& operator--(struct S &rs) { rs.a = rs.a - 4; return rs; } // Postfix increment (x++) struct S operator++(struct S &rs, int) { struct S temp; temp.a = rs.a; rs.a = rs.a + 1; return temp; } // Postfix decrement (x--) struct S operator--(struct S &rs, int) { struct S temp; temp.a = rs.a; rs.a = rs.a - 1; return temp; } task void f_f(uniform float RET[], uniform float aFOO[]) { struct S a; struct S c; a.a = aFOO[programIndex]; c.a = aFOO[programIndex]; // Not using overloaded operator RET[programIndex] = ++a.a; // Test prefix increment RET[programIndex] += (++a).a; // Test prefix decrement RET[programIndex] += (--a).a; // Test postfix increment c = a++; RET[programIndex] += a.a - c.a; // 1 // Test postfix decrement c = a--; RET[programIndex] += c.a - a.a; // 1 } task void result(uniform float RET[16]) { RET[programIndex] = programIndex * 3 + 8; }