Cannot create enumeration type as atomic

#include <iostream>
#include <atomic>
using namespace std;    
typedef enum day{sun =0, mon, tue}day;    

int main() {
    atomic<day> a(sun);
    cout<<a<<endl;
    return 0;
}

The above code will try to create an enum variable as an atomic type. But I get the following error.

undefined reference to std::atomic<day>::operator day() const

Does atom have no enum type support? or any error in my syntax? I am using a g ++ compiler running on a 32-bit ubuntu 12.0.4 machine. thank.

+4
source share
1 answer

I compiled the same code with an online compiler that supports C ++ 11 and C ++ 14. I had no problems.

atomic Not available until C ++ 11 standards.

For reference: http://ideone.com/fork/Pe4gVt

+1
source

All Articles