You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<iostream>
#include<string>
#include<yorel/yomm2/cute.hpp>using std::string;
using yorel::yomm2::virtual_;
structmatrix {
virtual~matrix() {}
};
structdense_matrix : matrix {};
structdiagonal_matrix : matrix {};
register_class(matrix);
register_class(dense_matrix, matrix);
register_class(diagonal_matrix, matrix);
declare_method(string, to_json, (virtual_<matrix*>));
define_method(string, to_json, (dense_matrix* m)) {
return"json for dense matrix ptr...";
}
define_method(string, to_json, (diagonal_matrix* m)) {
return"json for diagonal matrix ptr...";
}
intmain() {
using std::cout;
using std::cerr;
yorel::yomm2::update_methods();
dense_matrix _a{};
diagonal_matrix _b{};
auto a = &_a;
auto b = &_b;
#pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"
cout << to_json(a) << "\n"; // json for dense matrix ptr
cout << to_json(b) << "\n"; // json for diagonal matrix ptrreturn0;
}
triggers compiling error
D:\yomm2\examples\matrix.cpp(40,13): warning C4068: unknown pragma [D:\yomm2\build\examples\matrix.vcxproj]
D:\yomm2\include\yorel/yomm2.hpp(961,7): error C2665: 'yorel::yomm2::detail::resolver<1,yorel::yomm2::virtual_<matrix *>>::resolve': none of the 2 overloads could convert all the argument types [D:\yomm2\build\examples\matrix.vcxproj]
D:\yomm2\include\yorel/yomm2.hpp(710,18): message : could be 'void *yorel::yomm2::detail::resolver<1,yorel::yomm2::virtual_<matrix *>>::resolve(const yorel::yomm2::detail::word *,uintptr_t,size_t,const yorel::yomm2::detail::word *,const T &)' [D:\yomm2\build\examples\matrix.vcxproj]
with
[
T=matrix *
]
D:\yomm2\include\yorel/yomm2.hpp(692,18): message : or 'void *yorel::yomm2::detail::resolver<1,yorel::yomm2::virtual_<matrix *>>::resolve(const yorel::yomm2::detail::word *,uintptr_t,size_t,yorel::yomm2::detail::word,const T &)' [D:\yomm2\build\examples\matrix.vcxproj]
with
[
T=matrix *
]
D:\yomm2\include\yorel/yomm2.hpp(959,1): message : while trying to match the argument list '(yorel::yomm2::detail::word *, uintptr_t, size_t, yorel::yomm2::detail::word, const T *)' [D:\yomm2\build\examples\matrix.vcxproj]
with
[
T=matrix
]
D:\yomm2\include\yorel/yomm2.hpp(959): message : while compiling class template member function 'void *yorel::yomm2::detail::method<_yomm2_method_to_json,std::string (yorel::yomm2::virtual_<matrix *>),yorel::yomm2::default_policy>::resolve(yorel::yomm2::policy::hash_factors_in_globals,const T *)' [D:\yomm2\build\examples\matrix.vcxproj]
with
[
T=matrix
]
D:\yomm2\include\yorel/yomm2.hpp(955): message : see reference to function template instantiation 'void *yorel::yomm2::detail::method<_yomm2_method_to_json,std::string (yorel::yomm2::virtual_<matrix *>),yorel::yomm2::default_policy>::resolve(yorel::yomm2::policy::hash_factors_in_globals,const T *)' being compiled [D:\yomm2\build\examples\matrix.vcxproj]
with
[
T=matrix
]
D:\yomm2\examples\matrix.cpp(19): message : see reference to class template instantiation 'yorel::yomm2::detail::method<_yomm2_method_to_json,std::string (yorel::yomm2::virtual_<matrix *>),yorel::yomm2::default_policy>' being compiled [D:\yomm2\build\examples\matrix.vcxproj]
With const matrix*const dense_matrix* and const diagonal_matrix* all work fine.
The text was updated successfully, but these errors were encountered:
My guess is that YOMM2 is intended for value semantics (which are preferred in general).
I will leave the explanation of the specific error to @jll63 since I still don't understand yomm well enough.
From the example it is not clear that pointer semantics are needed. Might this be a classical XY problem? Why don't you just pass a reference instead?
Not sure if I am being helpful :D
with
virtual_<matrix*>
the following code
Click to expand!
triggers compiling error
With
const matrix*
const dense_matrix*
andconst diagonal_matrix*
all work fine.The text was updated successfully, but these errors were encountered: