|
Boost Users : |
From: Daniel Dilts (diltsman_at_[hidden])
Date: 2007-08-04 23:26:15
I'm trying to figure out how to use the boost.lambda library, and I'm having
some issues, probably stupid ones, but still, issues. In the following code
I want to remove all obects from m_devices that only have 1 remaining
reference (unique() returns true). Yes, I know that this would be pretty
easy, using regular function pointers, and the like, however, I'm trying to
learn this library.
What am I doing wrong? I would also appreciate any pointers for using
boost.lambda
Whenever I compile the following code on VS2005 I get the following errors:
Warning 1 warning C4512: 'boost::lambda::identity<T>' : assignment operator
could not be generated c:\program files
(x86)\boost\boost_1_34_0\boost\lambda\detail\lambda_functor_base.hpp 43
Warning 2 warning C4512: 'boost::lambda::lambda_functor<T>' : assignment
operator could not be generated c:\program files
(x86)\boost\boost_1_34_0\boost\lambda\detail\lambda_functors.hpp 204
Warning 3 warning C4512: 'boost::lambda::identity<T>' : assignment operator
could not be generated c:\program files
(x86)\boost\boost_1_34_0\boost\lambda\detail\lambda_functor_base.hpp 43
Warning 4 warning C4512: 'boost::lambda::lambda_functor<T>' : assignment
operator could not be generated c:\program files
(x86)\boost\boost_1_34_0\boost\lambda\detail\lambda_functors.hpp 204
Error 5 error C2451: conditional expression of type
'boost::lambda::detail::member_pointer_caller<RET,A,B>' is
illegal c:\program files (x86)\microsoft visual studio
8\vc\include\algorithm 87
Error 6 error C2675: unary '!' :
'boost::lambda::detail::member_pointer_caller<RET,A,B>' does not define this
operator or a conversion to a type acceptable to the predefined
operator c:\program files (x86)\microsoft visual studio
8\vc\include\algorithm 1240
Error 7 error C2582: 'operator =' function is unavailable in
'std::pair<_Ty1,_Ty2>' c:\program files (x86)\microsoft visual studio
8\vc\include\algorithm 1241
My code for the class I'm having trouble with follows:
#pragma once
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
#include "SocketDevice.h"
namespace Socket
{
class SocketFactory
{
public:
SocketFactory(std::string Host, std::string Port);
virtual ~SocketFactory(void);
protected:
std::pair<std::string, std::string> m_dest;
boost::shared_ptr<SocketDevice> m_device;
static std::map<std::pair<std::string, std::string>,
boost::shared_ptr<SocketDevice>> m_devices;
private:
void RemoveUnreferencedSockets(void);
};
};
#include "SocketFactory.h"
#include <boost/lambda/lambda.hpp>
#include <boost/bind.hpp>
Socket::SocketFactory::~SocketFactory(void)
{
}
void Socket::SocketFactory::RemoveUnreferencedSockets(void)
{
std::remove_if(Socket::SocketFactory::m_devices.begin(),
Socket::SocketFactory::m_devices.end(),
boost::lambda::_1 ->* &std::pair<std::pair<std::string, std::string>,
boost::shared_ptr<SocketDevice> >::second
->* &boost::shared_ptr<SocketDevice>::unique);
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net