Skip to content

atomic_init calls throw deprecation warnings after acceptance of C++20 P0883 #139

@BillyONeal

Description

@BillyONeal

P0883 marks atomic_init as deprecated, which causes cppcoro to throw a bunch of deprecation errors when used with our standard library (post microsoft/STL#390 ).

Should the places calling atomic_init be changed to do something like:

// earlier
#ifdef __cpp_lib_atomic_value_initialization
template<class T, class Args>
void true_placement_new(T* ptr, Args&&... args) { // do you already have a function for this?
    ::new(static_cast<void*>(ptr)) T(std::forward<Args>(args)...);
}
#endif // __cpp_lib_atomic_value_initialization


// in multi_producer_sequencer.hpp:
SEQUENCE seq = initialSequence - (bufferSize - 1);
do
{
#ifdef __cpp_lib_atomic_value_initialization
    true_placement_new(&m_published[seq & m_sequenceMask], seq);
#else
    std::atomic_init(&m_published[seq & m_sequenceMask], seq);
#endif // __cpp_lib_atomic_value_initialization
} while (seq++ != initialSequence);

instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions