atomic_atomic_init

atomic_atomic_init (원자적 초기화)

std::atomic_init는 기본 생성된 std::atomic 객체에 초기 값을 부여해요. C++20부터 사용 자제(deprecated)돼요.

출처: cppreference

본문

std::atomic_init<atomic> 헤더에 정의된 자유 함수예요.

template< class T >
void atomic_init( std::atomic<T>* obj,
                  typename std::atomic<T>::value_type value ) noexcept;

기본 생성된(초기화되지 않은) obj가 가리키는 std::atomic 객체의 값을 value로 비원자적으로(non-atomically) 설정해요. 객체가 이미 초기화된 경우 동작이 정의되지 않아요. C++20부터는 생성자로 초기화하는 것이 권장되며 atomic_init은 deprecated예요.

예제 (Example)

#include <atomic>

int main()
{
    std::atomic<int> a;          // 초기화되지 않음
    std::atomic_init(&a, 42);    // a의 값을 42로 설정
}

더 알아보기 (Learn more)

cppreference