// Copyright David Abrahams 2008. Distributed under the Boost // Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include int g[] = { 0, 1, 2, 3, 4 }; typedef int* vertex_iterator; std::pair vertices(int(&g)[5]) { return std::make_pair(&g[0], &g[0]+5); } template inline T operator%(T& start, std::pair const& r) { start = r.first; return r.second; } int main() { for (vertex_iterator pv,ve = pv%vertices(g); pv != ve; ++pv) { std::cout << *pv << std::endl; } }