Skip to content

Commit

Permalink
Merge branch 'master' of github.com:felixguendling/cista
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Apr 11, 2024
2 parents 95b2779 + 5f93560 commit 715692f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/cista/containers/hash_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ struct hash_storage {
}

hash_storage& operator=(hash_storage const& other) {
clear();
if (other.size() == 0U) {
clear();
return *this;
}
for (const auto& v : other) {
Expand Down
5 changes: 5 additions & 0 deletions include/cista/containers/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ using cista::variant;

namespace std {

template <typename Visitor, typename... T>
constexpr auto visit(Visitor&& vis, cista::variant<T...>&& v) {
v.apply(vis);
}

using cista::get;

} // namespace std
12 changes: 12 additions & 0 deletions test/variant_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,15 @@ TEST_CASE("variant get_if") {
REQUIRE(str != nullptr);
CHECK(*str == "hello test test test test");
}

TEST_CASE("std visit") {
std::visit(
[](auto&& x) {
if constexpr (std::is_same_v<int, std::decay_t<decltype(x)>>) {
CHECK(true);
} else {
CHECK(false);
}
},
cista::variant<int, float>{1});
}

0 comments on commit 715692f

Please sign in to comment.