std::copy to std::cout for std::pair

前端 未结 10 687
耶瑟儿~
耶瑟儿~ 2020-12-04 20:08

I have next code:

#include 
#include 
#include 
#include 

//namespace std
//{

std::ostream&         


        
10条回答
  •  孤街浪徒
    2020-12-04 21:07

    Just passing by, but this did the job for me, so it can for somebody else (cut version):

    template
    struct first_of {
        First& operator()(std::pair& v) const {
            return v.first;
        }
    };
    

    Use case given:

    transform (v.begin (), v.end (), 
               ostream_iterator(cout, "\n"), first_of ());
    

提交回复
热议问题