Re: std::map ,errors and warnings when declaring

Discussion in 'C++' started by John Harrison, Aug 24, 2003.

  1. "Christopher" <> wrote in message
    news:Xa92b.22912$...
    > I am getting strange warnings when declaring an std::map. I pretty much
    > imitated the example in the msdn docs, so I don't know what is causing it.
    > Any ideas?
    >
    > Here is the debug output:
    > server.cpp(20) : warning C4786:
    > 'std::reverse_bidirectional_iterator<std::_Tree<unsigned
    > int,std::pair<unsigned int const ,Player>,std::map<unsigned
    > int,Player,std::less<unsigned int>,std::allocator<Player>
    > >::_Kfn,std::less<unsigned int>,std::allocator<Player>
    > >::iterator,std::pair<unsigned int const ,Player>,std::pair<unsigned int

    > const ,Player> &,std::pair<unsigned int const ,Player> *,int>' :

    identifier
    > was truncated to '255' characters in the debug information
    >
    > c:\programming\vc98\include\utility(21) : error C2558: class 'Player' : no
    > copy constructor available c:\programming\vc98\include\utility(21) : while
    > compiling class-template member function '__thiscall std::pair<unsigned

    int
    > const ,class Player>::std::pair<unsigned int const ,class Player>(const
    > unsigned int &,const class Player &)'
    > player.
    >
    > Error executing cl.exe.
    >
    > Server.exe - 1 error(s), 4 warning(s)
    >
    > For the second message I thought I did make a copy constructor for the
    > Player class! did I do it wrong?
    >
    > Player(Player &rhs); // Copy Constructor
    >
    > Player::player(Player &rhs)
    > {
    > m_state = rhs.m_state;
    > m_socket = rhs.m_socket;
    > m_ip = rhs.m_ip;
    > m_recv_buffer = rhs.m_recv_buffer;
    > m_complete_messages = rhs.m_complete_messages;
    > }
    >
    > Thanx,
    > Christopher
    >


    Have you actually read the warning message?

    identifier was truncated to '255' characters in the debug information

    Does that worry you? Do you need to see more the 255 characters in the debug
    information? You can remove this annoying message with

    #pragma warning (disable: 4786)

    Your copy constructor is valid but not usable by the STL. The best copy
    constructor to use is this

    class Player
    {
    public:
    Player(const Player &rhs); // Copy Constructor

    Its very rare that a copy constructor need to modify the object being
    copied, so say so by using const.

    john
    John Harrison, Aug 24, 2003
    #1
    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. Peter Jansson
    Replies:
    5
    Views:
    6,255
    Ivan Vecerina
    Mar 17, 2005
  2. Replies:
    1
    Views:
    401
    red floyd
    Dec 21, 2008
  3. Thomas J. Gritzan
    Replies:
    6
    Views:
    991
    James Kanze
    Dec 22, 2008
  4. James Kanze
    Replies:
    0
    Views:
    1,974
    James Kanze
    Dec 21, 2008
  5. Replies:
    1
    Views:
    363
Loading...

Share This Page