pybind / pybind/pybind11

How to call into protected constructors?

Open
#1,173 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

class A
{}

template < typename T >
class B : public A
{

protected:
B():A(...)
.
.
.
}

My classes are templated.. and i am using this https://developer.lsst.io/coding/python_wrappers_for_cpp_with_pybind11.html as a reference to wrap my C++ code.
New to pybind, so any help appreciated :)

Compilation error:
error: ‘namespace_x::namespace_y::B< T > ::B() [with T = float]’ is protected

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the protected B() constructor shown in the issue and the referenced pybind11 wrapper guide. Reproduce the reported compilation error for B, then determine how constructor access is intended to work in this binding context. Done means documenting or demonstrating a valid way to expose the templated class without the protected-constructor error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.