Skip to content

Commit

Permalink
macos: vecvec bucket <-> std::span compatibility (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored May 31, 2023
1 parent 9e39a20 commit 8c090ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include(GNUInstallDirs)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(cista-compile-flags
-Wno-unknown-warning-option
-Wno-global-constructors
-Wno-exit-time-destructors
-fno-strict-aliasing
Expand Down
9 changes: 6 additions & 3 deletions include/cista/containers/vecvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct basic_vecvec {
bucket(basic_vecvec* map, index_value_type const i)
: map_{map}, i_{to_idx(i)} {}

data_value_type* data() const { return &(*begin()); }

template <typename T = std::decay_t<data_value_type>,
typename = std::enable_if_t<std::is_same_v<T, char>>>
std::string_view view() const {
Expand Down Expand Up @@ -75,9 +77,7 @@ struct basic_vecvec {
return *(begin() + i);
}

index_value_type size() const {
return bucket_end_idx() - bucket_begin_idx();
}
std::size_t size() const { return bucket_end_idx() - bucket_begin_idx(); }
iterator begin() { return map_->data_.begin() + bucket_begin_idx(); }
iterator end() { return map_->data_.begin() + bucket_end_idx(); }
const_iterator begin() const {
Expand Down Expand Up @@ -159,6 +159,9 @@ struct basic_vecvec {
const_bucket(basic_vecvec const* map, index_value_type const i)
: map_{map}, i_{to_idx(i)} {}

friend iterator data(const_bucket const& b) { return b.begin(); }
friend std::size_t size(const_bucket const& b) { return b.size(); }

template <typename T = std::decay_t<data_value_type>,
typename = std::enable_if_t<std::is_same_v<T, char>>>
std::string_view view() const {
Expand Down
2 changes: 1 addition & 1 deletion test/comparable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

struct comparable_a {
CISTA_COMPARABLE()
CISTA_FRIEND_COMPARABLE(comparable_a)
int i_ = 1;
int j_ = 2;
double d_ = 100.0;
Expand Down

0 comments on commit 8c090ea

Please sign in to comment.