<commit_before>#pragma once

#include <type_traits>
#include <agency/new_executor_traits.hpp>
#include <agency/future.hpp>

namespace agency
{
namespace detail
{
namespace new_executor_traits_detail
{


template<class Executor, class T, class Future>
struct has_future_cast_impl
{
  template<
    class Executor2,
    typename = decltype(
      std::declval<Executor2*>()->template future_cast<T>(
        *std::declval<Future*>()
      )
    )
  >
  static std::true_type test(int);

  template<class>
  static std::false_type test(...);

  using type = decltype(test<Executor>(0));
};

template<class Executor, class T, class Future>
using has_future_cast = typename has_future_cast_impl<Executor,T,Future>::type;


template<class Executor, class T, class... Args>
struct has_make_ready_future_impl
{
  template<
    class Executor2,
    typename = decltype(
      std::declval<Executor2*>()->template make_ready_future<T>(
        std::declval<Args>()...
      )
    )
  >
  static std::true_type test(int);

  template<class>
  static std::false_type test(...);

  using type = decltype(test<Executor>(0));
};


template<class Executor, class T, class... Args>
using has_make_ready_future = typename has_make_ready_future_impl<Executor,T,Args...>::type;


template<class Executor, class Function>
struct has_multi_agent_async_execute_returning_default_container_impl
{
  using index_type = typename new_executor_traits<Executor>::index_type;
  using container_value_type = typename std::result_of<Function(index_type)>::type;
  using expected_return_type = typename new_executor_traits<Executor>::template container<container_value_type>;

  template<class Executor1,
           class ReturnType = decltype(
             std::declval<Executor1>().async_execute(
               std::declval<Function>()
             )
           ),
           class = typename std::enable_if<
             std::is_same<ReturnType,expected_return_type>::value
           >::type>
  static std::true_type test(int);

  template<class>
  static std::false_type test(...);

  using type = decltype(test<Executor>(0));
};

template<class Executor, class Function>
using has_multi_agent_async_execute_returning_default_container = typename has_multi_agent_async_execute_returning_default_container_impl<Executor,Function>::type;


template<class Container, class Executor, class Function>
struct has_multi_agent_async_execute_returning_user_specified_container_impl
{
  template<class Executor1,
           class ReturnType = decltype(
             std::declval<Executor1>().template async_execute<Container>(
               std::declval<Function>()
             )
           ),
           class = typename std::enable_if<
             std::is_same<ReturnType,Container>::value
           >::type>
  static std::true_type test(int);
<commit_msg>Correct the implementation of has_multi_agent_async_execute_returning_user_specified_container<commit_after>#pragma once

#include <type_traits>
#include <agency/new_executor_traits.hpp>
#include <agency/future.hpp>

namespace agency
{
namespace detail
{
namespace new_executor_traits_detail
{


template<class Executor, class T, class Future>
struct has_future_cast_impl
{
  template<
    class Executor2,
    typename = decltype(
      std::declval<Executor2*>()->template future_cast<T>(
        *std::declval<Future*>()
      )
    )
  >
  static std::true_type test(int);

  template<class>
  static std::false_type test(...);

  using type = decltype(test<Executor>(0));
};

template<class Executor, class T, class Future>
using has_future_cast = typename has_future_cast_impl<Executor,T,Future>::type;


template<class Executor, class T, class... Args>
struct has_make_ready_future_impl
{
  template<
    class Executor2,
    typename = decltype(
      std::declval<Executor2*>()->template make_ready_future<T>(
        std::declval<Args>()...
      )
    )
  >
  static std::true_type test(int);

  template<class>
  static std::false_type test(...);

  using type = decltype(test<Executor>(0));
};


template<class Executor, class T, class... Args>
using has_make_ready_future = typename has_make_ready_future_impl<Executor,T,Args...>::type;


template<class Executor, class Function>
struct has_multi_agent_async_execute_returning_default_container_impl
{
  using index_type = typename new_executor_traits<Executor>::index_type;
  using container_value_type = typename std::result_of<Function(index_type)>::type;
  using expected_return_type = typename new_executor_traits<Executor>::template container<container_value_type>;

  template<class Executor1,
           class ReturnType = decltype(
             std::declval<Executor1>().async_execute(
               std::declval<Function>()
             )
           ),
           class = typename std::enable_if<
             std::is_same<ReturnType,expected_return_type>::value
           >::type>
  static std::true_type test(int);

  template<class>
  static std::false_type test(...);

  using type = decltype(test<Executor>(0));
};

template<class Executor, class Function>
using has_multi_agent_async_execute_returning_default_container = typename has_multi_agent_async_execute_returning_default_container_impl<Executor,Function>::type;


template<class Container, class Executor, class Function>
struct has_multi_agent_async_execute_returning_user_specified_container_impl
{
  using shape_type = typename new_executor_traits<Executor>::shape_type;
  using expected_return_type = typename new_executor_traits<Executor>::template future<Container>;

  template<class Executor1,
           class ReturnType = decltype(
             std::declval<Executor1>().template async_execute<Container>(
               std::declval<Function>(),
               std::declval<shape_type>()
             )
           ),
           class = typename std::enable_if<
             std::is_same<ReturnType,expected_return_type>::value
           >::type>
  static std::true_type test(int);

{'fraction_non_alphanumeric': 0.10926485397784491, 'fraction_numerical': 0.0036925142665323934, 'mean_word_length': 4.259488084730803, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5215399', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1754, 'n_words': 332}