[C++-sig] test if object instance is instance of extension class in C++

Stefan Seefeld stefan at seefeld.name
Fri Feb 24 15:49:48 CET 2012

On 02/24/2012 09:33 AM, Holger Joukl wrote:
> bp::object itself has reference (smart pointer) semantics, so there is
> no need to pass objects by reference.
> I see. Just out of curiosity:
> If I pass by reference I do save a copy constructor call, don't I?

In principle, yes. I'm not sure how much of this the compiler would be
able to optimize away, though.

> But I circumvent the bp::object refcount safety, though(?).

Well, yes, but you don't need that as C++ language semantics ensure the
object lifetime.

> But in a type check like above this shouldn't be dangerous - right?

There is definitely no danger in doing this. It may just add a little
bit of overhead (since in certain cases passing by value is cheaper than
passing by reference, depending on the involved types and optimization



      ...ich hab' noch einen Koffer in Berlin...

More information about the Cplusplus-sig mailing list