move copy constructor for json_data
Summary:
As json_data is being used in CmdStan, it does this:
stan::json::json_data d(stream);
stream.close();
std::shared_ptr<stan::io::var_context> result
= std::make_shared<stan::json::json_data>(d);
return result;
The class json_data is a subclass of var_context. It does not define a copy constructor, so the default copy constructor will be invoked by that call to make_shared (which constructs an object and returns a shared pointer to it that encapsulates the memory management). That means a deep copy of all the data. That means all the data sits in memory twice while this block is executing.
To solve this problem, we need to define move semantics so that the returned object constructed in the shared pointer can steal the data from the local object.
I'm not sure how to test this as we want to make sure we reduce total dynamic memory overhead requirements.
Current Version:
v2.19.1
Transferring to cmdstan, this is where json_data code lives now.