void some_function(Foo* foo);
Adding a smart pointer means adding another line like this:
void some_function(Foo* foo){ smart_ptr<Foo> f(foo); // only use 'f' from now on}
Though it would be easier if I could write my function like this:
void some_function(smart_ptr<Foo> foo);
I have little knowledge of assembler, but I know that pointer arguments are passed on the stack (under msvc and cdecl at least). Is the same true for small objects, like a smart_ptr would be?
I imagine an implementation like:
template <typename T>class as_pointer{public: as_pointer(T* foo) : foo(foo) {} as_pointer(as_pointer<T> that) : foo(that.foo) { if(foo) foo->AddRef(); } ~as_pointer() { if(foo) foo->Release(); }private: T* foo;}
It would have the same size as a pointer (given a padding of 4 bytes).
Do you think this can work under most compilers that angelscript already supports with native calling conventions?