You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6KB

  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Eric Niebler 2013-present
  5. //
  6. // Use, modification and distribution is subject to the
  7. // Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // Project home: https://github.com/ericniebler/range-v3
  12. //
  13. #ifndef RANGES_V3_ALGORITHM_FILL_HPP
  14. #define RANGES_V3_ALGORITHM_FILL_HPP
  15. #include <range/v3/range_fwd.hpp>
  16. #include <range/v3/iterator/concepts.hpp>
  17. #include <range/v3/range/access.hpp>
  18. #include <range/v3/range/concepts.hpp>
  19. #include <range/v3/range/dangling.hpp>
  20. #include <range/v3/range/traits.hpp>
  21. #include <range/v3/utility/static_const.hpp>
  22. namespace ranges
  23. {
  24. /// \addtogroup group-algorithms
  25. /// @{
  26. RANGES_BEGIN_NIEBLOID(fill)
  27. /// \brief function template \c fill
  28. template<typename O, typename S, typename V>
  29. auto RANGES_FUN_NIEBLOID(fill)(O first, S last, V const & val) //
  30. ->CPP_ret(O)( //
  31. requires output_iterator<O, V const &> && sentinel_for<S, O>)
  32. {
  33. for(; first != last; ++first)
  34. *first = val;
  35. return first;
  36. }
  37. /// \overload
  38. template<typename Rng, typename V>
  39. auto RANGES_FUN_NIEBLOID(fill)(Rng && rng, V const & val)
  40. ->CPP_ret(safe_iterator_t<Rng>)( //
  41. requires output_range<Rng, V const &>)
  42. {
  43. return (*this)(begin(rng), end(rng), val);
  44. }
  45. RANGES_END_NIEBLOID(fill)
  46. namespace cpp20
  47. {
  48. using ranges::fill;
  49. }
  50. /// @}
  51. } // namespace ranges
  52. #endif // include guard