/* * Copyright Neal Becker 2009 * 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) * * Test demo for array_range.hpp */ #include "array_range.hpp" #include #include // Simple example function using boost::range interface template typename boost::range_value::type sum (in_t const& in) { typename boost::range_const_iterator::type i = boost::begin (in); typename boost::range_const_iterator::type e = boost::end (in); typename boost::range_value::type o = 0; for (; i != e; ++i) o += *i; return o; } int main () { double x[10]; for (int i = 0; i < 10; ++i) x[i] = i; double y = sum (make_array_range (x, 10)); std::cout << y << '\n'; }