This is the declaration I have in .h file:
static std::atomic<int> OrdersExecutorIdCounter;
This is initilization from .cpp file:
std::atomic<int> ActionBasedOrdersExecutor::OrdersExecutorIdCounter = 0;
It compiles just fine in VC++, but in gcc 4.8 I get this error:
error: use of deleted function ‘std::atomic<int>::atomic(const std::atomic<int>&)’
How can I solve this problem?
Use the DELETE function to erase the data contents of a specified field, value, or subvalue and its corresponding delimiter from a dynamic array.
You can directly initialise the atomic variable, which does not require deleted copy constructor, eg:
std::atomic<int> ActionBasedOrdersExecutor::OrdersExecutorIdCounter{0};
You don't need (or want) to initialize your atomic integer to 0 (the int value would be 0 initialized for a global).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With