Skip to content

ossia: handle std::vector<bool> in to_ossia_value - #178

Merged
jcelerier merged 1 commit into
mainfrom
fix/vector-bool-libcxx
Jul 22, 2026
Merged

ossia: handle std::vector<bool> in to_ossia_value#178
jcelerier merged 1 commit into
mainfrom
fix/vector-bool-libcxx

Conversation

@jcelerier

Copy link
Copy Markdown
Member

std::vector satisfies avnd::vector_ish, so the generic container overload at to_value.hpp:182 is selected and calls to_ossia_value_impl on f[i].

  • On libstdc++, vector<bool>::const_reference is plainly bool, so that resolves to the bool overload and works by accident.
  • On libc++, it is the proxy class std::__bit_const_reference<std::vector<bool>>, which is neither integral, nor bool, nor a container. It matches none of the constrained overloads and binds to the deleted catch-all operator()(const auto&) by identity (exact match beats the user-defined conversion to bool), so the build fails with call to deleted function call operator.

This adds a dedicated std::vector<bool> overload that materializes each element to bool. Being a non-template exact match it is preferred over the vector_ish template with no ambiguity, and nothing changes for any other type. (A static_cast<value_type> inside the generic loop would also work but would force a copy of every element for all container types.)

Found while building ossia/score on macOS (Apple clang / libc++), where Avnd_ossia_value_Test failed to compile — the round-trip test at from_ossia_value_Test.cpp:300 exercises a std::vector<bool> parameter.

Verified: compiles and links cleanly on Linux/libstdc++ (no regression); the fix removes the proxy from the call entirely so it resolves identically on both standard libraries.

🤖 Generated with Claude Code

std::vector<bool> satisfies avnd::vector_ish, so the generic container
overload is selected and calls to_ossia_value_impl on f[i]. On libstdc++
vector<bool>::const_reference is plainly bool, so that resolves to the
bool overload and works by accident. On libc++ it is the proxy class
std::__bit_const_reference, which is neither integral, nor bool, nor a
container: it matches none of the constrained overloads and binds to the
deleted catch-all operator()(const auto&) by identity, so the build fails
with 'call to deleted function call operator'.

Add a dedicated std::vector<bool> overload that materializes each element
to bool. Being a non-template exact match it is preferred over the
vector_ish template, and nothing else changes.

Found building ossia/score on macOS (Apple clang / libc++), where
Avnd_ossia_value_Test failed to compile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jcelerier
jcelerier force-pushed the fix/vector-bool-libcxx branch from 8082936 to a1f9cb4 Compare July 22, 2026 15:23
@jcelerier
jcelerier merged commit 4ca9deb into main Jul 22, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant