#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include
#include
// increments a counter only on destruction
struct CountOnDestruction {
CountOnDestruction(const CountOnDestruction& rhs) : counter {rhs.counter} {
rhs.counter = nullptr;
}
CountOnDestruction(CountOnDestruction&& rhs) : counter{rhs.counter} {
rhs.counter = nullptr;
}
CountOnDestruction(std::atomic& c) : counter {&c} {}
~CountOnDestruction() {
if(counter) {
//std::cout fetch_add(1, std::memory_order_relaxed);
}
}
mutable std::atomic* counter {nullptr};
};
// ----------------------------------------------------------------------------
// test move constructor
// ----------------------------------------------------------------------------
TEST_CASE("moved_run") {
int N = 10000;
std::atomic counter {0};
tf::Taskflow taskflow;
auto make_taskflow = [&](){
for(int i=0; i