Jump to content
  • Advertisement

snooty

Member
  • Content Count

    139
  • Joined

  • Last visited

Community Reputation

122 Neutral

About snooty

  • Rank
    Member
  1. snooty

    c++ templates...

    Quote:Original post by Shinkage Even with this description, I'm a little confused at what isn't working here. Why can't you make the generic declaration inline with the class declaration and have explicit specializations outside the class declaration like above? It compiles fine that way for me, like so: *** Source Snippet Removed *** Judging by your description I can only imagine that's what you're trying to do in the end, and on VS2010 what I have above compiles just fine. If that's not what's supposed to be going on in your real code, then I dunno :) Ah!!! A solution finally. I'm so used to defining functions outside the class declarations that this method never occurred to me. Although I believe this method clusters the class terribly (when the functions are non-trivial), at least it works. [smile] Quote:Original post by Shinkage Also, you might want to look into the Adobe Generic Image Library for some ideas. They have a pretty solid implementation of just what you seem to be working at, although theirs is almost certainly overkill for game-related uses. I thought GIL was dead. Its last update was 3 years old... [dead]
  2. snooty

    c++ templates...

    Quote:Original post by Antheus Quote:Original post by snooty Unfortunately, reordering of the lines doesn't solve the problem in reality because this is a simplified example I use here; the real code is more complicated and no reordering solves it. So what you are posting here is completely unrelated to the actual problem? Of course it is related. [tears]
  3. snooty

    c++ templates...

    Quote:Original post by phresnel g++ will accept this code. But, even though I haven't looked in the standard for deep explanations here, notice that in template<> template<enum A<int>::e> void A<int>::test1() {} the enum keyword is redundant, at least. You only need to disambiguate between types and non-types, and because A<>::e is not a type, no extra keyword is needed. Possibly your compiler was causing trouble because of this? Removing it doesn't compile neither. [tears]
  4. snooty

    c++ templates...

    Quote:Original post by Zahlman ... umm... so out of curiousity... just what the hell kind of problem are you trying to solve here? Or is this just an acid test for compilers? :) I'm trying to make an image handling application that can handle different color types (eg. rgb888, rgb565, etc), while using templates to allow code re-use. This problem is just the result of one of the designs I have; the syntax is compliant to the cpp standards AFAIK, so I expected it to work. Anyway I'm using another design now, so everything is still good for me. Just discovered a compiler bug though. [smile] Thanks for the help.
  5. snooty

    c++ templates...

    Quote:Original post by the_edd Quote:Original post by snooty 3. Tried it with MinGW. It won't compile either. Now I'm starting to think whether using enum as template parameters is legal at all. Trying to consult c++ references now... Compiles fine on MinGW for me (version 4.4). Fails in the same way on Visual C++ 2008. I can confirm Shinkage's workaround works there, though. I'd tentatively suggest it's a compiler bug, though I'd wait for a few more responses before giving in to that temptation :) I don't know why my MinGW doesn't work, but I'm not familiar with MinGW anyway. [totally]
  6. snooty

    c++ templates...

    Quote:Original post by Shinkage Try putting the //line2 line before the //line1 line. Thanks. Unfortunately, reordering of the lines doesn't solve the problem in reality because this is a simplified example I use here; the real code is more complicated and no reordering solves it.
  7. snooty

    c++ templates...

    @wicked357 Thank you for helping. The more I look at it, the more it seems to be a compiler bug. I don't have VS2008 though so I can't try.
  8. Hi. I tried to compile the following with VS2010: template<typename T> struct A { enum e { e1, e2 }; template<e> void test1(); template<e> void test2(); }; template<> template<enum A<int>::e> void A<int>::test1() {} template<> template<enum A<char>::e> void A<char>::test1() {} //line 1 template<> template<enum A<int>::e> void A<int>::test2() {} //line 2 but it gave this error: error C2244: 'A<T>::test2' : unable to match function definition to an existing declaration with [ T=int ] definition 'void A<T>::test2(void)' with [ T=int ] existing declarations 'void A<T>::test2(void)' with [ T=int ] What have I done wrong? [depressed] Further discoveries: 1. If either line 1 or line 2 is removed, it compiles fine. Strange... 2. If I replace the enum with intrinsic types (eg. int, bool, etc) it compiles fines. It seems VS2010 can't handle enum as template parameters in this way??? 3. Tried it with MinGW. It won't compile either. Now I'm starting to think whether using enum as template parameters is legal at all. Trying to consult c++ references now... ...Turns out it should be legal. [Edited by - snooty on August 3, 2010 1:14:14 AM]
  9. Hi, Here says for exception to work, it needs RTTI. But my projects (VS2005, PPC2003) has RTTI disabled and can still use exception everywhere. What is going on?
  10. Nevermind. I was confusing it with something else. Sorry.
  11. Hi, boost says event variables are unsafe. Why? And what is the safe substitute for it? Thanks.
  12. snooty

    pixel center

    Quote:Original post by jpetrie Yes. But the entire D3D10 API break backwards compatibility. And having a direct mapping now is so much nicer to work with. Direct mapping is better? How come?
  13. snooty

    multiprocessor

    Thanks. Now I know where to look.
  14. snooty

    pixel center

    Thanks for the replies. Quote:Original post by Sc4Freak I think that has changed in Direct3D10. (0,0) maps to the center of the top-left pixel now. Doesn't this break backward compatibility?
  15. snooty

    pixel center

    Thanks. Another question: Do DirectX and OpenGL map (0, 0) to the lower-left or upper-left of a surface by default?
  • 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!