auto in argument list
От: D14  
Дата: 12.07.09 07:57
Оценка:
Балуюсь Intel C++.
Так можно.
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{   
    double arr[]={1,2.5,3,4,5};
    std::vector<double> v(arr,arr+5);
    typedef decltype(v[0]) ElemType;
    std::for_each(v.begin(),v.end(),[&](ElemType e){std::cout << e << " " ;});  
    std::cout << std::endl;
    for (auto it = v.begin(),end=v.end(); it !=end; ++it)    
    {
        std::cout << *it << " " ;
    }
    std::cout << std::endl;  
    return 0;
}

А так нельзя
    std::for_each(v.begin(),v.end(),[&](auto e){std::cout << e << " " ;});

Так ПОКА нельзя, или вообще никогда можно не будет?
c++0x
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.