pybind / pybind/pybind11_abseil

Error when converting absl::Span<const bool>

Open
#4 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug enhancement help wanted
Dominant language
C++
Stars
27
Forks
21
PR merge metrics
No merged PRs in 30d

Description

When trying to specify a py::arg with C++ type absl::Span (or more specifically in my case absl::optional<absl::Span>), I get an compile error:

./third_party/pybind11_abseil/absl_casters.h:378:12: error: no matching function for call to 'MakeSpan'
return absl::MakeSpan(static_cast<std::vector<value_type>&>(caster));
...

I guess this might be related to std::vector being potentially specialized as a bitset instead of an array of byte sized bools (https://github.com/abseil/abseil-cpp/issues/644). It would be nice to be able to define an py::arg as absl::Span though if it's possible to side-step this issue.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in third_party/pybind11_abseil/absl_casters.h around line 378 and reproduce the compile error for absl::Span, including the absl::optional case. Investigate the MakeSpan call and the interaction with std::vector; done means a py::arg using these types compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.