I'm facing a similar problem: I need to transform the set of pairs by
scaling the second element (that is a double) by a certain factor.
The following line of code:
// typedef set<pair<UserEquipment*, double> SetOfFsDouble;
// SetOfFsDouble numberOfFreqSlotsToAdd
transform(numberOfFreqSlotsToAdd.begin(), numberOfFreqSlotsToAdd.end(),
numberOfFreqSlotsToAdd.begin(), f_gx(bind2nd(std::multiplies<double>(),
unit), select2nd<SetOfFsDouble::value_type>()));
reports the following error:
1>c:\program files\microsoft visual studio 8\vc\include\algorithm(650)
: error C2679: binary '=' : no operator found which takes a right-hand
operand of type 'double' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio
8\vc\include\utility(55): could be 'std:
air<_Ty1,_Ty2>
&std:
air<_Ty1,_Ty2>:
perator =(const std:
air<_Ty1,_Ty2> &)'
1> with
1> [
1> _Ty1=UserEquipment *,
1> _Ty2=double
1> ]
1> while trying to match the argument list
'(std:
air<_Ty1,_Ty2>, double)'
1> with
1> [
1> _Ty1=UserEquipment *,
1> _Ty2=double
1> ]
while the following approach:
transform(numberOfFreqSlotsToAdd.begin(), numberOfFreqSlotsToAdd.end(),
numberOfFreqSlotsToAdd.begin(),
::make_pair(select1st<SetOfFsDouble::value_type>(),
(bind2nd(std::multiplies<double>(), unit),
select2nd<SetOfFsDouble::value_type>())) );
where I try to overcome the previous problem by creating a Pair to give
back to the set, reports the following error:
1>c:\program files\microsoft visual studio 8\vc\include\algorithm(650)
: error C2064: term does not evaluate to a function taking 1 arguments
1> c:\program files\microsoft visual studio
8\vc\include\algorithm(685) : see reference to function template
instantiation '_OutIt
std::_Transform<std::_Tree<_Traits>::iterator,_OutIt,_Fn1,std::_Iter_random_helper<_Cat1,_Cat2>::_Iter_random_cat>(_InIt,_InIt,_OutIt,_Fn1,_InOutItCat,std::_Range_checked_iterator_tag)'
being compiled
1> with
1> [
1>
_OutIt=std::_Tree<std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>>::iterator,
1> _Traits=std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>,
1> _Fn1=std:
air<select1st<std:
air<UserEquipment
*,double>>,select2nd<std:
air<UserEquipment *,double>>>,
1>
_Cat1=std::_Tree<std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>>::iterator::iterator_category,
1>
_Cat2=std::_Tree<std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>>::iterator::iterator_category,
1>
_InIt=std::_Tree<std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>>::iterator,
1>
_InOutItCat=std::_Iter_random_helper<std::_Tree<std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>>::iterator::iterator_category,std::_Tree<std::_Tset_traits<std:
air<UserEquipment
*,double>,SinrBasedWithoutPowerScaling::NumberOfFrequencySlotsComparison,std::allocator<std:
air<UserEquipment
*,double>>,false>>::iterator::iterator_category>::_Iter_random_cat
1> ]
Do you have any suggestion on how to solve this problem?