29 #ifndef PIRANHA_DETAIL_ATOMIC_FLAG_ARRAY_HPP 30 #define PIRANHA_DETAIL_ATOMIC_FLAG_ARRAY_HPP 38 #include <piranha/config.hpp> 48 struct atomic_flag_array {
49 using value_type = std::atomic_flag;
51 explicit atomic_flag_array(
const std::size_t &size) : m_size(size)
53 if (unlikely(size > std::numeric_limits<std::size_t>::max() /
sizeof(value_type))) {
61 m_ptr.reset(::
new unsigned char[size *
sizeof(value_type)]);
65 const auto end_ptr = m_ptr.get() + size *
sizeof(value_type);
66 for (
auto ptr = m_ptr.get(); ptr != end_ptr; ptr +=
sizeof(value_type)) {
71 ::new (static_cast<void *>(ptr)) value_type;
72 reinterpret_cast<value_type *
>(ptr)->clear();
80 atomic_flag_array() =
delete;
81 atomic_flag_array(
const atomic_flag_array &) =
delete;
82 atomic_flag_array(atomic_flag_array &&) =
delete;
83 atomic_flag_array &operator=(
const atomic_flag_array &) =
delete;
84 atomic_flag_array &operator=(atomic_flag_array &&) =
delete;
85 value_type &operator[](
const std::size_t &i)
87 return *
reinterpret_cast<value_type *
>(m_ptr.get() +
sizeof(value_type) * i);
89 const value_type &operator[](
const std::size_t &i)
const 91 return *
reinterpret_cast<const value_type *
>(m_ptr.get() +
sizeof(value_type) * i);
94 std::unique_ptr<unsigned char[]> m_ptr;
95 const std::size_t m_size;
#define piranha_throw(exception_type,...)
Exception-throwing macro.