“Use of deleted function” error with std::atomic_int

前端 未结 2 1386
清酒与你
清酒与你 2021-01-31 16:28

I want to use an std::atomic_int variable. In my code, I have:

#include 

std::atomic_int stop = 0;

int main()
{
    // Do something
         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-31 16:56

    In my case I had de following errors (Examples):

    • ‘std::literals’ has not been declared

    using namespace std::literals::string_literals;
    

    • “Use of deleted function” error with std::random_device{}

    std::random_device device = std::random_device{}  
    

    Check what is your selected C++ Standard. In my case on debug mode I had selected -std=c++17, ALL OK. But on Release mode I had selected -std:c++11, tons of errors.

    Update Tested on Clion Windows 2018.3 with remote Linux compile.

    Using -std=c++11

    Using -std=c++17

    C ++ is an evolving standard: after 2003 there were 2011 (C ++ 11), then 2014 (C ++ 14) and now we have 2017 (C ++ 17) and we are working for 2020 (C ++ 20) . Many things are changing, they are deprecated, other features are new. If you want the latest update, you should use the most recent standard, if your software has code that may be deprecated then you have to use the standard with which it was created.

提交回复
热议问题