Skip to content

Commit

Permalink
add rtree (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored Oct 4, 2023
1 parent e5a58c7 commit e27496c
Show file tree
Hide file tree
Showing 7 changed files with 503 additions and 34 deletions.
33 changes: 33 additions & 0 deletions include/cista/cista_member_offset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include "cista/offset_t.h"

namespace cista {

template <typename T, typename Member>
cista::offset_t member_offset(T const* t, Member const* m) {
static_assert(std::is_trivially_copyable_v<T>);
return (reinterpret_cast<std::uint8_t const*>(m) -
reinterpret_cast<std::uint8_t const*>(t));
}

template <typename T, typename Member>
offset_t member_offset(T const* t, Member T::*m) {
static_assert(std::is_trivially_copyable_v<T>);
return (reinterpret_cast<std::uint8_t const*>(&(t->*m)) -
reinterpret_cast<std::uint8_t const*>(t));
}

} // namespace cista

#ifndef cista_member_offset
#define cista_member_offset(Type, Member) \
([]() { \
if constexpr (std::is_standard_layout_v<Type>) { \
return static_cast<::cista::offset_t>(offsetof(Type, Member)); \
} else { \
return ::cista::member_offset(static_cast<Type*>(nullptr), \
&Type::Member); \
} \
}())
#endif
1 change: 1 addition & 0 deletions include/cista/containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "cista/containers/mutable_fws_multimap.h"
#include "cista/containers/nvec.h"
#include "cista/containers/optional.h"
#include "cista/containers/rtree.h"
#include "cista/containers/string.h"
#include "cista/containers/tuple.h"
#include "cista/containers/unique_ptr.h"
Expand Down
Loading

0 comments on commit e27496c

Please sign in to comment.