#include <hpx/hpx_main.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/parallel/algorithms/transform_inclusive_scan.hpp>

struct Integer {
    int integer;
};

int main(int argc, char *argv[]) {
    std::vector<int> test{1, 10, 100, 1000};
    std::vector<Integer> output(test.size());
    auto pol    = hpx::parallel::execution::par(hpx::parallel::execution::task);
    auto result = hpx::parallel::transform_inclusive_scan(
                      pol, test.cbegin(), test.cend(), output.begin(),
                      [](Integer acc, Integer xs) -> Integer {
                          return Integer{acc.integer + xs.integer};
                      },
                      [](int el) -> Integer { return Integer{el}; }/*, Integer{0}*/)
                      .get();
    for(auto el : output) {
        hpx::cout << el.integer << hpx::endl;
    }
    return 0;
}

/*
....\hpx\parallel\algorithms\transform_inclusive_scan.hpp(132): error C2672:
'hpx::util::invoke': no matching overloaded function found
....\hpx/parallel/algorithms/detail/dispatch.hpp(357): note: see reference
to function template instantiation 'hpx::lcos::future<T>
hpx::parallel::v1::detail::transform_inclusive_scan<FwdIter2>::parallel<hpx::parallel::execution::parallel_task_policy&,FwdIter1,_Ty,int,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>>(ExPolicy,FwdIter1,FwdIter1,FwdIter2,Conv
&&,int &&,Op &&)' being compiled with
          [
              T=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter1=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>,
              _Ty=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              ExPolicy=hpx::parallel::execution::parallel_task_policy &,
              Conv=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              Op=hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>
          ]
....\hpx/parallel/algorithms/detail/dispatch.hpp(358): note: see reference
to function template instantiation 'hpx::lcos::future<T>
hpx::parallel::v1::detail::transform_inclusive_scan<FwdIter2>::parallel<hpx::parallel::execution::parallel_task_policy&,FwdIter1,_Ty,int,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>>(ExPolicy,FwdIter1,FwdIter1,FwdIter2,Conv
&&,int &&,Op &&)' being compiled with
          [
              T=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter1=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>,
              _Ty=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              ExPolicy=hpx::parallel::execution::parallel_task_policy &,
              Conv=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              Op=hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>
          ]
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(181): note: see
reference to function template instantiation 'hpx::lcos::future<T>
hpx::parallel::v1::detail::algorithm<hpx::parallel::v1::detail::transform_inclusive_scan<FwdIter2>,FwdIter2>::call<hpx::parallel::execution::parallel_task_policy&,FwdIter1&,FwdIter1&,FwdIter2&,_Ty,int,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>>(ExPolicy,std::false_type,FwdIter1
&,FwdIter1 &,FwdIter2 &,_Ty &&,int &&,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06> &&) const' being
compiled with
          [
              T=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter1=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>,
              _Ty=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              ExPolicy=hpx::parallel::execution::parallel_task_policy &
          ]
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(178): note: see
reference to function template instantiation 'hpx::lcos::future<T>
hpx::parallel::v1::detail::algorithm<hpx::parallel::v1::detail::transform_inclusive_scan<FwdIter2>,FwdIter2>::call<hpx::parallel::execution::parallel_task_policy&,FwdIter1&,FwdIter1&,FwdIter2&,_Ty,int,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>>(ExPolicy,std::false_type,FwdIter1
&,FwdIter1 &,FwdIter2 &,_Ty &&,int &&,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06> &&) const' being
compiled with
          [
              T=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter1=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>,
              _Ty=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              ExPolicy=hpx::parallel::execution::parallel_task_policy &
          ]
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(439): note: see
reference to function template instantiation 'hpx::lcos::future<T>
hpx::parallel::v1::detail::transform_inclusive_scan_<hpx::parallel::execution::parallel_task_policy&,FwdIter1,FwdIter2,_Ty,hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,int>(ExPolicy,FwdIter1,FwdIter1,FwdIter2,Conv
&&,int,Op &&,std::false_type)' being compiled with
          [
              T=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              FwdIter1=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>,
              FwdIter2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              _Ty=hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>,
              ExPolicy=hpx::parallel::execution::parallel_task_policy &,
              Conv=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,
              Op=hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>
          ]
  C:\Projects\Test\hpx\transform_op_noinit\main.cpp(18): note: see reference to function template instantiation
'hpx::lcos::future<T>
hpx::parallel::v1::transform_inclusive_scan<hpx::parallel::execution::parallel_task_policy&,std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>,hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>,42,0>(ExPolicy,FwdIter1,FwdIter1,FwdIter2,Op
&&,Conv &&)' being compiled with
          [
              T=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              _Ty=int,
              ExPolicy=hpx::parallel::execution::parallel_task_policy &,
              FwdIter1=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>,
              FwdIter2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<Integer>>>,
              Op=hpx_startup::user_main::<lambda_75248d8b5a61340f9e0ee523bc83bd06>,
              Conv=hpx_startup::user_main::<lambda_755cc1564d605a3c71061167843da3bc>
          ]
....\hpx\parallel\algorithms\transform_inclusive_scan.hpp(132): error C2893:
Failed to specialize function template 'util::invoke_result<F,Ts...>::type hpx::util::invoke(F &&,Ts &&...)'
....\hpx/functional/invoke.hpp(133): note: see declaration of
'hpx::util::invoke'
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(132): note: With
the following template arguments:
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(132): note:
'F=const Op &'
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(132): note:
'Ts={Integer &, T &}'
....\hpx\parallel\algorithms\transform_inclusive_scan.hpp(142): error C2440:
'initializing': cannot convert from 'Integer' to 'T' with
          [
              T=int
          ]
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(142): note: No
user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Libraries\vcpkg\installed\x64-windows\include\hpx\parallel\algorithms\transform_inclusive_scan.hpp(144): error C2679:
binary '=': no operator found which takes a right-hand operand of type 'T' (or there is no acceptable conversion) with
          [
              T=int
          ]
  C:\Projects\Test\hpx\transform_op_noinit\main.cpp(7): note: could be 'Integer &Integer::operator =(Integer &&)'
  C:\Projects\Test\hpx\transform_op_noinit\main.cpp(7): note: or       'Integer &Integer::operator =(const Integer &)'
....\hpx/parallel/algorithms/transform_inclusive_scan.hpp(144): note:
while trying to match the argument list '(Integer, T)' with
          [
              T=int
          ]

*/