Archived

This topic is now archived and is closed to further replies.

FXO

vector<primitive<> > - class question

Recommended Posts

While browsing throught FluidStudios collision detection algorithm, I found this:
  
"vector<primitive<> > &polygonList"
  
Its some kind of vector class with a specific pointertype, but Ive never seen it before (the <> stuff). And when i try to go to the definition of vector, it is located in "vector." which is not included in the source. Does anybody know how this works, how you can create a vector class and declare what kind of pointers it is to have like this? Thanks! /Fredrik Olsson Edit: the vector-line didnt show up correctly. [edited by - FXO on August 11, 2002 3:18:14 PM]

Share this post


Link to post
Share on other sites
Thanks, I have missed that completely.

Its a pity you cant typedef templates though.
Im thinking of using a #define ph_IntVec vector,
but that would be bad coding, #defines should be uppercase.
And upperchased PH_INTVEC defeats the purpose of having the type blend in with my other "ph_"-types.... maby im just to picky.

Thanks again

Share this post


Link to post
Share on other sites
quote:
Original post by FXO
Thanks, I have missed that completely.

Its a pity you cant typedef templates though.
Im thinking of using a #define ph_IntVec vector,
but that would be bad coding, #defines should be uppercase.
And upperchased PH_INTVEC defeats the purpose of having the type blend in with my other "ph_"-types.... maby im just to picky.

Thanks again



Yeah you can:

  
typedef vector<int> IntegerVector;
IntegerVector a; // a is of type vector<int>





[edited by - fallenang3l on August 11, 2002 10:25:51 PM]

Share this post


Link to post
Share on other sites
This is causing a lot of errors when i compile in debug mode:

    
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
#define new DEBUG_CLIENTBLOCK
#endif
#include <vector>


Does anybody have a clue of what can be wrong?
The errors only occur when i #include <vector>.

Errors generated:

  
octree.cpp
c:\program\microsoft visual studio\vc98\include\new(35) : error C2059: syntax error : 'constant'
c:\program\microsoft visual studio\vc98\include\new(35) : error C2091: function returns function
c:\program\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new' has no formal parameters
c:\program\microsoft visual studio\vc98\include\new(36) : error C2059: syntax error : 'constant'
c:\program\microsoft visual studio\vc98\include\new(37) : error C2091: function returns function
c:\program\microsoft visual studio\vc98\include\new(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl operator
new(void))(unsigned int)'
c:\program\microsoft visual studio\vc98\include\new(35) : see declaration of 'new'
c:\program\microsoft visual studio\vc98\include\new(41) : error C2059: syntax error : 'constant'
c:\program\microsoft visual studio\vc98\include\new(42) : error C2091: function returns function
c:\program\microsoft visual studio\vc98\include\new(42) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,void *)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl operator new(void))(unsigned in
t)'
c:\program\microsoft visual studio\vc98\include\new(35) : see declaration of 'new'
c:\program\microsoft visual studio\vc98\include\new(42) : error C2809: 'operator new' has no formal parameters
c:\program\microsoft visual studio\vc98\include\new(42) : error C2065: '_P' : undeclared identifier
c:\program\microsoft visual studio\vc98\include\memory(16) : error C2059: syntax error : 'constant'
c:\program\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function
c:\program\microsoft visual studio\vc98\include\memory(17) : error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' : could not deduce template argument for 'void *(__cdecl *)(unsigne
d int,class std::allocator<_Ty> &)' from 'void *(__cdecl *)(unsigned int)'
c:\program\microsoft visual studio\vc98\include\memory(17) : error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' and 'void *(__cdecl *__cdecl operator new(void))(unsigned int)' hav
e different return types
c:\program\microsoft visual studio\vc98\include\memory(16) : see declaration of 'new'
c:\program\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' has no formal parameters
c:\program\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest
Error executing cl.exe.


[edited by - FXO on August 11, 2002 11:52:53 PM]

Share this post


Link to post
Share on other sites
I don`t know if that is the problem.. but VC6 have some strange problems in using templates + precompiled headers. Disable precompiled headers.

If brute force does not solve your problem....you''re not using enough!

Share this post


Link to post
Share on other sites
Trying to redefine new when using the standard library is a bit trouble-prone, mainly because it tends to redefine new too and things get mixed up. Firstly, try simply recompiling - sometimes when I get this error, it goes away if I just recompile the file. Illogical, but true. If that''s no good, try putting the #define after the #include, although it won''t catch the allocations in the library that way. It''s a shame that the whole debug new thing doesn''t work as documented.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites