fill.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright Neil Groves 2009. Use, modification and
  2. // distribution is subject to the Boost Software License, Version
  3. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. //
  6. //
  7. // For more information, see http://www.boost.org/libs/range/
  8. //
  9. #ifndef BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED
  10. #define BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED
  11. #include <boost/concept_check.hpp>
  12. #include <boost/range/begin.hpp>
  13. #include <boost/range/end.hpp>
  14. #include <boost/range/concepts.hpp>
  15. #include <algorithm>
  16. namespace boost
  17. {
  18. namespace range
  19. {
  20. /// \brief template function fill
  21. ///
  22. /// range-based version of the fill std algorithm
  23. ///
  24. /// \pre ForwardRange is a model of the ForwardRangeConcept
  25. template< class ForwardRange, class Value >
  26. inline ForwardRange& fill(ForwardRange& rng, const Value& val)
  27. {
  28. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
  29. std::fill(boost::begin(rng), boost::end(rng), val);
  30. return rng;
  31. }
  32. /// \overload
  33. template< class ForwardRange, class Value >
  34. inline const ForwardRange& fill(const ForwardRange& rng, const Value& val)
  35. {
  36. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
  37. std::fill(boost::begin(rng), boost::end(rng), val);
  38. return rng;
  39. }
  40. } // namespace range
  41. using range::fill;
  42. }
  43. #endif // include guard