There we go, I'm including whole file, well... Since I don't really know why the problem appears.
//PacketTypes.h
#pragma once
#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include <string>
#include <vector>
template<class T>
sf::Packet& operator <<(sf::Packet& Packet, const std::vector<T>& A)
{
Packet << A.size();
for (int i=0;i<A.size();i++)
{
Packet << A[i];
}
return Packet;
}
template<class T>
sf::Packet& operator >>(sf::Packet& Packet, std::vector<T>& A)
{
unsigned int size;
Packet >> size;
A.reserve(size);
for (int i=0;i<size;i++)
{
T temp;
Packet >> temp;
A.push_back(temp);
}
return Packet;
}
namespace Packets
{
namespace Types
{
typedef const sf::Uint8 PacketType;
PacketType Welcome=0x10; //Client wants to join server
PacketType Welcome_Accept=0x11; //Server accepts the user
PacketType Welcome_Decline=0x12; //Server is full
PacketType Ping=0x20; //Server pings
PacketType Pong=0x21; //Client pongs
PacketType New_User=0x30; //User joins server
PacketType Delete_User=0x31; //Server removes user from list
PacketType Status_Update=0x40;
PacketType Quit=0xFF; //User quits app
} //Namespace types
namespace Structs
{
struct New_User
{
sf::Uint8 UserId;
std::string IpAdress;
std::string Nick;
};
struct Welcome
{
bool ShowIp;
std::string Nick;
};
struct Welcome_Accept
{
sf::Uint8 UserId;
std::vector<New_User> UserList;
};
struct Delete_User
{
sf::Uint8 UserId;
};
struct Status_Update_List
{
sf::Uint8 UserId;
sf::Uint16 X;
sf::Uint16 Y;
};
typedef std::vector<Status_Update_List> Status_Update;
sf::Packet& operator <<(sf::Packet& Packet, const New_User& A)
{
return Packet << A.UserId << A.IpAdress << A.Nick;
}
sf::Packet& operator >>(sf::Packet& Packet, New_User& A)
{
return Packet >> A.UserId >> A.IpAdress >> A.Nick;
}
sf::Packet& operator <<(sf::Packet& Packet, const Welcome& A)
{
return Packet << A.ShowIp << A.Nick;
}
sf::Packet& operator >>(sf::Packet& Packet, Welcome& A)
{
return Packet >> A.ShowIp >> A.Nick;
}
sf::Packet& operator <<(sf::Packet& Packet, const Welcome_Accept& A)
{
return Packet << A.UserId << A.UserList;
}
sf::Packet& operator >>(sf::Packet& Packet, Welcome_Accept& A)
{
return Packet >> A.UserId >> A.UserList;
}
sf::Packet& operator <<(sf::Packet& Packet, const Delete_User& A)
{
return Packet << A.UserId;
}
sf::Packet& operator >>(sf::Packet& Packet, Delete_User& A)
{
return Packet >> A.UserId;
}
sf::Packet& operator <<(sf::Packet& Packet, const Status_Update_List& A)
{
return Packet << A.UserId << A.X << A.Y;
}
sf::Packet& operator >>(sf::Packet& Packet, Status_Update_List& A)
{
return Packet >> A.UserId >> A.X >> A.Y;
}
} //Namespace structs
} //Namespace packets
//Main.cpp
#include "PacketTypes.h"
int main()
{
}
And the error
1>c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(112) : error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'sf::Packet' (or there is no acceptable conversion)
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/IPAddress.hpp(226): could be 'std::ostream &sf::operator <<(std::ostream &,const sf::IPAddress &)' [found using argument-dependent lookup]
1> c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(92): or 'sf::Packet &Packets::Structs::operator <<(sf::Packet &,const Packets::Structs::New_User &)'
1> c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(101): or 'sf::Packet &Packets::Structs::operator <<(sf::Packet &,const Packets::Structs::Welcome &)'
1> c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(110): or 'sf::Packet &Packets::Structs::operator <<(sf::Packet &,const Packets::Structs::Welcome_Accept &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(128): or 'sf::Packet &sf::Packet::operator <<(bool)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(129): or 'sf::Packet &sf::Packet::operator <<(sf::Int8)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(130): or 'sf::Packet &sf::Packet::operator <<(sf::Uint8)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(131): or 'sf::Packet &sf::Packet::operator <<(sf::Int16)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(132): or 'sf::Packet &sf::Packet::operator <<(sf::Uint16)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(133): or 'sf::Packet &sf::Packet::operator <<(sf::Int32)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(134): or 'sf::Packet &sf::Packet::operator <<(sf::Uint32)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(135): or 'sf::Packet &sf::Packet::operator <<(float)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(136): or 'sf::Packet &sf::Packet::operator <<(double)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(137): or 'sf::Packet &sf::Packet::operator <<(const char *)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(138): or 'sf::Packet &sf::Packet::operator <<(const std::string &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(139): or 'sf::Packet &sf::Packet::operator <<(const wchar_t *)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(140): or 'sf::Packet &sf::Packet::operator <<(const std::wstring &)'
1> while trying to match the argument list '(sf::Packet, const std::vector<_Ty>)'
1> with
1> [
1> _Ty=Packets::Structs::New_User
1> ]
1>c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(116) : error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'sf::Packet' (or there is no acceptable conversion)
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/IPAddress.hpp(215): could be 'std::istream &sf::operator >>(std::istream &,sf::IPAddress &)' [found using argument-dependent lookup]
1> c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(96): or 'sf::Packet &Packets::Structs::operator >>(sf::Packet &,Packets::Structs::New_User &)'
1> c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(105): or 'sf::Packet &Packets::Structs::operator >>(sf::Packet &,Packets::Structs::Welcome &)'
1> c:\documents and settings\ritave\moje dokumenty\visual studio 2008\projects\pointertest\pointertest\PacketTypes.h(114): or 'sf::Packet &Packets::Structs::operator >>(sf::Packet &,Packets::Structs::Welcome_Accept &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(110): or 'sf::Packet &sf::Packet::operator >>(bool &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(111): or 'sf::Packet &sf::Packet::operator >>(sf::Int8 &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(112): or 'sf::Packet &sf::Packet::operator >>(sf::Uint8 &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(113): or 'sf::Packet &sf::Packet::operator >>(sf::Int16 &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(114): or 'sf::Packet &sf::Packet::operator >>(sf::Uint16 &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(115): or 'sf::Packet &sf::Packet::operator >>(sf::Int32 &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(116): or 'sf::Packet &sf::Packet::operator >>(sf::Uint32 &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(117): or 'sf::Packet &sf::Packet::operator >>(float &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(118): or 'sf::Packet &sf::Packet::operator >>(double &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(119): or 'sf::Packet &sf::Packet::operator >>(char *)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(120): or 'sf::Packet &sf::Packet::operator >>(std::string &)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(121): or 'sf::Packet &sf::Packet::operator >>(wchar_t *)'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\SFML/Network/Packet.hpp(122): or 'sf::Packet &sf::Packet::operator >>(std::wstring &)'
1> while trying to match the argument list '(sf::Packet, std::vector<_Ty>)'
1> with
1> [
1> _Ty=Packets::Structs::New_User
1> ]
The error lines are in code from previous post, in calling snippet (the return lines)
That's my whole project, Visual C++ Empty Project, SFML dynamic, preprocessor macro is done, and sfml-system.lib and sfml-network.lib are included