Comments (6)
I think it's possible to fix this by casting away const, i.e. change lines 98-100 in Layer.hpp to
template <typename T>
const T& getLayerAs() const {
return const_cast<Layer*>(this)->getLayerAs<T>();
}
but would appreciate an expert opinion on that!
from tmxlite.
Interesting const_cast
- I think the more correct way to fix it would be to create const overloads for each of the specialisations? If I happen to find an expert I'll ask them
from tmxlite.
Certainly would be do-able to create const overloads for each of the specialisations, if a little tedious. How about if it were swapped around - the specialisations are all for the const version? Then the non-const overload would cast to const (should always be safe), cast to the subclass, and then cast back to non-const (should also be safe because we know, within that same function, the pointer was to a non-const object in the first place)
from tmxlite.
To be honest I'd prefer to do the work (it only has to be done once to be included in the library anyway) if it means the intended behaviour is explicit. After all it was my assumption based on implicit behaviour that all compilers would pick the correct specialisation which caused the bug in the first place
from tmxlite.
That certainly solved the problem I was having,
from tmxlite.
Good enough, thanks!
from tmxlite.
Related Issues (20)
- Error during build HOT 12
- Minimal working example for SFML? HOT 1
- Compiler error on SFMLOrthogonalLayer.hpp HOT 4
- Get Object from inside Tile element HOT 1
- SFMLOrthogonolLayer.hpp Update() Animation Error HOT 4
- Tilesets not loading tiles HOT 5
- Can't find package when installing using vcpkg HOT 1
- CAN SOMEONE JUST EXPLAIN HOW TO USE THIS HOT 9
- Problem with "std::localtime" in Log.hpp line 145 HOT 1
- meson.build version doesn't match git tags HOT 1
- Enough with the unsigned integers
- Find tmxlite on Windows HOT 4
- Feature Request: Allow independent parse of tsx to TileMap. HOT 2
- How hard would it be to adapt the library to render an isometric map? HOT 2
- Add improved file loading API (feedback wanted)
- Parse object types file
- New properties constructor + property map HOT 5
- tmx::TileSet::HasTransparency() HOT 1
- Allow to use external miniz & pugixml HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tmxlite.