How do you use std::transform in conjunction with containers which hold objects of type std::reference_wrapper? when reading from const std::vector<std::reference_wrapper<const float>> and writing into an std::vector<float> everything works, but if I try to write into an std::vector<std::reference_wrapper<float>> it doesn't compile giving the error
/usr/include/c++/5/bits/stl_algo.h:4214: error: use of deleted function >'std::reference_wrapper<_Tp>::reference_wrapper(_Tp&&) [with _Tp = float]' __result = __binary_op(__first1, *__first2);
I think it is trying to replace the reference instead of changing the value of the referred value. Is there a way to use transform to achieve this or should I prefer writing my own function?
Aucun commentaire:
Enregistrer un commentaire