How to provide function json& to_json() which is similar as 'void to_json(json&j, const CObject& obj)' ? #1650
Labels
kind: question
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Describe what you want to achieve.
I've deifned functions to_json for user defined classes, i.e.
class foo
{
friend inline void to_json(json& j, const foo& obj) {...}.
}
These code work well.
But I wonder if we can define the function like 'json& to_json(void) {...}' as a memeber function in the class foo?
The purpose for this function is that I want to use virtual function of basic class, and all derived classes can automatic define their reload funtion such as 'cout << to_json() << endl';
If can, how to define this function?
Describe what you tried.
Describe which system (OS, compiler) you are using.
Ubuntu 18.04 LTS, g++ 7.3;
Describe which version of the library you are using (release version, develop branch).
the master version.
The text was updated successfully, but these errors were encountered: