並列 avl ツリーに取り組んでいて、問題が発生しました。この問題を引き起こす関数は次のとおりです。
template<typename T, int Threads>
bool PTreeSet<T, Threads>::tryInsert(Node* parent, Node* node) {
if (parent->key > node->key) {
return parent->left.compare_exchange_strong(nullptr, node); // <-- Error
} else if (parent->key < node->key) {
return parent->right.compare_exchange_strong(nullptr, node); // <-- Error
} else {
return false;
}
return true;
}
parent->left
タイプがあり、現在の値が null の場合にatomic<Node*>
そのポインターを設定したい。node
コンパイラはエラーを訴えます
error: no matching member function for call to 'compare_exchange_strong'
return parent->left.compare_exchange_strong(nullptr, node);
これが有効なコードではないのはなぜですか?