Open Weeena opened 7 years ago
The example is from the CAMP code. I haven't used/tested it. I've created an "example inserter" for the docs, so that the examples get compiled to check they work, but clearly I haven't moved this one.
CAMP used std::string
for everything. I changed this to Id
and IdRef
for more efficient passing of string references. I did search and replace for const std::string&
, but in some places we want to reference the value type not the reference type (e.g. when returning names).
If you change ponder::IdRef
to const std::string&
I think it should work.
Unfortunately, then I get a PONDER_TYPE_NOT_REGISTERED
error:
detail\typeid.hpp(52): error C2039: 'PONDER_TYPE_NOT_REGISTERED': is not a member of 'ponder::NoType'
But maybe that's a different story?
Well it's looking for '(const ponder::String)'
so maybe try that. (I haven't used this feature)
Unfortunately, it makes no difference. As usual with templates, the comile error is rather lengthy, the topmost part is:
\detail\typeid.hpp(52): error C2039: 'PONDER_TYPE_NOT_REGISTERED': is not a member of 'ponder::NoType'
\ponder\type.hpp(43): note: see declaration of 'ponder::NoType'
\ponder\detail\typeid.hpp(49): note: while compiling class template member function 'const char *ponder::detail::StaticTypeId<ponder::NoType>::get(bool)'
\ponder\detail\typeid.hpp(78): note: see reference to function template instantiation 'const char *ponder::detail::StaticTypeId<ponder::NoType>::get(bool)' being compiled
\ponder\detail\typeid.hpp(78): note: see reference to class template instantiation 'ponder::detail::StaticTypeId<ponder::NoType>' being compiled
\ponder\detail\typeid.hpp(125): note: see reference to function template instantiation 'const char *ponder::detail::staticTypeId<T>(void)' being compiled
with
[
T=ponder::NoType
]
Again, could that be a different story that does not anymore has to do with string?
BTW, I thought I try something out with a ValueVisitor. Since a fix seems not so clear, I am currently reworking my code to use an old-fashioned switch statement.
Well it looks like an uninitialised Value may have been passed to the visitor.
I tried to iterate over the properties of a UserObject
in the following way:
const ponder::Class& metaClass = obj.getClass();
for (auto&& iter : metaClass.propertyIterator())
{
const ponder::Property& property = *iter.value().get();
ponder::Value val = property.get(obj);
val.visit(visitor);
}
It seems that (at least in my environment = VS2015) your ValueVisitor example leads to a compile error. I had problems with my own ValueVisitor, so I tried to reproduce your ValueVisitor example to see if the behaviour is the same. It looks as if that would be the case.
When I compile your ValueVisitor example (which can be found here: ValueVisitor example) I get the following compiler error:
It seems that the compiler does not know which of the operators to call if the Value is a string.
Am I doing something wrong?