Skip to content

Commit

Permalink
Merge pull request #75 from no92/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
no92 authored Sep 27, 2024
2 parents 736c716 + 09aa801 commit 91ada7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/frg/manual_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class manual_box {
template<typename... Args>
void initialize(Args &&... args) {
FRG_ASSERT(!_initialized);
new(&_storage) T(std::forward<Args>(args)...);
new(&_storage.buffer) T(std::forward<Args>(args)...);
_initialized = true;
}

template<typename F, typename... Args>
void construct_with(F f) {
FRG_ASSERT(!_initialized);
new(&_storage) T{f()};
new(&_storage.buffer) T{f()};
_initialized = true;
}

Expand All @@ -37,7 +37,7 @@ class manual_box {

T *get() {
FRG_ASSERT(_initialized);
return std::launder(reinterpret_cast<T *>(&_storage));
return std::launder(reinterpret_cast<T *>(&_storage.buffer));
}

bool valid() {
Expand Down
6 changes: 6 additions & 0 deletions include/frg/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const T &max(const T &a, const T &b) {
return (a < b) ? b : a;
}

template<typename T>
requires (T(-1) < T(0))
const T abs(const T v) {
return (v < 0) ? -v : v;
}

template<typename Tag, typename T>
struct composition : private T {
static T &get(composition<Tag, T> *p) {
Expand Down

0 comments on commit 91ada7d

Please sign in to comment.