Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add wrappers for abseil containers #178

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
19 changes: 19 additions & 0 deletions include/libpy/library_wrappers/abseil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <absl/container/btree_map.h>
#include <absl/container/btree_set.h>

#include "libpy/to_object.h"

namespace py {
namespace dispatch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be shortened to namespace py::dispatch {


template<typename Key, typename T>
struct to_object<absl::btree_map<Key, T>>
: public map_to_object<absl::btree_map<Key, T>> {};

template<typename Key>
struct to_object<absl::btree_set<Key>> : public set_to_object<absl::btree_set<Key>> {};

} // namespace dispatch
} // namespace py
20 changes: 20 additions & 0 deletions tests/library_wrappers/test_abseil.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "libpy/library_wrappers/abseil.h"

#include "test_utils.h"

namespace test_abseil {

class abseil_to_object : public with_python_interpreter {};

TEST_F(abseil_to_object, btree_map) {
auto map = absl::btree_map<std::string, bool>();
py_test::test_map_to_object_impl(map);
}

TEST_F(abseil_to_object, btree_set) {
auto filler = py_test::examples<std::string>();
auto a = absl::btree_set<std::string>(filler.begin(), filler.end());
py_test::test_set_to_object_impl(a);
}

} // namespace test_abseil