Skip to content
Merged
8 changes: 6 additions & 2 deletions libcxx/include/__atomic/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@

_LIBCPP_BEGIN_NAMESPACE_STD

template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >
struct __cxx_atomic_impl : public _Base {
template <typename _Tp>
struct __check_atomic_mandates {
using type = _Tp;
static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");
};

template <typename _Tp, typename _Base = __cxx_atomic_base_impl<typename __check_atomic_mandates<_Tp>::type> >
struct __cxx_atomic_impl : public _Base {
_LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// <atomic>

// template <class T>
// struct atomic;

#include <atomic>

struct NotTriviallyCopyable {
explicit NotTriviallyCopyable(int i) : i_(i) {}
NotTriviallyCopyable(const NotTriviallyCopyable& rhs) : i_(rhs.i_) {}
int i_;
};

void f() {
NotTriviallyCopyable x(42);
std::atomic<NotTriviallyCopyable> a(
x); // expected-error@*:* {{std::atomic<T> requires that 'T' be a trivially copyable type}}
}

This file was deleted.

Loading