Why is std :: atomic not a trivial type only in Visual C ++?

The Folly library requires std::atomic<hazptr_obj*> be a trivial type. This works with gcc and clang, but not for Visual C ++ even for std::atomic<int> . Why std::is_trivial return false ?

 #include <type_traits> #include <atomic> static_assert( std::is_trivial<std::atomic<int>>::value, "std::atomic<int> not trivial"); 
+7
c ++ c ++ 11 visual-c ++
source share
2 answers

std::atomic was trivial (which requires a trivially copied one), but no longer exists. See this answer for a detailed explanation of how and why this has changed.

This makes VC compatible and gcc and clang incompatible, at least in C ++ 17. Since this was considered a committee flaw, VC shows the desired behavior for C ++ 11 and C ++ 14.

For future reference, the corresponding defect DR # 1734 , you can see the implementation status for clang here . I am not aware of the equivalent status page for gcc.

+12
source share
+1
source share

All Articles