I wanted to know the time complexity of the next_permutation function. Can I view its code?
See http://www.sgi.com/tech/stl/next_permutation.html :
Linear. Maximum (last - first) / 2 swaps.
To see the source code, just browse the STL header files for your system. On a Unix-like system, you probably need to search somewhere like /usr/include/c++/4.1.2/bits/stl_algo.h .
/usr/include/c++/4.1.2/bits/stl_algo.h