Namespaces
Variants

std:: atomic_init

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
atomic_init
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
헤더 파일에 정의됨 <atomic>
template < class T >

void atomic_init
( std:: atomic < T > * obj,

typename std:: atomic < T > :: value_type desired ) noexcept ;
(1) (C++11부터)
(C++20부터 사용 중단됨)
template < class T >

void atomic_init
( volatile std:: atomic < T > * obj,

typename std:: atomic < T > :: value_type desired ) noexcept ;
(2) (C++11부터)
(C++20부터 사용 중단됨)

기본 생성된 atomic 객체 obj 를 값 desired 로 초기화합니다. 이 함수는 atomic하지 않습니다: 다른 스레드에서의 동시 접근(atomic 연산을 통한 경우에도)은 데이터 경쟁(data race)입니다.

만약 obj 가 기본 생성되지 않았거나, 동일한 obj 에 대해 이 함수가 두 번 호출되면, 동작은 정의되지 않습니다.

목차

매개변수

obj - 초기화할 atomic 객체에 대한 포인터
desired - atomic 객체를 초기화할 값

반환값

(없음)

참고 사항

이 함수는 C와의 호환성을 위해 제공됩니다. 호환성이 필요하지 않은 경우, std::atomic 은(는) 비기본 생성자를 통해 초기화될 수 있습니다.

예제

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
P0558R1 C++11 정확한 타입 일치가 요구되었음
T 가 여러 인수에서 추론되었기 때문
T 는 오직
obj 에서만 추론됨

참고 항목

(C++11) (C++20에서 사용 중단됨)
정적 저장 기간을 가진 원자 변수의 상수 초기화
(함수 매크로)
원자 객체를 생성함
( std::atomic<T> 의 public 멤버 함수)
C 문서 for atomic_init