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 6836799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:23:59+00:00 2026-05-26T23:23:59+00:00

I was wondering if any one here might be able to help me out

  • 0

I was wondering if any one here might be able to help me out with the following problem I’m having.

I seem unable to create a boost::python::object from a c++ class I’ve bound to python that is noncopyable. Here is a simplified example..

#include <boost/python.hpp>

class A
{
public:
    static A*
    create() {return new A;}

protected:
    A(){}
};

void
doSomething(const A& a)
{
    boost::python::object obj(a);
}

BOOST_PYTHON_MODULE(test)
{
    boost::python::class_<A, boost::noncopyable>("A", boost::python::no_init)
    .def("__init__", boost::python::make_constructor(&A::create));

    boost::python::def("doSomething", &doSomething);
}

Then at runtime in python

import test
a = test.A()
test.doSomething(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: No to_python (by-value) converter found for C++ type: A

I realise that the boost::noncopyable parameter prevents a to_python converter for A being registered. Does anyone know how I might be able to create a boost::python::object from an A instance ?

thanks in advance!

  • 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-26T23:24:00+00:00Added an answer on May 26, 2026 at 11:24 pm

    Use this

    boost::python::object obj(**boost::cref(a)**);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if any one could help me out; I have a table
I was just wondering if any one knows of a good script to emulate
i was wondering if any one can advise me on how i can go
I'm wondering if any one knows of a JS function to convert a json
I was wondering if any one knows how memory is handled with JS arrays
I was just wondering if any one knew of any good beginner tutorials for
I am having trouble with my game and was wondering if anyone can help?
I know I can get answers here but I was wondering if anyone knows
Frequent visitor but first post here on StackOverflow, I'm hoping that you guys might
I'm wondering how one would implement an outline view like the one Xcode 3

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.