It seems Boost offers a topological sort algorithm,

http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/topological_sort.html