|
Boost Users : |
From: François Duranleau (duranlef_at_[hidden])
Date: 2005-12-06 14:37:56
On Tue, 6 Dec 2005, gast128 wrote:
> Dear all,
>
> I am too tired to investigate it deeply, so does anyone know why this does not
> compile (on VS 2003):
>
> typedef boost::function<int (const int& , const int&)> BinOperand;
> typedef std::vector<BinOperand> BinOperandVector;
>
> BinOperandVector operands = boost::assign::list_of(std::plus<int>())
> (std::minus<int>())
> (std::multiplies<int>())
> (std::divides<int>());
That's because the first time you call list_of, it's argument is of type
std::plus<int>, and this binds the 'assignment object' to that type only.
Thus all other calls to operator() expects arguments of the same type. The
solution is to explicitly give the argument type to list_of as BinOperand
like this:
BinOperandVector operands
= boost::assign::list_of<BinOperand>(std::plus<int>())
(std::minus<int>())
(std::multiplies<int>())
(std::divides<int>());
-- François Duranleau LIGUM, Université de Montréal "When there are others, I can perceive myself as an individual. If I am alone, then I will be the same as everything else. There will be no difference between myself and nothing!" - from _Neon Genesis Evangelion_
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