cpluspluscom / ChessPlusPlus

cplusplus.com Community Project: Modular Chess with support for more types of pieces than traditional Chess
https://cpluspluscom.GitHub.IO/ChessPlusPlus/
35 stars 26 forks source link

Unable to access newly constructed AppStates #95

Open LB-- opened 9 years ago

LB-- commented 9 years ago

Application::changeState() should return a reference to the new AppState instance so that calling code can interact with it beyond passing constructor arguments.

Additionally, something should be done about the destruction of the old AppState object inside the call - generally an AppState will be making the call to changeState() and will thus be destructing itself. This is dangerous even if documented.

I'm thinking of returning both the old and the new in a std::pair<std::unique_ptr<AppState>, std::reference_wrapper<NewState>> or making a simple custom struct to label them previous and current.