generate.hpp 878 Bytes
Newer Older
Edwin Carlinet's avatar
Edwin Carlinet committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once
#include <mln/core/image/image.hpp>
#include <mln/core/rangev3/rows.hpp>


namespace mln
{
  namespace experimental
  {
    template <class OutputImage, class Generator>
    void generate(OutputImage output, Generator g);
  }

  /******************************************/
  /****          Implementation          ****/
  /******************************************/

  namespace experimental
  {
    template <class OutputImage, class Generator>
    void generate(OutputImage output, Generator g)
    {
      static_assert(mln::is_a<OutputImage, Image>());
      static_assert(std::is_convertible_v<std::invoke_result_t<Generator>, image_value_t<OutputImage>>);

26
27
      auto&& vals = output.new_values();
      for (auto row : mln::ranges::rows(vals))
Edwin Carlinet's avatar
Edwin Carlinet committed
28
29
30
31
32
33
34
35
        for (auto& v : row)
          v = g();
    }
  } // namespace experimental

} // end of namespace mln