From c1f1eee58bc8d0907e3cb0c4f988725007a9f1da Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 9 Feb 2025 21:32:49 -0500 Subject: [PATCH] Actually this works, so...yeah why don't they just do this? --- sfml-const/fix2.cpp | 6 +++--- sfml-const/fix2.hpp | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sfml-const/fix2.cpp b/sfml-const/fix2.cpp index 3faf153..34a4ddd 100644 --- a/sfml-const/fix2.cpp +++ b/sfml-const/fix2.cpp @@ -11,8 +11,8 @@ void Shape::draw(RenderTarget& target) const { cout << "shape draw\n"; } -void Shape::render_to(RenderTarget &target) { - cout << "shape render_to instead\n"; +void Shape::draw(RenderTarget &target) { + cout << "shape non-const instead\n"; } int main() { @@ -21,6 +21,6 @@ int main() { target.draw(shape); - shape.render_to(target); + shape.draw(target); return 0; } diff --git a/sfml-const/fix2.hpp b/sfml-const/fix2.hpp index 75581d1..14c09a5 100644 --- a/sfml-const/fix2.hpp +++ b/sfml-const/fix2.hpp @@ -13,15 +13,16 @@ class Drawable { * NOTE: This requires const because RenderTarget * pass itself in as a *this which is always const. * If you need to draw without const then invert it - * then use shape.render_to(target) instead. + * then use shape.draw(target) instead, which is + * not const. */ virtual void draw(RenderTarget& target) const = 0; - virtual void render_to(RenderTarget& target) = 0; + virtual void draw(RenderTarget& target) = 0; }; class Shape : public Drawable { public: void draw(RenderTarget& target) const override; - void render_to(RenderTarget &target) override; + void draw(RenderTarget& target) override; };