Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions include/frg/aligned_storage.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef FRG_ALIGNED_STORAGE_HPP
#define FRG_ALIGNED_STORAGE_HPP

#include <cstddef>
#include <algorithm>

#include <frg/macros.hpp>

namespace frg FRG_VISIBILITY {

template<std::size_t Size, std::size_t Align>
struct alignas(Align) aligned_storage {
constexpr aligned_storage()
: buffer{0} { }

char buffer[Size];
};

template <typename ...T>
using aligned_union = aligned_storage<
std::max({sizeof(T)...}),
std::max({alignof(T)...})
>;

} // namespace frg

#endif // FRG_ALIGNED_STORAGE_HPP
16 changes: 1 addition & 15 deletions include/frg/eternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,12 @@
#include <new>
#include <cstddef>
#include <utility>
#include <algorithm>

#include <frg/aligned_storage.hpp>
#include <frg/macros.hpp>

namespace frg FRG_VISIBILITY {

template<std::size_t Size, std::size_t Align>
struct alignas(Align) aligned_storage {
constexpr aligned_storage()
: buffer{0} { }

char buffer[Size];
};

template <typename ...T>
using aligned_union = aligned_storage<
std::max({sizeof(T)...}),
std::max({alignof(T)...})
>;

// Container for an object that deletes the object's destructor.
// eternal<T> always has a trivial destructor.
template<typename T>
Expand Down
2 changes: 1 addition & 1 deletion include/frg/manual_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <new>
#include <utility>

#include <frg/eternal.hpp>
#include <frg/aligned_storage.hpp>
#include <frg/macros.hpp>

namespace frg FRG_VISIBILITY {
Expand Down
2 changes: 1 addition & 1 deletion include/frg/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <new>
#include <utility>

#include <frg/eternal.hpp>
#include <frg/aligned_storage.hpp>
#include <frg/macros.hpp>

namespace frg FRG_VISIBILITY {
Expand Down
2 changes: 1 addition & 1 deletion include/frg/rcu_radixtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <atomic>
#include <new>
#include <frg/allocation.hpp>
#include <frg/eternal.hpp>
#include <frg/aligned_storage.hpp>
#include <frg/macros.hpp>
#include <frg/tuple.hpp>
#include <frg/rcu.hpp>
Expand Down
1 change: 1 addition & 0 deletions include/frg/safe_int.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <concepts>
#include <expected>
#include <type_traits>

Expand Down
3 changes: 2 additions & 1 deletion include/frg/small_vector.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include <new>
#include <utility>
#include <stdint.h>

#include <frg/array.hpp>
#include <frg/eternal.hpp>
#include <frg/aligned_storage.hpp>
#include <frg/macros.hpp>

namespace frg FRG_VISIBILITY {
Expand Down
3 changes: 2 additions & 1 deletion include/frg/variant.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <frg/eternal.hpp>
#include <frg/aligned_storage.hpp>
#include <frg/macros.hpp>
#include <new>
#include <type_traits>
#include <stddef.h>

Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ incl = include_directories('include')
if not get_option('frigg_no_install')
install_headers(
'include/frg/algorithm.hpp',
'include/frg/aligned_storage.hpp',
'include/frg/allocation.hpp',
'include/frg/array.hpp',
'include/frg/bitops.hpp',
Expand Down
Loading