is_lock_free()是否对某些数据类型返回true,而对另一种数据类型返回false?

问题描述 投票:0回答:1

我知道is_lock_free取决于硬件,但是当我在ADT上使用它时,对于int类型它返回false但为true。怎么可能?

#include <iostream>
#include <atomic>
struct myType {

    size_t ID{};
    size_t to{};
};
int main() {


    std::atomic<myType> i{ };
    std::cout << "\n" << i.is_lock_free();

    std::atomic j { 1};
    std::cout << "\n" << j.is_lock_free();

}
c++ multithreading c++17 atomic
1个回答
0
投票

is_lock_free()是否对某些数据类型返回true,而对另一种数据类型返回false?

© www.soinside.com 2019 - 2024. All rights reserved.