Skip to content

[C++] Make C++ headers accept pointers and shared pointers alike #134

@alexanderoster

Description

@alexanderoster

The idea is to introduce a templated class into the C++ headers that looks similar to this code:

private:
   const T* m_ptr;

public:	
   classParam(const T* ptr)
      : m_ptr (ptr)
   {	}	

   classParam(std::shared_ptr <T> sharedptr)
   : m_ptr(sharedptr.get())
   {	}	
   
   LibXXXSDKHandle GetHandle()
   {
    if (m_ptr != nullptr)
	 return m_ptr->GetHandle();		
    return nullptr;
  }
};

This would allow to make method calls with class instances a lot cleaner and script-like, for example

objectA->Method (objectB, objectC, 5);

instead of

objectA->Method (objectB.get(), objectC.get(), 5);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions