C++ STLPort 5.0.2 ,new, vector

Discussion in 'C++' started by Artur Bac, Nov 8, 2006.

  1. Artur Bac

    Artur Bac Guest

    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
    Artur Bac, Nov 8, 2006
    #1
    1. Advertising

  2. Artur Bac

    Bo Persson Guest

    Artur Bac wrote:
    > 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
    Bo Persson, Nov 8, 2006
    #2
    1. Advertising

  3. Artur Bac

    mlimber Guest

    Bo Persson wrote:
    > Artur Bac wrote:
    > > 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.


    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
    mlimber, Nov 8, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.L

    STLPort question

    A.L, Jul 24, 2003, in forum: C++
    Replies:
    1
    Views:
    390
    Dan Cernat
    Jul 24, 2003
  2. Gary
    Replies:
    1
    Views:
    622
    Christoph Rabel
    Aug 13, 2003
  3. Icosahedron
    Replies:
    4
    Views:
    328
    tom_usenet
    Aug 18, 2003
  4. John Graat
    Replies:
    0
    Views:
    587
    John Graat
    Aug 26, 2004
  5. Replies:
    8
    Views:
    1,894
    Csaba
    Feb 18, 2006
Loading...

Share This Page