I am getting the following warning: warning: returning reference to temporary…
Jump to turn (6)
- 1I am getting the following warning: warning: returning reference to temporary [-
- 2Got it, in these lines: const std::unorderedmap > &getPaytable() const override
- 3This function is inside a class called Configuration, that inherits from IConfig
- 4Variable paytable must be public or can be private?
- 5Ok, I will keep it private. I am getting the following error: Config.cpp:4:72: e
- 6Coming back to the first warning, now also SonarLint is giving a warning: Addres
- User
I am getting the following warning: warning: returning reference to temporary [-Wreturn-local-addr] 59 | return reels; The definitions are these ones: using Reels = std::vector<std::vector>; using ReelsSet = std::vector<std::vector<std::vector>>;
using ReelsType = std::variant<Reels, ReelsSet>; And the relevant code this one: const ReelsType &getReels(const std::string &stateName) const override { if (stateName == "BaseState") { static const Reels reels = { // Populate with your specific reel symbols data {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}; return reels; } else if (stateName == "FreespinState") { static const Reels reels = { // Populate with your specific reel symbols data {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}; return reels; } else throw std::invalid_argument("State not defined"); } Any ideas about how to fix it?