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

Add boost::variant support #430

Merged
merged 5 commits into from
Jan 30, 2024

Conversation

jorisv
Copy link
Contributor

@jorisv jorisv commented Jan 30, 2024

  • Add BoostVariantConverter to register a boost::variant conversion to an alternatives and alternatives conversion to boost::variant.
  • Add ReturnInternalBoostVariant to return an alternative reference

Also:

  • Cancel CI workflow when a new commit is pushed

@jorisv jorisv self-assigned this Jan 30, 2024
@jorisv jorisv marked this pull request as ready for review January 30, 2024 09:14
@ManifoldFR
Copy link
Member

Is it possible to handle other variant types ? Like we did with the PR for optional types where we have a mechanism for both boost::optional and std::optional and their respective null/none values.

@jorisv
Copy link
Contributor Author

jorisv commented Jan 30, 2024

@ManifoldFR I will check if it's easy to handle std and boost with the same code

@jcarpent
Copy link
Contributor

std::variant are slow ;)

@jcarpent jcarpent merged commit 61859c2 into stack-of-tasks:devel Jan 30, 2024
29 checks passed
@jorisv jorisv deleted the topic/add_boost_variant branch January 30, 2024 13:15
Copy link
Member

@ManifoldFR ManifoldFR left a comment

Choose a reason for hiding this comment

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

Just some spelling changes to do

/// bp::make_setter(&VariantHolder::variant));
/// }
template <typename Variant>
struct BoostVariantConvertor {
Copy link
Member

@ManifoldFR ManifoldFR Jan 30, 2024

Choose a reason for hiding this comment

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

There's a spelling mistake, it should be "Converter" as in the rest of the library. (not really a mistake because "Convertor" exists but it's very uncommon in English, users might get tripped up)

bp::class_<V1>("V1", bp::init<>()).def_readwrite("v", &V1::v);
bp::class_<V2>("V2", bp::init<>()).def_readwrite("v", &V2::v);

typedef eigenpy::BoostVariantConvertor<MyVariant> Convertor;
Copy link
Member

Choose a reason for hiding this comment

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

Also change the spelling in the typedef here to Converter

@jorisv jorisv mentioned this pull request Jan 31, 2024
nim65s added a commit to nim65s/robotpkg that referenced this pull request Mar 12, 2024
Upstream changelog:

    ## [3.4.0] - 2024-02-26

    ### Added
    - Support for `Eigen::SparseMatrix` types (stack-of-tasks/eigenpy#426)
    - Support for `boost::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#430)
    - Support for `std::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#431)
    - Support for `std::unique_ptr` as a return types with `StdUniquePtrCallPolicies` and `boost::python::default_call_policies` (stack-of-tasks/eigenpy#433)
    - Support for `std::unique_ptr` as an internal reference with `ReturnInternalStdUniquePtr` (stack-of-tasks/eigenpy#433)
    - Support for `Eigen::Simplicial{LLT,LDLT}` and `Eigen::Cholmod{Simplicial,Supernodal}{LLT,LDLT}` Cholesky de compositions (stack-of-tasks/eigenpy#438)
    - Switch to ruff for lints, format, and import sort (stack-of-tasks/eigenpy#441)

    ### Fixed
    - Fix the issue of missing exposition of Eigen types with __int64 scalar type (stack-of-tasks/eigenpy#426)
    - Fix namespace use in unittest/std_pair.cpp (stack-of-tasks/eigenpy#429)
    - Fix case of zero-size sparse matrices (stack-of-tasks/eigenpy#437)

Packaging changes:
- remove patch-aa, fixed upstream
nim65s added a commit to nim65s/robotpkg that referenced this pull request Mar 29, 2024
Upstream changelog:

    ## [3.4.0] - 2024-02-26

    ### Added
    - Support for `Eigen::SparseMatrix` types (stack-of-tasks/eigenpy#426)
    - Support for `boost::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#430)
    - Support for `std::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#431)
    - Support for `std::unique_ptr` as a return types with `StdUniquePtrCallPolicies` and `boost::python::default_call_policies` (stack-of-tasks/eigenpy#433)
    - Support for `std::unique_ptr` as an internal reference with `ReturnInternalStdUniquePtr` (stack-of-tasks/eigenpy#433)
    - Support for `Eigen::Simplicial{LLT,LDLT}` and `Eigen::Cholmod{Simplicial,Supernodal}{LLT,LDLT}` Cholesky de compositions (stack-of-tasks/eigenpy#438)
    - Switch to ruff for lints, format, and import sort (stack-of-tasks/eigenpy#441)

    ### Fixed
    - Fix the issue of missing exposition of Eigen types with __int64 scalar type (stack-of-tasks/eigenpy#426)
    - Fix namespace use in unittest/std_pair.cpp (stack-of-tasks/eigenpy#429)
    - Fix case of zero-size sparse matrices (stack-of-tasks/eigenpy#437)

Packaging changes:
- remove patch-aa, fixed upstream
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.

None yet

3 participants