ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcDbObject derived class in a vector container

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
246 Views, 6 Replies

AcDbObject derived class in a vector container

i am currently developing a custom dbr object. in the application of this
object i have to place in in an stl vector container but at compile time it
spits out an error every time i try to use the vector::push_back() function.

the error reads something to the effect new operator does not take 2
paramiters.

i need to know what a quick and easy fix would be.
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Can you show us the context of the problem. Without knowing your
intentions, I would recommend using AcDbObjectId's in your vector.

|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
| Autodesk Registered Developer
| email: byron@cadwerx.net
| web site: http://www.cadwerx.net
|

"Justus" wrote in message
news:BDFF1B0DDA6E96EE6A9071D28AF9635D@in.WebX.maYIadrTaRb...
> i am currently developing a custom dbr object. in the application of this
> object i have to place in in an stl vector container but at compile time
it
> spits out an error every time i try to use the vector::push_back()
function.
>
> the error reads something to the effect new operator does not take 2
> paramiters.
>
> i need to know what a quick and easy fix would be.
>
>
Message 3 of 7
Anonymous
in reply to: Anonymous

class myClass : AcDbObject {
//...
};

//...
void main() {
std::vector myClassVector;
myClass stuff;

myClassVector.push_back(stuff); // causes error
}

the error is generated when the Allocator object calls the new funtion to
store myClass. the error reads new does not take 2 paramiters.

myClass has all nessisary functions to work in stl containers(copy
constructor, comairison, assignment, ect.)
Message 4 of 7
Anonymous
in reply to: Anonymous

Is myClass derived from AcDbObject or AcDbEntity? If so then you should use
myClass pointers or AcDbObjectId's in your container.

If not, are you getting a complier error or a crash when push_back() is
reached. The error you indicate is a compiler error which suggests that
your copy constructor is not properly implemented. Since the allocator
creates another copy of the object, you are also doubling your memory
allocation/free cycle. Wouldn't it be better to create it on the heap (via
new) and delete it at the appropriate time?

|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
| Autodesk Registered Developer
| email: byron@cadwerx.net
| web site: http://www.cadwerx.net
|

"Justus" wrote in message
news:5B2F0DB37CF79F0639B2279FEE31A73B@in.WebX.maYIadrTaRb...
> class myClass : AcDbObject {
> //...
> };
>
> //...
> void main() {
> std::vector myClassVector;
> myClass stuff;
>
> myClassVector.push_back(stuff); // causes error
> }
>
> the error is generated when the Allocator object calls the new funtion to
> store myClass. the error reads new does not take 2 paramiters.
>
> myClass has all nessisary functions to work in stl containers(copy
> constructor, comairison, assignment, ect.)
>
>
>
>
Message 5 of 7
Anonymous
in reply to: Anonymous

Make sure that your header files are being compiled in release mode, i.e.
when you include MFC/CRT/STL headers make sure that the appropriate
preprocessor symbols are defined e.g. _DEBUG is not defined.

Joel

"Justus" wrote in message
news:BDFF1B0DDA6E96EE6A9071D28AF9635D@in.WebX.maYIadrTaRb...
> i am currently developing a custom dbr object. in the application of this
> object i have to place in in an stl vector container but at compile time
it
> spits out an error every time i try to use the vector::push_back()
function.
>
> the error reads something to the effect new operator does not take 2
> paramiters.
>
> i need to know what a quick and easy fix would be.
>
>
Message 6 of 7
Anonymous
in reply to: Anonymous

even with a release build the comiler complains that there is a problem when
ever i use vector::push_back(). more specifically when the allocator object
of vector calls the new fuction here

template inline
void _Construct(_T1 _FARQ *_P, const _T2& _V)
{new ((void _FARQ *)_P) _T1(_V); }

i think i need to make an new new operator that is compatible with this call
but dont know how.

"Joel Matthias" wrote in message
news:349161E76116F92F5C8ABA3E51B13BD8@in.WebX.maYIadrTaRb...
> Make sure that your header files are being compiled in release mode, i.e.
> when you include MFC/CRT/STL headers make sure that the appropriate
> preprocessor symbols are defined e.g. _DEBUG is not defined.
>
> Joel
>
> "Justus" wrote in message
> news:BDFF1B0DDA6E96EE6A9071D28AF9635D@in.WebX.maYIadrTaRb...
> > i am currently developing a custom dbr object. in the application of
this
> > object i have to place in in an stl vector container but at compile time
> it
> > spits out an error every time i try to use the vector::push_back()
> function.
> >
> > the error reads something to the effect new operator does not take 2
> > paramiters.
> >
> > i need to know what a quick and easy fix would be.
> >
> >
>
>
Message 7 of 7
Anonymous
in reply to: Anonymous

myClass is derived from AcDbObject as stated above.

the error occurs when ever i call vector::push_back() because push_back() in
turn uses the new opperator to create space to store the object in the
vector.

template inline
void _Construct(_T1 _FARQ *_P, const _T2& _V)
{new ((void _FARQ *)_P) _T1(_V); }

the above is the function called in the push_back function that causes the
error.

C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(34) : error
C2660: 'new' : function does not take 2 parameters
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(66) :
see reference to function template instantiation 'void __cdecl
std::_Construct(class ar3dLayerProfile *,const class ar3dLayerProfile &)'
being compiled

so I think i need to write a custom new function to work with stl but i dont
know how to do this or even what the types it is asking for are.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost