ponder icon indicating copy to clipboard operation
ponder copied to clipboard

Support for std::shared_ptr arguments

Open jgehring opened this issue 7 years ago • 2 comments

I've been trying to declare constructors and functions that take std::shared_ptr<U> argument, where U is a type that has been previously declared via ponder::Class::declare<U>. A small example test case is here. However, I'm running into template issues like the following:

In file included from test_ponder.cpp:2: In file included from /usr/local/include/ponder/class.hpp:37: In file included from /usr/local/include/ponder/property.hpp:35: In file included from /usr/local/include/ponder/tagholder.hpp:36: In file included from /usr/local/include/ponder/value.hpp:38: /usr/local/include/ponder/detail/valueimpl.hpp:53:16: error: no viable conversion from returned value of type 'Test1' to function return type 'std::__1::shared_ptr<Test1>' return ponder_ext::ValueMapper<T>::from(value); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/ponder/detail/variant.hpp:316:20: note: in instantiation of function template specialization 'ponder::detail::ConvertVisitor<std::__1::shared_ptr<Test1> >::operator()' requested here return f(unwrapper<T>::apply_const(v.template get_unchecked<T>())); [...]

I'm wondering whether I'm doing something wrong or whether there's missing support for smart pointer arguments.

jgehring avatar Mar 22 '17 22:03 jgehring

I think this is probably a problem with Ponder not supporting smart pointers. Related to #41.

I'd suggest just using normal ones until I get round to looking at this (which may not be soon as I have little spare time at the moment).

billyquith avatar Mar 23 '17 09:03 billyquith

Ok, thanks! I think the issue is that the ValueMapper trait for smart pointers simply forwards the underlying type. I'd guess that the from functions would need to be reimplemented, but without further knowledge of ponder's internals I'm not sure what the right way to do this would be.

jgehring avatar Mar 23 '17 12:03 jgehring