C++ STLPort 5.0.2 ,new, vector

A

Artur Bac

I got a problem with eVc4 i STLPort and i dont known why

c:\stlport-5.0.2\stlport\stl\_construct.h(115) : error C2665: 'new' :
none of
the 2 overloads can convert parameter 2 from type 'struct
ns::CPointT<short> *'
c:\stlport-5.0.2\stlport\stl\_vector.h(351) : see reference to
function
template instantiation 'void __cdecl stlp_std::_Copy_Construct(struct
ns::CPointT<short> *,const struct ns::CPointT<short> &)' being compiled


#include <vector>
#include <algorithm>

template <class T>
struct CPointT {
T x;
T y;
CPointT(){};
CPointT( T p_x, T p_y) : x(p_x), y(p_y) {};
};

typedef CPointT<SHORT> CPoint16;

std::vector<CPoint16> punkty;
vector<CPoint16> v1;
CPoint16 a(1,0);
v1.insert(v1.end(),a);

I dig into the STLPort and it fail on that
-----------------------------------------
#define _STLP_PLACEMENT_NEW new
...
template <class _Tp>
inline void _Copy_Construct(_Tp* __p, const _Tp& __val) {
_STLP_PLACEMENT_NEW (__p) _Tp(__val);
}

help
 
B

Bo Persson

Artur said:
I got a problem with eVc4 i STLPort and i dont known why

c:\stlport-5.0.2\stlport\stl\_construct.h(115) : error C2665: 'new'
: none of
the 2 overloads can convert parameter 2 from type 'struct
ns::CPointT<short> *'
c:\stlport-5.0.2\stlport\stl\_vector.h(351) : see reference to
function
template instantiation 'void __cdecl
stlp_std::_Copy_Construct(struct ns::CPointT<short> *,const struct
ns::CPointT<short> &)' being compiled

#include <vector>
#include <algorithm>

template <class T>
struct CPointT {
T x;
T y;
CPointT(){};
CPointT( T p_x, T p_y) : x(p_x), y(p_y) {};
};

typedef CPointT<SHORT> CPoint16;

std::vector<CPoint16> punkty;
vector<CPoint16> v1;
CPoint16 a(1,0);
v1.insert(v1.end(),a);

I dig into the STLPort and it fail on that
-----------------------------------------
#define _STLP_PLACEMENT_NEW new
..
template <class _Tp>
inline void _Copy_Construct(_Tp* __p, const _Tp& __val) {
_STLP_PLACEMENT_NEW (__p) _Tp(__val);
}

help

You have written two constructors for CPointT, none of which is a copy
constructor. That means the struct cannot be copied.


Bo Persson
 
M

mlimber

Bo said:
You have written two constructors for CPointT, none of which is a copy
constructor. That means the struct cannot be copied.

No, the compiler should generate a copy constructor automatically. I
tried this code (replacing SHORT with short) on Comeau and Dinkumware's
tests, and it compiled fine. I'd guess it's a problem with STLport.

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top