Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      ATOMIC_FLAG_INIT

      From cppreference.com
      <cpp‎ |atomic
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      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
      (C++11)(deprecated in C++20)
      (C++11)(deprecated in C++20)
      ATOMIC_FLAG_INIT
      (C++11)
      Memory ordering
      (C++11)(deprecated in C++26)
      Free functions for atomic operations
      Free functions for atomic flags
       
      Defined in header<atomic>
      #define ATOMIC_FLAG_INIT /* implementation-defined */
      (since C++11)

      Defines the initializer which can be used to initializestd::atomic_flag to clear (false) state in the formstd::atomic_flag v= ATOMIC_FLAG_INIT;. It is unspecified if it can be used with other initialization contexts.

      If the flag has is acomplete object withstatic storage duration, thisinitialization is static.

      This is the only way to initializestd::atomic_flag to a definite value: the value held after any other initialization is unspecified.

      (until C++20)

      This macro is no longer needed since default constructor ofstd::atomic_flag initializes it to clear state. It is kept for the compatibility with C.

      (since C++20)

      [edit]Example

      Run this code
      #include <atomic> std::atomic_flag static_flag= ATOMIC_FLAG_INIT;// static initialization,// guaranteed to be available during dynamic initialization of static objects. int main(){std::atomic_flag automatic_flag= ATOMIC_FLAG_INIT;// guaranteed to work//    std::atomic_flag another_flag(ATOMIC_FLAG_INIT); // unspecified}

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2159C++11it was unclear whetherATOMIC_FLAG_INIT
      can be used with other initialization contexts
      other usages are
      not guaranteed
      LWG 3659C++20ATOMIC_FLAG_INIT was deprecated, but needed in C on some platformsit is undeprecated

      [edit]See also

      the lock-free boolean atomic type
      (class)[edit]
      C documentation forATOMIC_FLAG_INIT
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/atomic/ATOMIC_FLAG_INIT&oldid=177107"

      [8]ページ先頭

      ©2009-2025 Movatter.jp