mirror of
https://github.com/catchorg/Catch2.git
synced 2025-10-09 12:15:39 +02:00
Add option to skip forward to the generator interface
This commit is contained in:
@@ -39,6 +39,22 @@ public:
|
||||
current_number = m_dist(m_rand);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Note: this improves the performance only a bit, but it is here
|
||||
// to show how you can override the skip functionality.
|
||||
void skipToNthElementImpl( std::size_t n ) override {
|
||||
auto current_index = currentElementIndex();
|
||||
assert(current_index <= n);
|
||||
// We cannot jump forward the underlying generator directly,
|
||||
// because we do not know how many bits each distributed number
|
||||
// would consume to be generated.
|
||||
for (; current_index < n; ++current_index) {
|
||||
(void)m_dist(m_rand);
|
||||
}
|
||||
|
||||
// We do not have to touch the current element index; it is handled
|
||||
// by the base class.
|
||||
}
|
||||
};
|
||||
|
||||
// Avoids -Wweak-vtables
|
||||
|
Reference in New Issue
Block a user