Basically I have function that generates SFML object from LevelObject (template). i.e
void draw(LevelObject obj, sf::RenderWindow &window) {
if(obj.type == RECTANGLE) {
sf::RectangleShape rect(obj.width, obj.height);
window.draw(rect);
} // other types
}
So now I'd like to return generated sfml object, for future export object properties to file, and later load them. Also later I'd like to create vector that will contain all loaded objects from file, but the same problem remains. What vector type should I have? I tried std::variant:
using ExportableSFMLObject = std::variant<sf::RectangleShape, sf::CircleShape, sf::Text, sf::Sprite, int>;
ExportableSFMLObject function(...) { ... }
But then I couldn't figure out exactly what type function returns, maybe it's RectangleShape, or sf::CircleShape. Even if I could resolve what type function returns, function GetType, where'd I'd like to realize type resolving, is also doesn't have exact type to return.