| 166 | // same as tryCast, but throws if fails |
| 167 | template <typename T> |
| 168 | [[nodiscard]] T cast() const |
| 169 | { |
| 170 | if(auto res = tryCast<T>()) |
| 171 | { |
| 172 | return res.value(); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | throw std::runtime_error(res.error()); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // Method to access the value by pointer. |
| 181 | // It will return nullptr, if the user try to cast it to a |