Jump to content
  • Advertisement

Slavik81

Member
  • Content Count

    153
  • Joined

  • Last visited

Community Reputation

360 Neutral

About Slavik81

  • Rank
    Member
  1. Why is it difficult to create a completely new, independent class in Java? Personally, I think you'd be better off making it simpler to create new classes than developing techniques to work around how troublesome it is.
  2. Yoda conditionals are a particular annoyance to me. They're less readable, and are not very useful if you write good tests. More dangerous is accidentally forgetting to break at the end of a case in a switch. It's rare to test for things that you don't do, so a case that falls through and does something extra might not be caught.
  3. FYI Visual c++ 2012 does not issue a warning about this with /wall (and 'language extensions' disabled fwiw). I know gcc does, and I agree that it's a useful warning. [/quote] Yeah, msvc is the only compiler I know of that doesn't support that warning. For gcc, clang and intel, the flag is -Wreorder. You could vote for it if you want Microsoft to add it.
  4. Slavik81

    SFINAE equivalent in C#?

    That would be a reasonable solution if it did not have such a dramatic impact on compilation time, and if it did not require major workarounds to apply to virtual functions. There are definite advantages to the restrictions C# imposes on its generics.
  5. Slavik81

    SFINAE equivalent in C#?

    I could expect it, given that the two objects should have both identical code and data, and one has an interface that is a subset of the other. The fact that it's so difficult to use one in place of the other is just a limitation imposed by poor design choices in the C++ template system. If it C++ disallowed atrocities like this, the types would be compatible: struct MyObject{}; template<class T> struct MyTemplateClass { T x; }; template<> struct MyTemplateClass<const MyObject*>{}; int main() { MyObject obj; MyTemplateClass<MyObject*> i1; i1.x= &obj; MyTemplateClass<const MyObject*> i2; i2.x= &obj; // compile error } Reading through stuff about C# generics, it seems that they maintain restrictions to prevent that sort of thing.
  6. I was typing a response that involved C++ template syntax in a code block, and discovered when I posted that the &lt; and &gt; symbols (and everything between them) had all been removed. I discovered that you could use escape codes to cause the characters to appear correctly and edited those into my post. Unfortunately, hitting 'preview post' replaces escaped characters with unescaped characters. Thus, hitting 'preview post' twice in a row will result in two different-looking previews, as the second time the now-unescaped characters will be removed. 'preview post' changing what your post will look like upon submit is most certainly a bug. Could you just automatically replace symbols like &lt; with their escape sequences upon submit? I think the entire rest of your system would work well enough with just that. And it doesn't do anything a user couldn't do themselves, so it could not possibly be a security issue.
  7. Slavik81

    SFINAE equivalent in C#?

    There's a number of aspects of C++ templates that bug me. Stuff like this in particular: [source lang="cpp"]void function(const std::vector&lt;Objects*&gt;&){} void constFunction(const std::vector&lt;const Objects*&gt;&){} std::vector&lt;Objects*&gt; objectList; function(objectList); constFunction(objectList); // compile error[/source] Do C# generics let you do that sort of stuff easily?
  8. Slavik81

    #pragma once

    I would use #pragma once because it's simpler and leaves less room for programmer error. It is supported across all major compilers (gcc, msvc, clang, intel...). In the event that you discover that you need to support an old compiler, you can run a script such as this one to replace #pragma once with include guards. I've only once encountered a header file in which I wouldn't want to include #pragma once. By default, you should be doing it for every header file.
  9. That's not really all that fundamentally different. The difference between sorting by key and sorting by value is simply that in the latter case, your key is a part of your value. The former is a more general case of the latter. Hence why you see things like QSet (value only) being implemented using a QHash (key value pair). The source is literally: template <class T> class QSet { typedef QHash<T, QHashDummyValue> Hash; ///... private: Hash q_hash; }; QHash then relies on some specializations in choosing the node type to save memory, but even if it didn't the worst that could happen is that you'd use a little more memory to store each object. If that saved the developer the time of building and maintaining a completely new data structure with the desired performance characteristics, and if you had memory to spare, then nothing of value was lost. There are other differences between multimap and priority_queue, but the fact that one is key/value and the other is value-only is not enough to say that one would be a natural fit and that the other would not. I think the expected read and write patterns are far more important.
  10. Slavik81

    Overusing smart pointers?

    Assuming the pointer must not be null, is there any reason to use pointer.get() over &*pointer? I've been using the latter as it works for pretty much any pointer-like type (raw pointers, boost smart pointers, qt smart pointers).
  11. Slavik81

    Streaming Development Buy or Write

    On the "buy" vs. "build" evaluation, this would sound like a no-brainer "buy" to me. You have no special requirements whatsoever. Heck, you could use something like livestream and get everything for free.
  12. To use other build systems, all you need to do is run the moc over each class that declares signals or slots. Compile and link each of the moc's output files into the same library as the input file. There is no requirement even to use qmake.
  13. That depends on how you acquire the data and what you're going to use it for. Whatever the case, the velocity will need to be adjusted each time the position changes (assuming you're travelling around a sphere). What sort of game is it? It's much harder to do things like line-of-sight or shortest path checks with spherical coordinates. The poles in particular are very annoying.
  14. What's workingState initialized to? Make sure it's either NULL or a valid state if you're going to be deleting it on the first state change.
  15. I've only begun to use scripting, but the biggest thing it seems to be useful for (to me) is tweaking user-interface elements. By defining user interactions functions in a script, I can quickly evaluate the impact of UI changes on the fly without leaving my program. An example of this would be controlling the zoom levels of a map. You're never going to figure out the ideal parameters without using it, and you might not even know what the basic structure of the function should look like (polynomial, exponential, bounded?).
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!