vendredi 13 mars 2015

std::for_each function template


N4296::25.2.4 [alg.foreach] provides requirements for the function std::for_each:



template<class InputIterator, class Function> Function
for_each(InputIterator first, InputIterator last, Function f);



Requires: Function shall meet the requirements of MoveConstructible (Table 20). [ Note: Function need not meet the requirements of CopyConstructible (Table 21). —end note ]



OK, now what MoveConstructible is is the following:



Expression Post-condition
T u = rv; u is equivalent to the value of rv before the construction
T(rv) T(rv) is equivalent to the value of rv before the construction

rv’s state is unspecified [ Note:rv must still meet the requirements of the
library component that is using it. The operations listed in those requirements
must work as specified whether rv has been moved from or not. —end note ]


There was no any mention about the type Function must have operator () member function, but in fact it must. Does the Standard mention it explicitly?




Aucun commentaire:

Enregistrer un commentaire