您可以使用一箇中間全局數據結構存儲對uint32_t
就可以了,用你只uint32_t
參數作爲結構上的指數:
struct my_pair {
uint32_t a, b;
};
std::map<uint32_t, my_pair> global_pair_map;
uint32_t register_new_pair(uint32_t a, uint32_t b) {
// Add the pair of (a, b) to the map global_pair_map on a new key, and return the
// new key value.
}
void release_pair(uint32_t key) {
// Remove the key from the global_pair_map.
}
void callback(uint32_t user_data) {
my_pair& p = global_pair_map[user_data];
// Use your pair of uint32_t with p.a, and p.b.
}
void main() {
uint32_t key = register_new_pair(number1, number2);
register_callback(callback, key);
}
來源
2014-01-16 18:02:00
vz0
做些什麼範圍值的每個'uint32_t'需要代表?在某種極端情況下,他們是否需要40億的全部範圍,或者另一方面他們是否都代表布爾? – simonc
在大多數情況下,數字將<1000。我不願意將兩者的低位轉換爲單個uint32_t,但這在短期內會起作用。 – Chance