最初の例:
template <class HashingSolution>
struct State : public HashingSolution {
void Update(int idx, int val) {
UpdateHash(idx, val);
}
int GetState(int idx) {
return ...;
}
};
struct DummyHashingSolution {
void UpdateHash(int idx, int val) {}
void RecalcHash() {}
};
struct MyHashingSolution {
void UpdateHash(int idx, int val) {
...
}
void RecalcHash() {
...
UpdateHash(idx, GetState(idx)); // Problem: no acces to GetState function, can't do recursive application of templates
...
}
};
この例では、MyHashingSolutionをStateクラスに渡して、StateがHashingSolutionのメソッドにアクセスできるようにすることができますが、HashingSolutionはGetStateを呼び出すことができません。これを回避することは可能ですか?
これは最も深いループにあります。ここでの仮想関数は、パフォーマンスを25%以上低下させます。インライン化は私にとって非常に重要です。