Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 604089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:00:03+00:00 2026-05-13T17:00:03+00:00

I made some bindings from my C++ app for python. The problem is that

  • 0

I made some bindings from my C++ app for python.

The problem is that I use pointers to members (It’s for computing shortest path and giving the property to minimize as parameter).

This is the C++ signature:

std::vector<Path> martins(int start, int dest, MultimodalGraph & g, float Edge::*)

This is what I did (from what I understood in the doc):

%constant float Edge::* distance = &Edge::distance;

This is how I call my function from python:

foo.martins(0, 1000, g, foo.distance)

And this is the error I get:

NotImplementedError: Wrong number of arguments for overloaded function 'martins'.
Possible C/C++ prototypes are:
martins(int,int,MultimodalGraph &,float Edge::*)

I have an overloaded method that uses a default 4th paramaters, and it works perfectly.

So is it possible to use pointers to members with swig? If yes, what’s the trick? If no, what would be the most elegant way to work arround?

Thank you for your help!

UPDATE: if someone knows if Boost::python does it for sure, I’ll switch to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:00:03+00:00Added an answer on May 13, 2026 at 5:00 pm

    Don’t know about SWIG, but in boost::python you can write a wrapper:

    bool foo(int x, float* result);
    
    boost::python::tuple foo_wrapper(int x)
    {
        float v;
        bool result = foo(x, &v);
        return boost::python::make_tuple(result, v);
    }
    
    BOOST_PYTHON_MODULE(foomodule)
    {
        def("foo", &foo_wrapper);
    }
    

    And in python you would:

    result, v = foomodule.foo(x)
    

    Since in Python floats are immutable, you can’t actually pass one to a method and expect the method to change the float value, so we adapt the code to return a tuple of values instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help understanding some of the points from Paul Graham’s What Made
I've made a small tool that parses a chunk of text, does some simple
I have some icon resources as DrawingImage s that is made up of many
I've copied code from the blank panorama project and made some adjustments, but somewhere
Im trying to find some sample code that shows how use the WMI (
I made some little programs with Swing-components in JRuby. Now I want to convert
I made some modifications to SVG Edit which contains a make file. When I
I made some code to produce boxes every time my code encounters a white
I made some changes to an open source project without taking time to create
I made some code, for understanding the concept/basic of pointer: int a=1; int *b=&a;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.