Invoking begin and end via using-directive?

后端 未结 4 2103
刺人心
刺人心 2021-02-19 01:44

The established idiom for invoking swap is:

using std::swap
swap(foo, bar);

This way, swap can be overloaded for user

4条回答
  •  走了就别回头了
    2021-02-19 02:06

    If your some_container is standard container, std:: prefix is needless

    #include 
    #include 
    #include 
    int main(){ 
           std::vectorv { 1, 7, 1, 3, 6, 7 };
           std::sort( begin(v), end(v) ); // here ADL search finds std::begin, std::end
    }
    

提交回复
热议问题