billyquith/ponder

Support for std::shared_ptr arguments

jgehring opened this issue · 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'
return ponder_ext::ValueMapper::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 >::operator()' requested
here
return f(unwrapper::apply_const(v.template get_unchecked()));
[...]

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

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).

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.