不清楚如何定义结构字段的ref或ptr类型?
struct uint128_t {
uint64_t lo;
uint64_t hi;
device uint64_t& operator[](int i) {
return (i == 0) ? lo : hi;
}
...
}
Reference to type 'device uint64_t' (aka 'device unsigned long') could not bind to an lvalue of type 'uint64_t' (aka 'unsigned long')
您需要为函数本身指定一个地址空间。否则,您就不能使用地址空间特定的东西。
以下是正确的定义:
struct uint128_t {
uint64_t lo;
uint64_t hi;
device uint64_t& operator[](int i) device {
return (i == 0) ? lo : hi;
}
};