-
Notifications
You must be signed in to change notification settings - Fork 2.2k
DEAD END: Make make_caster
unique_to_translation_unit
#3931
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for more information, see https://pre-commit.ci
Friend functions are preferable for ADL-based selection of the type casters.
for more information, see https://pre-commit.ci
rwgk
added a commit
to rwgk/stuff
that referenced
this pull request
May 9, 2022
Models pybind11_select_caster (pybind/pybind11#3931) instead of the older type_caster specialization mechanics.
make_caster
unique_to_translation_unit
make_caster
unique_to_translation_unit
rwgk
added a commit
to laramiel/pybind11
that referenced
this pull request
May 13, 2022
For full background see: pybind#3931 TL;DR: The work under PR pybind#3931 made it obvious that test_select_caster_alt was too simple for deriving meaningful conclusions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
DEAD END
Small experiment (3239d48) on top of PR #3862.
DEAD END
The approach below does not solve the ODR problem. The essence is captured here:
https://github.com/rwgk/stuff/blob/4da4c4e020ed3c82f3c066f73442fdea77d32fec/caster_odr_specs_scope/engine.h#L35
rwgk/stuff@4da4c4e
The
power_less
function violates the ODR because it drops theU
template parameter (roughly corresponds to pybind11cpp_function::initialize
).The
more_power_less
function violates the ODR transitively (roughly corresponds tocpp_function::dispatcher
).See also: dead-end experiment changing pybind11 (on top of master):
Original PR description below:
Objective: ISO C++ standard-compliant support for translation-unit-specific caster classes.
Informed by observations from an isolated experiment under https://github.com/rwgk/stuff/tree/master/caster_odr:
main()
) — model for an application that imports both extensionsclang++ -std=c++11 car.cc truck.cc vehicle_specs.cc
The example output below exhibits
unique_to_translation_unit
fixes the observable consequences (3rd & 4th ./a.out outputs).The caster_odr results were reproduced with:
Important:
pybind11_select_caster
mechanism it not part of the caster_odr experiment.unique_to_translation_unit
, test_select_caster + test_select_caster_alt (included in PR Addpybind11_select_caster
#3862) does not exhibit observable consequences of ODR-non-conformance (https://eel.is/c++draft/temp.dep.candidate#1).Questions (two ways of looking at the same question, really):
make_caster
as under PR Addpybind11_select_caster
#3862 (i.e. withoutunique_to_translation_unit
)?Suggested changelog entry: